diff --git a/ChangeLog.md b/ChangeLog.md index bfc380b19ff..575a28a9f84 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,20 @@ # Change Log +### 2021-xx-xx - 5.9.0 + +| Library | Min Version +| --------------- | ------- +|`@autorest/core` | `3.4.5` +|`@autorest/modelerfour` | `4.19.1` +|`azure-core` dep of generated code | `1.16.0` +|`msrest` dep of generated code | `0.6.21` +|`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.2.1` + +**New Features** + +- We have added a **provisional** `rest` layer to our generated code. We have also added the following **provisional** flags listed [here](https://github.com/Azure/autorest.python/wiki/Generating-Low-Level-Client#generate-a-low-level-client). #875 +- With this new release, we are also dropping support for Python 3.5 + async. #875 + ### 2021-07-13 - 5.8.4 min Autorest core version: 3.4.5 diff --git a/autorest/codegen/__init__.py b/autorest/codegen/__init__.py index 233849c5bc3..61058f88e0c 100644 --- a/autorest/codegen/__init__.py +++ b/autorest/codegen/__init__.py @@ -13,12 +13,40 @@ from .models import build_schema from .models.operation_group import OperationGroup from .models.parameter import Parameter -from .models.parameter_list import ParameterList -from .models.credential_schema import AzureKeyCredentialSchema, TokenCredentialSchema -from .models.credential_schema_policy import get_credential_schema_policy, CredentialSchemaPolicy +from .models.parameter_list import GlobalParameterList +from .models.rest import Rest from .serializers import JinjaSerializer +from .models.credential_schema_policy import CredentialSchemaPolicy, get_credential_schema_policy +from .models.credential_schema import AzureKeyCredentialSchema, TokenCredentialSchema +def _get_credential_default_policy_type_has_async_version(credential_default_policy_type: str) -> bool: + mapping = { + "BearerTokenCredentialPolicy": True, + "AzureKeyCredentialPolicy": False + } + return mapping[credential_default_policy_type] + +def _build_convenience_layer(yaml_data: Dict[str, Any], code_model: CodeModel) -> None: + # Create operations + if code_model.show_operations and yaml_data.get("operationGroups"): + code_model.operation_groups = [ + OperationGroup.from_yaml(code_model, op_group) for op_group in yaml_data["operationGroups"] + ] + if code_model.show_models and yaml_data.get("schemas"): + # sets the enums property in our code_model variable, which will later be passed to EnumSerializer + + code_model.add_inheritance_to_models() + code_model.sort_schemas() + code_model.link_operation_to_request_builder() + code_model.add_schema_link_to_operation() + code_model.generate_single_parameter_from_multiple_media_types_operation() + + if code_model.show_operations: + # LRO operation + code_model.format_lro_operations() + code_model.remove_next_operation() + _LOGGER = logging.getLogger(__name__) class CodeGenerator(Plugin): @staticmethod @@ -56,7 +84,35 @@ def _build_exceptions_set(yaml_data: List[Dict[str, Any]]) -> Set[int]: def _create_code_model(self, yaml_data: Dict[str, Any], options: Dict[str, Union[str, bool]]) -> CodeModel: # Create a code model - code_model = CodeModel(options) + low_level_client = self._autorestapi.get_boolean_value("low-level-client", False) + show_models = self._autorestapi.get_boolean_value( + "show-models", + not low_level_client + ) + show_builders = self._autorestapi.get_boolean_value( + "show-builders", + low_level_client + ) + show_operations = self._autorestapi.get_boolean_value( + "show-operations", + not low_level_client + ) + show_send_request = self._autorestapi.get_boolean_value( + "show-send-request", + low_level_client + ) + only_path_and_body_params_positional = self._autorestapi.get_boolean_value( + "only-path-and-body-params-positional", + low_level_client + ) + code_model = CodeModel( + show_builders=show_builders, + show_models=show_models, + show_operations=show_operations, + show_send_request=show_send_request, + only_path_and_body_params_positional=only_path_and_body_params_positional, + options=options, + ) if code_model.options['credential']: self._handle_default_authentication_policy(code_model) code_model.module_name = yaml_data["info"]["python_title"] @@ -66,9 +122,8 @@ def _create_code_model(self, yaml_data: Dict[str, Any], options: Dict[str, Union ) # Global parameters - code_model.global_parameters = ParameterList( + code_model.global_parameters = GlobalParameterList( [Parameter.from_yaml(param) for param in yaml_data.get("globalParameters", [])], - implementation="Client", ) # Custom URL @@ -79,17 +134,13 @@ def _create_code_model(self, yaml_data: Dict[str, Any], options: Dict[str, Union # UGLY as hell..... if yaml_data.get("operationGroups"): first_req_of_first_op_of_first_grp = yaml_data["operationGroups"][0]["operations"][0]["requests"][0] - code_model.custom_base_url = first_req_of_first_op_of_first_grp["protocol"]["http"]["uri"] + code_model.service_client.custom_base_url = ( + first_req_of_first_op_of_first_grp["protocol"]["http"]["uri"] + ) else: for host in dollar_host: code_model.global_parameters.remove(host) - code_model.base_url = dollar_host[0].yaml_data["clientDefaultValue"] - - # Create operations - if yaml_data.get("operationGroups"): - code_model.operation_groups = [ - OperationGroup.from_yaml(code_model, op_group) for op_group in yaml_data["operationGroups"] - ] + code_model.service_client.base_url = dollar_host[0].yaml_data["clientDefaultValue"] # Get my namespace namespace = self._autorestapi.get_value("namespace") @@ -98,23 +149,17 @@ def _create_code_model(self, yaml_data: Dict[str, Any], options: Dict[str, Union namespace = yaml_data["info"]["python_title"] code_model.namespace = namespace + code_model.rest = Rest.from_yaml(yaml_data, code_model=code_model) if yaml_data.get("schemas"): exceptions_set = CodeGenerator._build_exceptions_set(yaml_data=yaml_data["operationGroups"]) for type_list in yaml_data["schemas"].values(): for schema in type_list: build_schema(yaml_data=schema, exceptions_set=exceptions_set, code_model=code_model) - # sets the enums property in our code_model variable, which will later be passed to EnumSerializer - - code_model.add_inheritance_to_models() - code_model.sort_schemas() - code_model.add_schema_link_to_operation() + code_model.add_schema_link_to_request_builder() code_model.add_schema_link_to_global_parameters() - code_model.generate_single_parameter_from_multiple_media_types() - # LRO operation - code_model.format_lro_operations() - code_model.remove_next_operation() + _build_convenience_layer(yaml_data=yaml_data, code_model=code_model) if options["credential"]: code_model.add_credential_global_parameter() @@ -230,6 +275,7 @@ def _build_code_model_options(self) -> Dict[str, Any]: "client_side_validation": self._autorestapi.get_boolean_value("client-side-validation", False), "tracing": self._autorestapi.get_boolean_value("trace", False), "multiapi": self._autorestapi.get_boolean_value("multiapi", False), + "polymorphic_examples": self._autorestapi.get_value("polymorphic-examples") or 5, } if options["basic_setup_py"] and not options["package_version"]: diff --git a/autorest/codegen/models/__init__.py b/autorest/codegen/models/__init__.py index 098def60012..22c109ec686 100644 --- a/autorest/codegen/models/__init__.py +++ b/autorest/codegen/models/__init__.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Any, Dict +from typing import Any, Dict, TypeVar, Union from .base_model import BaseModel from .code_model import CodeModel from .credential_schema import AzureKeyCredentialSchema, TokenCredentialSchema @@ -22,8 +22,13 @@ from .property import Property from .operation_group import OperationGroup from .schema_response import SchemaResponse -from .parameter_list import ParameterList - +from .parameter_list import GlobalParameterList, ParameterList +from .request_builder_parameter_list import RequestBuilderParameterList +from .request_builder import RequestBuilder +from .base_builder import BaseBuilder +from .lro_paging_operation import LROPagingOperation +from .request_builder_parameter import RequestBuilderParameter +from .schema_request import SchemaRequest __all__ = [ "AzureKeyCredentialSchema", @@ -47,8 +52,13 @@ "ParameterList", "OperationGroup", "Property", + "RequestBuilder", "SchemaResponse", "TokenCredentialSchema", + "LROPagingOperation", + "BaseBuilder", + "SchemaRequest", + "RequestBuilderParameter", ] def _generate_as_object_schema(yaml_data: Dict[str, Any]) -> bool: @@ -90,7 +100,7 @@ def build_schema(yaml_data: Dict[str, Any], **kwargs) -> BaseSchema: schema = DictionarySchema.from_yaml(namespace=namespace, yaml_data=yaml_data, **kwargs) code_model.primitives[yaml_id] = schema - elif schema_type in ["object", "and", "group"]: + elif schema_type in ["object", "and", "group", "any-object"]: if _generate_as_object_schema(yaml_data): # To avoid infinite loop, create the right instance in memory, # put it in the index, and then parse the object. @@ -100,9 +110,28 @@ def build_schema(yaml_data: Dict[str, Any], **kwargs) -> BaseSchema: else: schema = AnySchema.from_yaml(namespace=namespace, yaml_data=yaml_data) code_model.primitives[yaml_id] = schema - else: schema = get_primitive_schema(namespace=namespace, yaml_data=yaml_data) code_model.primitives[yaml_id] = schema return schema + +BuilderType = TypeVar( + "BuilderType", + bound=Union[ + RequestBuilder, + Operation, + LROPagingOperation, + LROOperation, + PagingOperation, + ] +) + +ParameterListType = TypeVar( + "ParameterListType", + bound=Union[ + ParameterList, + GlobalParameterList, + RequestBuilderParameterList, + ], +) diff --git a/autorest/codegen/models/base_builder.py b/autorest/codegen/models/base_builder.py new file mode 100644 index 00000000000..0bc89c8e2fe --- /dev/null +++ b/autorest/codegen/models/base_builder.py @@ -0,0 +1,96 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, List, Optional, Union, TYPE_CHECKING +from abc import abstractmethod +from .base_model import BaseModel +from .schema_response import SchemaResponse + +if TYPE_CHECKING: + from . import ParameterListType + + +_M4_HEADER_PARAMETERS = ["content_type", "accept"] + +def get_converted_parameters(yaml_data: Dict[str, Any], parameter_converter: Callable): + multiple_requests = len(yaml_data["requests"]) > 1 + + multiple_media_type_parameters = [] + parameters = [parameter_converter(yaml) for yaml in yaml_data.get("parameters", [])] + + for request in yaml_data["requests"]: + for yaml in request.get("parameters", []): + parameter = parameter_converter(yaml) + name = yaml["language"]["python"]["name"] + if name in _M4_HEADER_PARAMETERS: + parameters.append(parameter) + elif multiple_requests: + parameter.has_multiple_media_types = True + multiple_media_type_parameters.append(parameter) + else: + parameters.append(parameter) + + if multiple_media_type_parameters: + body_parameters_name_set = set( + p.serialized_name for p in multiple_media_type_parameters + ) + if len(body_parameters_name_set) > 1: + raise ValueError( + f"The body parameter with multiple media types has different names: {body_parameters_name_set}" + ) + + + parameters_index = {id(parameter.yaml_data): parameter for parameter in parameters} + + # Need to connect the groupBy and originalParameter + for parameter in parameters: + parameter_grouped_by_id = id(parameter.grouped_by) + if parameter_grouped_by_id in parameters_index: + parameter.grouped_by = parameters_index[parameter_grouped_by_id] + + parameter_original_id = id(parameter.original_parameter) + if parameter_original_id in parameters_index: + parameter.original_parameter = parameters_index[parameter_original_id] + + return parameters, multiple_media_type_parameters + +class BaseBuilder(BaseModel): + """Base class for Operations and Request Builders""" + + def __init__( + self, + yaml_data: Dict[str, Any], + name: str, + description: str, + parameters: "ParameterListType", + responses: Optional[List[SchemaResponse]] = None, + summary: Optional[str] = None, + ) -> None: + super().__init__(yaml_data=yaml_data) + self.name = name + self.description = description + self.parameters = parameters + self.responses = responses or [] + self.summary = summary + + @property + def default_content_type_declaration(self) -> str: + return f'"{self.parameters.default_content_type}"' + + def get_response_from_status(self, status_code: int) -> SchemaResponse: + for response in self.responses: + if status_code in response.status_codes: + return response + raise ValueError(f"Incorrect status code {status_code}, operation {self.name}") + + @property + def success_status_code(self) -> List[Union[str, int]]: + """The list of all successfull status code.""" + return [code for response in self.responses for code in response.status_codes if code != "default"] + + @staticmethod + @abstractmethod + def get_parameter_converter() -> Callable: + ... diff --git a/autorest/codegen/models/base_schema.py b/autorest/codegen/models/base_schema.py index 3be72596ee5..c4038c65b14 100644 --- a/autorest/codegen/models/base_schema.py +++ b/autorest/codegen/models/base_schema.py @@ -35,8 +35,7 @@ def has_xml_serialization_ctxt(self) -> bool: return bool(self.xml_metadata) def xml_serialization_ctxt(self) -> Optional[str]: - """Return the serialization context in case this schema is used in an operation. - """ + """Return the serialization context in case this schema is used in an operation.""" attrs_list = [] if self.xml_metadata.get("name"): attrs_list.append(f"'name': '{self.xml_metadata['name']}'") @@ -127,3 +126,13 @@ def validation_map(self) -> Optional[Dict[str, Union[bool, int, str]]]: # pylin @property def serialization_constraints(self) -> Optional[List[str]]: # pylint: disable=no-self-use return None + + @abstractmethod + def get_json_template_representation(self, **kwargs: Any) -> Any: + """Template of what this schema would look like as JSON input""" + ... + + @abstractmethod + def get_files_template_representation(self, **kwargs: Any) -> Any: + """Template of what this schema would look like as files input""" + ... diff --git a/autorest/codegen/models/client.py b/autorest/codegen/models/client.py index 80927742341..c80e7be065a 100644 --- a/autorest/codegen/models/client.py +++ b/autorest/codegen/models/client.py @@ -3,6 +3,10 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from typing import List, Optional +from .primitive_schemas import StringSchema +from .parameter import Parameter, ParameterLocation +from .parameter_list import GlobalParameterList from .imports import FileImport, ImportType, TypingSection @@ -10,9 +14,15 @@ class Client: """A service client. """ - @staticmethod - def pipeline_class(code_model, async_mode: bool) -> str: - if code_model.options["azure_arm"]: + def __init__(self, code_model, parameters: GlobalParameterList): + self.code_model = code_model + self.parameters = parameters + self.base_url: Optional[str] = None + self.custom_base_url = None + self._config_parameters = parameters + + def pipeline_class(self, async_mode: bool) -> str: + if self.code_model.options["azure_arm"]: if async_mode: return "AsyncARMPipelineClient" return "ARMPipelineClient" @@ -20,41 +30,100 @@ def pipeline_class(code_model, async_mode: bool) -> str: return "AsyncPipelineClient" return "PipelineClient" - @staticmethod - def imports(code_model, async_mode: bool) -> FileImport: + def _imports_shared(self, async_mode: bool) -> FileImport: file_import = FileImport() file_import.add_from_import("msrest", "Serializer", ImportType.AZURECORE) file_import.add_from_import("msrest", "Deserializer", ImportType.AZURECORE) file_import.add_from_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) - if async_mode: + + any_optional_gp = any(not gp.required for gp in self.parameters) + + if any_optional_gp or self.code_model.service_client.base_url: + file_import.add_from_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL) + + if self.code_model.options["azure_arm"]: file_import.add_from_import( - "azure.core.pipeline.transport", "AsyncHttpResponse", ImportType.AZURECORE, TypingSection.CONDITIONAL + "azure.mgmt.core", self.pipeline_class(async_mode), ImportType.AZURECORE ) else: file_import.add_from_import( - "azure.core.pipeline.transport", "HttpResponse", ImportType.AZURECORE, TypingSection.CONDITIONAL + "azure.core", self.pipeline_class(async_mode), ImportType.AZURECORE ) + + for gp in self.code_model.global_parameters: + file_import.merge(gp.imports()) file_import.add_from_import( - "azure.core.pipeline.transport", "HttpRequest", ImportType.AZURECORE, TypingSection.CONDITIONAL + "._configuration", f"{self.code_model.class_name}Configuration", + ImportType.LOCAL ) - any_optional_gp = any(not gp.required for gp in code_model.global_parameters) - if any_optional_gp or code_model.base_url: - file_import.add_from_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL) + return file_import - if code_model.options["azure_arm"]: + def imports(self, async_mode: bool) -> FileImport: + file_import = self._imports_shared(async_mode) + if async_mode: + file_import.add_from_import("typing", "Awaitable", ImportType.STDLIB) file_import.add_from_import( - "azure.mgmt.core", Client.pipeline_class(code_model, async_mode), ImportType.AZURECORE + "azure.core.rest", "AsyncHttpResponse", ImportType.AZURECORE, TypingSection.CONDITIONAL ) else: file_import.add_from_import( - "azure.core", Client.pipeline_class(code_model, async_mode), ImportType.AZURECORE + "azure.core.rest", "HttpResponse", ImportType.AZURECORE, TypingSection.CONDITIONAL ) + file_import.add_from_import("azure.core.rest", "HttpRequest", ImportType.AZURECORE, TypingSection.CONDITIONAL) + for og in self.code_model.operation_groups: + file_import.add_from_import(".operations", og.class_name, ImportType.LOCAL) - if not code_model.sorted_schemas: + if self.code_model.sorted_schemas: + path_to_models = ".." if async_mode else "." + file_import.add_from_import(path_to_models, "models", ImportType.LOCAL) + else: # in this case, we have client_models = {} in the service client, which needs a type annotation # this import will always be commented, so will always add it to the typing section file_import.add_from_import("typing", "Dict", ImportType.STDLIB, TypingSection.TYPING) + file_import.add_from_import("copy", "deepcopy", ImportType.STDLIB) + return file_import + def imports_for_multiapi(self, async_mode: bool) -> FileImport: + file_import = self._imports_shared(async_mode) + try: + mixin_operation = next(og for og in self.code_model.operation_groups if og.is_empty_operation_group) + file_import.add_from_import("._operations_mixin", mixin_operation.class_name, ImportType.LOCAL) + except StopIteration: + pass return file_import + + @property + def method_parameters(self) -> List[Parameter]: + base_url_param = [] + if self.base_url: + base_url_param = [Parameter( + yaml_data={}, + schema=StringSchema(namespace="", yaml_data={"type": "str"}), + rest_api_name="base_url", + serialized_name="base_url", + description="Service URL", + implementation="Client", + required=False, + location=ParameterLocation.Other, + skip_url_encoding=False, + constraints=[], + )] + return self.parameters.method + base_url_param + + def method_parameters_signature(self, async_mode) -> List[str]: + return [ + parameter.method_signature(async_mode) for parameter in self.method_parameters + ] + self.parameters.method_signature_kwargs(async_mode) + + def send_request_signature(self, async_mode) -> List[str]: + request_signature = ["request: HttpRequest," if async_mode else "request, # type: HttpRequest"] + return request_signature + self.parameters.method_signature_kwargs(async_mode) + + @property + def config_initialization(self) -> str: + method = ", ".join([p.serialized_name for p in self.parameters.method]) + if method: + return method + ", **kwargs" + return "**kwargs" diff --git a/autorest/codegen/models/code_model.py b/autorest/codegen/models/code_model.py index c9ee83ccc03..6b598b72e88 100644 --- a/autorest/codegen/models/code_model.py +++ b/autorest/codegen/models/code_model.py @@ -19,15 +19,16 @@ from .paging_operation import PagingOperation from .parameter import Parameter, ParameterLocation from .client import Client -from .parameter_list import ParameterList +from .parameter_list import GlobalParameterList from .schema_response import SchemaResponse from .property import Property from .primitive_schemas import IOSchema +from .request_builder import RequestBuilder +from .rest import Rest _LOGGER = logging.getLogger(__name__) - class CodeModel: # pylint: disable=too-many-instance-attributes """Holds all of the information we have parsed out of the yaml file. The CodeModel is what gets serialized by the serializers. @@ -54,7 +55,21 @@ class CodeModel: # pylint: disable=too-many-instance-attributes :param str base_url: Optional. The default base_url. Will include the host from yaml """ - def __init__(self, options: Dict[str, Any]) -> None: + def __init__( + self, + options: Dict[str, Any], + *, + show_builders: Optional[bool] = False, + show_models: Optional[bool] = True, + show_operations: Optional[bool] = True, + show_send_request: Optional[bool] = False, + only_path_and_body_params_positional: Optional[bool] = False, + ) -> None: + self.rest_layer_name = "rest" if show_builders else "_rest" + self.send_request_name = "send_request" if show_send_request else "_send_request" + self.show_models = show_models + self.show_operations = show_operations + self.only_path_and_body_params_positional = only_path_and_body_params_positional self.options = options self.module_name: str = "" self.class_name: str = "" @@ -66,12 +81,31 @@ def __init__(self, options: Dict[str, Any]) -> None: self.enums: Dict[int, EnumSchema] = {} self.primitives: Dict[int, BaseSchema] = {} self.operation_groups: List[OperationGroup] = [] - self.global_parameters: ParameterList = ParameterList() self.custom_base_url: Optional[str] = None self.base_url: Optional[str] = None - self.service_client: Client = Client() + self.service_client: Client = Client(self, GlobalParameterList()) + self._rest: Optional[Rest] = None + self.request_builder_ids: Dict[int, RequestBuilder] = {} self._credential_schema_policy: Optional[CredentialSchemaPolicy] = None + @property + def global_parameters(self) -> GlobalParameterList: + return self.service_client.parameters + + @global_parameters.setter + def global_parameters(self, val: GlobalParameterList) -> None: + self.service_client.parameters = val + + @property + def rest(self) -> Rest: + if not self._rest: + raise ValueError("rest is None. Can not call it, you first have to set it.") + return self._rest + + @rest.setter + def rest(self, p: Rest) -> None: + self._rest = p + def lookup_schema(self, schema_id: int) -> BaseSchema: """Looks to see if the schema has already been created. @@ -141,27 +175,8 @@ def add_credential_global_parameter(self) -> None: ) self.global_parameters.insert(0, credential_parameter) - @staticmethod - def _lro_initial_function(operation: LROOperation) -> Operation: - return Operation( - yaml_data={}, - name="_" + operation.name + "_initial", - description="", - url=operation.url, - method=operation.method, - multipart=operation.multipart, - api_versions=operation.api_versions, - parameters=operation.parameters.parameters, - requests=operation.requests, - responses=operation.responses, - exceptions=operation.exceptions, - want_description_docstring=False, - want_tracing=False, - ) - def format_lro_operations(self) -> None: """Adds operations and attributes needed for LROs. - If there are LRO functions in here, will add initial LRO function. Will also set the return type of the LRO operation """ @@ -170,8 +185,7 @@ def format_lro_operations(self) -> None: while i < len(operation_group.operations): operation = operation_group.operations[i] if isinstance(operation, LROOperation): - operation.set_lro_response_type() - operation_group.operations.insert(i, CodeModel._lro_initial_function(operation)) + operation_group.operations.insert(i, operation.initial_operation) i += 1 i += 1 @@ -278,7 +292,7 @@ def add_inheritance_to_models(self) -> None: self._add_exceptions_from_inheritance() def _populate_target_property(self, parameter: Parameter) -> None: - for obj in self.sorted_schemas: + for obj in self.schemas.values(): for prop in obj.properties: if prop.id == parameter.target_property_name: parameter.target_property_name = prop.name @@ -318,31 +332,28 @@ def add_schema_link_to_operation(self) -> None: operation.responses, operation.exceptions, chain.from_iterable(response.headers for response in operation.responses), - chain.from_iterable(request.parameters for request in operation.requests) ): self._populate_schema(obj) + def add_schema_link_to_request_builder(self) -> None: + for request_builder in self.rest.request_builders: + for obj in chain( + request_builder.parameters, + chain.from_iterable(request.parameters for request in request_builder.schema_requests), + request_builder.responses, + ): + self._populate_schema(obj) + + def add_schema_link_to_global_parameters(self) -> None: for parameter in self.global_parameters: self._populate_schema(parameter) - def generate_single_parameter_from_multiple_media_types(self) -> None: + def generate_single_parameter_from_multiple_media_types_operation(self) -> None: for operation_group in self.operation_groups: for operation in operation_group.operations: if operation.multiple_media_type_parameters: - type_annot = ", ".join([ - param.schema.operation_type_annotation for param in operation.multiple_media_type_parameters - ]) - docstring_type = " or ".join([ - param.schema.docstring_type for param in operation.multiple_media_type_parameters - ]) - chosen_parameter = next( - iter(filter(lambda x: x.has_multiple_media_types, operation.parameters)), None - ) - if not chosen_parameter: - raise ValueError("You are missing a parameter that has multiple media types") - chosen_parameter.multiple_media_types_type_annot = f"Union[{type_annot}]" - chosen_parameter.multiple_media_types_docstring_type = docstring_type + operation.convert_multiple_media_type_parameters() @property def has_lro_operations(self) -> bool: @@ -357,3 +368,24 @@ def base_url_method_signature(async_mode: bool) -> str: if async_mode: return "base_url: Optional[str] = None," return "base_url=None, # type: Optional[str]" + + def _lookup_request_builder(self, schema_id: int) -> RequestBuilder: + """Looks to see if the schema has already been created. + + :param int schema_id: The yaml id of the schema + :return: If created, we return the created schema, otherwise, we throw. + :rtype: ~autorest.models.RequestBuilder + :raises: KeyError if schema is not found + """ + for elt_key, elt_value in self.request_builder_ids.items(): # type: ignore + if schema_id == elt_key: + return elt_value + raise KeyError("Didn't find it!!!!!") + + def link_operation_to_request_builder(self) -> None: + for operation_group in self.operation_groups: + for operation in operation_group.operations: + request_builder = self._lookup_request_builder(id(operation.yaml_data)) + if isinstance(operation, LROOperation): + request_builder.name = request_builder.name + "_initial" + operation.request_builder = request_builder diff --git a/autorest/codegen/models/constant_schema.py b/autorest/codegen/models/constant_schema.py index 65c0ffd91e3..529fe9493be 100644 --- a/autorest/codegen/models/constant_schema.py +++ b/autorest/codegen/models/constant_schema.py @@ -83,6 +83,12 @@ def from_yaml(cls, namespace: str, yaml_data: Dict[str, Any], **kwargs) -> "Cons value=yaml_data.get("value", {}).get("value", None), ) + def get_json_template_representation(self, **kwargs: Any) -> Any: + return self.schema.get_json_template_representation(**kwargs) + + def get_files_template_representation(self, **kwargs: Any) -> Any: + return self.schema.get_files_template_representation(**kwargs) + def imports(self) -> FileImport: file_import = FileImport() file_import.merge(self.schema.imports()) diff --git a/autorest/codegen/models/credential_schema.py b/autorest/codegen/models/credential_schema.py index ec348535a9b..5eaa6da2bd0 100644 --- a/autorest/codegen/models/credential_schema.py +++ b/autorest/codegen/models/credential_schema.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from typing import Any from .base_schema import BaseSchema from .imports import FileImport, ImportType, TypingSection @@ -24,6 +25,12 @@ def serialization_type(self) -> str: # abstract serialization_type in BaseSchema is not overridden pass + 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: + raise TypeError("You should not try to get a files template representation of a CredentialSchema") + class AzureKeyCredentialSchema(CredentialSchema): diff --git a/autorest/codegen/models/dictionary_schema.py b/autorest/codegen/models/dictionary_schema.py index 51bf8a7e994..904f194c133 100644 --- a/autorest/codegen/models/dictionary_schema.py +++ b/autorest/codegen/models/dictionary_schema.py @@ -7,7 +7,6 @@ from .base_schema import BaseSchema from .imports import FileImport, ImportType, TypingSection - class DictionarySchema(BaseSchema): """Schema for dictionaries that will be serialized. @@ -63,6 +62,16 @@ def docstring_type(self) -> str: def xml_serialization_ctxt(self) -> Optional[str]: raise NotImplementedError("Dictionary schema does not support XML serialization.") + def get_json_template_representation(self, **kwargs: Any) -> Any: + return { + "str": self.element_type.get_json_template_representation(**kwargs) + } + + def get_files_template_representation(self, **kwargs: Any) -> Any: + return { + "str": self.element_type.get_files_template_representation(**kwargs) + } + @classmethod def from_yaml(cls, namespace: str, yaml_data: Dict[str, Any], **kwargs: Any) -> "DictionarySchema": """Constructs a DictionarySchema from yaml data. diff --git a/autorest/codegen/models/enum_schema.py b/autorest/codegen/models/enum_schema.py index 055caf6f179..1e8f4c5bf14 100644 --- a/autorest/codegen/models/enum_schema.py +++ b/autorest/codegen/models/enum_schema.py @@ -131,6 +131,12 @@ def _get_enum_values(yaml_data: List[Dict[str, Any]]) -> List["EnumValue"]: seen_enums.add(enum_name) return values + def get_json_template_representation(self, **kwargs: Any) -> Any: + return self.enum_type.get_json_template_representation(**kwargs) + + def get_files_template_representation(self, **kwargs: Any) -> Any: + return self.enum_type.get_files_template_representation(**kwargs) + @classmethod def from_yaml(cls, namespace: str, yaml_data: Dict[str, Any], **kwargs: Any) -> "EnumSchema": """Constructs an EnumSchema from yaml data. diff --git a/autorest/codegen/models/list_schema.py b/autorest/codegen/models/list_schema.py index 97c589cd885..332e50275e5 100644 --- a/autorest/codegen/models/list_schema.py +++ b/autorest/codegen/models/list_schema.py @@ -61,6 +61,12 @@ def validation_map(self) -> Optional[Dict[str, Union[bool, int, str]]]: def has_xml_serialization_ctxt(self) -> bool: return super().has_xml_serialization_ctxt or self.element_type.has_xml_serialization_ctxt + 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 xml_serialization_ctxt(self) -> Optional[str]: attrs_list = [] base_xml_map = super().xml_serialization_ctxt() diff --git a/autorest/codegen/models/lro_operation.py b/autorest/codegen/models/lro_operation.py index 3d109f99225..0f84acc0bb3 100644 --- a/autorest/codegen/models/lro_operation.py +++ b/autorest/codegen/models/lro_operation.py @@ -4,12 +4,11 @@ # license information. # -------------------------------------------------------------------------- import logging -from typing import Dict, List, Any, Optional, Set, cast +from typing import Callable, Dict, List, Any, Optional, Set, cast from .imports import FileImport from .operation import Operation -from .parameter import Parameter +from .parameter_list import ParameterList from .schema_response import SchemaResponse -from .schema_request import SchemaRequest from .imports import ImportType, TypingSection from .base_schema import BaseSchema @@ -22,14 +21,10 @@ def __init__( yaml_data: Dict[str, Any], name: str, description: str, - url: str, - method: str, - multipart: bool, api_versions: Set[str], - requests: List[SchemaRequest], + parameters: ParameterList, + multiple_media_type_parameters: ParameterList, summary: Optional[str] = None, - parameters: Optional[List[Parameter]] = None, - multiple_media_type_parameters: Optional[List[Parameter]] = None, responses: Optional[List[SchemaResponse]] = None, exceptions: Optional[List[SchemaResponse]] = None, want_description_docstring: bool = True, @@ -39,25 +34,22 @@ def __init__( yaml_data, name, description, - url, - method, - multipart, api_versions, - requests, - summary, parameters, multiple_media_type_parameters, + summary, responses, exceptions, want_description_docstring, want_tracing, ) - self.lro_response: Optional[SchemaResponse] = None self.lro_options = yaml_data.get("extensions", {}).get("x-ms-long-running-operation-options", {}) + self.name = "begin_" + self.name - def set_lro_response_type(self) -> None: + @property + def lro_response(self) -> Optional[SchemaResponse]: if not self.responses: - return + return None responses_with_bodies = [r for r in self.responses if r.has_body] num_response_schemas = {r.schema for r in responses_with_bodies} response = None @@ -81,7 +73,28 @@ def set_lro_response_type(self) -> None: elif num_response_schemas: response = responses_with_bodies[0] - self.lro_response = response + return response + + @property + def schema_of_initial_operation(self) -> Callable: + return Operation + + @property + def initial_operation(self) -> Operation: + operation = self.schema_of_initial_operation( + yaml_data={}, + name=self.name[5:] + "_initial", + description="", + api_versions=self.api_versions, + parameters=self.parameters, + multiple_media_type_parameters=self.multiple_media_type_parameters, + summary=self.summary, + responses=self.responses, + want_description_docstring=False, + want_tracing=False, + ) + operation.request_builder = self.request_builder + return operation @property def has_optional_return_type(self) -> bool: @@ -120,6 +133,13 @@ def get_base_polling_method_path(self, async_mode: bool) -> str: def get_base_polling_method(self, async_mode: bool) -> str: return self.get_base_polling_method_path(async_mode).split(".")[-1] + def imports_for_multiapi(self, code_model, async_mode: bool) -> FileImport: + file_import = super().imports_for_multiapi(code_model, async_mode) + poller_import_path = ".".join(self.get_poller_path(async_mode).split(".")[:-1]) + poller = self.get_poller(async_mode) + file_import.add_from_import(poller_import_path, poller, ImportType.AZURECORE, TypingSection.CONDITIONAL) + return file_import + def imports(self, code_model, async_mode: bool) -> FileImport: file_import = super().imports(code_model, async_mode) file_import.add_from_import("typing", "Union", ImportType.STDLIB, TypingSection.CONDITIONAL) diff --git a/autorest/codegen/models/lro_paging_operation.py b/autorest/codegen/models/lro_paging_operation.py index 972d0b13e86..58086bc999b 100644 --- a/autorest/codegen/models/lro_paging_operation.py +++ b/autorest/codegen/models/lro_paging_operation.py @@ -3,52 +3,11 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Set, Optional +from .imports import FileImport from .lro_operation import LROOperation from .paging_operation import PagingOperation -from .imports import FileImport -from .schema_request import SchemaRequest -from .parameter import Parameter -from .schema_response import SchemaResponse class LROPagingOperation(PagingOperation, LROOperation): - def __init__( - self, - yaml_data: Dict[str, Any], - name: str, - description: str, - url: str, - method: str, - multipart: bool, - api_versions: Set[str], - requests: List[SchemaRequest], - summary: Optional[str] = None, - parameters: Optional[List[Parameter]] = None, - multiple_media_type_parameters: Optional[List[Parameter]] = None, - responses: Optional[List[SchemaResponse]] = None, - exceptions: Optional[List[SchemaResponse]] = None, - want_description_docstring: bool = True, - want_tracing: bool = True - ) -> None: - super(LROPagingOperation, self).__init__( - yaml_data, - name, - description, - url, - method, - multipart, - api_versions, - requests, - summary, - parameters, - multiple_media_type_parameters, - responses, - exceptions, - want_description_docstring, - want_tracing, - override_success_response_to_200=True - ) def imports(self, code_model, async_mode: bool) -> FileImport: lro_imports = LROOperation.imports(self, code_model, async_mode) @@ -57,3 +16,9 @@ def imports(self, code_model, async_mode: bool) -> FileImport: file_import = lro_imports file_import.merge(paging_imports) return file_import + + @property + def success_status_code(self): + """The list of all successfull status code. + """ + return [200] diff --git a/autorest/codegen/models/object_schema.py b/autorest/codegen/models/object_schema.py index 996c759e7b8..3259221f0df 100644 --- a/autorest/codegen/models/object_schema.py +++ b/autorest/codegen/models/object_schema.py @@ -33,6 +33,7 @@ def __init__( self.subtype_map: Optional[Dict[str, str]] = kwargs.pop("subtype_map", None) self.discriminator_name: Optional[str] = kwargs.pop("discriminator_name", None) self.discriminator_value: Optional[str] = kwargs.pop("discriminator_value", None) + self._created_json_template_representation = False @property def serialization_type(self) -> str: @@ -75,6 +76,42 @@ def xml_map_content(self) -> Optional[str]: # but we don't want to write a serialization context for an object. return super().xml_serialization_ctxt() + def get_json_template_representation(self, **kwargs: Any) -> Any: + if self._created_json_template_representation: + return "..." # do this to avoid loop + self._created_json_template_representation = True + representation = { + "{}".format( + prop.original_swagger_name + ): prop.get_json_template_representation(**kwargs) + for prop in [p for p in self.properties if not p.is_discriminator] + } + try: + # add discriminator prop if there is one + discriminator = next(p for p in self.properties if p.is_discriminator) + representation[ + discriminator.original_swagger_name + ] = self.discriminator_value or discriminator.original_swagger_name + except StopIteration: + pass + + # once we've finished, we want to reset created_json_template_representation to false + # so we can call it again + self._created_json_template_representation = False + return representation + + def get_files_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) + for prop in self.properties + } + + @classmethod def from_yaml(cls, namespace: str, yaml_data: Dict[str, Any], **kwargs) -> "ObjectSchema": """Returns a ClassType from the dict object constructed from a yaml file. @@ -163,6 +200,13 @@ def fill_instance_from_yaml(self, namespace: str, yaml_data: Dict[str, Any], **k def has_readonly_or_constant_property(self) -> bool: return any(x.readonly or x.constant for x in self.properties) + @property + def property_with_discriminator(self) -> Any: + try: + return next(p for p in self.properties if getattr(p.schema, "discriminator_name", None)) + except StopIteration: + return None + def imports(self) -> FileImport: file_import = FileImport() if self.is_exception: diff --git a/autorest/codegen/models/operation.py b/autorest/codegen/models/operation.py index 5d33665a368..c3b349caf5c 100644 --- a/autorest/codegen/models/operation.py +++ b/autorest/codegen/models/operation.py @@ -5,65 +5,21 @@ # -------------------------------------------------------------------------- from itertools import chain import logging -from typing import cast, Dict, List, Any, Optional, Union, Set, TypeVar +from typing import Callable, cast, Dict, List, Any, Optional, Union, Set -from .base_model import BaseModel +from .base_builder import BaseBuilder, get_converted_parameters from .imports import FileImport, ImportType, TypingSection from .schema_response import SchemaResponse from .parameter import Parameter from .parameter_list import ParameterList from .base_schema import BaseSchema -from .schema_request import SchemaRequest from .object_schema import ObjectSchema - +from .request_builder import RequestBuilder _LOGGER = logging.getLogger(__name__) -T = TypeVar('T') -OrderedSet = Dict[T, None] - -_M4_HEADER_PARAMETERS = ["content_type", "accept"] - -def _non_binary_schema_media_types(media_types: List[str]) -> OrderedSet[str]: - response_media_types: OrderedSet[str] = {} - - json_media_types = [media_type for media_type in media_types if "json" in media_type] - xml_media_types = [media_type for media_type in media_types if "xml" in media_type] - - if not sorted(json_media_types + xml_media_types) == sorted(media_types): - raise ValueError("The non-binary responses with schemas of {self.name} have incorrect json or xml mime types") - if json_media_types: - if "application/json" in json_media_types: - response_media_types["application/json"] = None - else: - response_media_types[json_media_types[0]] = None - if xml_media_types: - if "application/xml" in xml_media_types: - response_media_types["application/xml"] = None - else: - response_media_types[xml_media_types[0]] = None - return response_media_types - -def _remove_multiple_m4_header_parameters(parameters: List[Parameter]) -> List[Parameter]: - m4_header_params_in_schema = { - k: [p for p in parameters if p.serialized_name == k] - for k in _M4_HEADER_PARAMETERS - } - remaining_params = [p for p in parameters if p.serialized_name not in _M4_HEADER_PARAMETERS] - json_m4_header_params = { - k: [p for p in m4_header_params_in_schema[k] if p.yaml_data["schema"]["type"] == "constant"] - for k in m4_header_params_in_schema - } - for k, v in json_m4_header_params.items(): - if v: - remaining_params.append(v[0]) - else: - remaining_params.append(m4_header_params_in_schema[k][0]) - - return remaining_params - -class Operation(BaseModel): # pylint: disable=too-many-public-methods, too-many-instance-attributes - """Represent an operation. +class Operation(BaseBuilder): # pylint: disable=too-many-public-methods, too-many-instance-attributes + """Represent an self. """ def __init__( @@ -71,49 +27,76 @@ def __init__( yaml_data: Dict[str, Any], name: str, description: str, - url: str, - method: str, - multipart: bool, api_versions: Set[str], - requests: List[SchemaRequest], + parameters: ParameterList, + multiple_media_type_parameters: ParameterList, summary: Optional[str] = None, - parameters: Optional[List[Parameter]] = None, - multiple_media_type_parameters: Optional[List[Parameter]] = None, responses: Optional[List[SchemaResponse]] = None, exceptions: Optional[List[SchemaResponse]] = None, want_description_docstring: bool = True, - want_tracing: bool = True + want_tracing: bool = True, ) -> None: - super().__init__(yaml_data) - self.name = name - self.description = description - self.url = url - self.method = method - self.multipart = multipart + super().__init__( + yaml_data=yaml_data, + name=name, + description=description, + parameters=parameters, + responses=responses, + summary=summary, + ) + self.multiple_media_type_parameters = multiple_media_type_parameters self.api_versions = api_versions - self.requests = requests - self.summary = summary - self.parameters = ParameterList(parameters) self.multiple_media_type_parameters = multiple_media_type_parameters - self.responses = responses or [] self.exceptions = exceptions or [] self.want_description_docstring = want_description_docstring self.want_tracing = want_tracing + self._request_builder: Optional[RequestBuilder] = None + self.deprecated = False @property def python_name(self) -> str: return self.name @property - def is_stream_request(self) -> bool: - """Is the request is a stream, like an upload.""" - return any(request.is_stream_request for request in self.requests) + def request_builder(self) -> RequestBuilder: + if not self._request_builder: + raise ValueError( + "You're calling request_builder when you haven't linked up operation to its " + "request builder through the code model" + ) + return self._request_builder + + @request_builder.setter + def request_builder(self, r: RequestBuilder) -> None: + self._request_builder = r @property def is_stream_response(self) -> bool: """Is the response expected to be streamable, like a download.""" return any(response.is_stream_response for response in self.responses) + @property + def body_kwargs_to_pass_to_request_builder(self) -> List[str]: + kwargs = [] + if self.request_builder.multipart: + kwargs.append("files") + if self.parameters.has_partial_body: + kwargs.append("data") + if any([ct for ct in self.parameters.content_types if "json" in ct]): + kwargs.append("json") + if self.request_builder.is_stream or not kwargs: + kwargs.append("content") + return kwargs + + @property + def serialized_body_kwarg(self) -> str: + # body serialization can be passed to either "json" or "content" + if "json" in self.body_kwargs_to_pass_to_request_builder: + return "json" + if not self.request_builder.is_stream: + return "content" + raise ValueError("You should not be trying to serialize this body") + @property def has_optional_return_type(self) -> bool: """Has optional return type if there are multiple successful response types where some have @@ -148,22 +131,10 @@ def has_response_body(self) -> bool: """ return any(response.has_body or response.is_stream_response for response in self.responses) - def get_response_from_status(self, status_code: int) -> SchemaResponse: - for response in self.responses: - if status_code in response.status_codes: - return response - raise ValueError(f"Incorrect status code {status_code}, operation {self.name}") - @property def any_response_has_headers(self) -> bool: return any(response.has_headers for response in self.responses) - @property - def success_status_code(self) -> List[Union[str, int]]: - """The list of all successfull status code. - """ - return [code for response in self.responses for code in response.status_codes if code != "default"] - @property def default_exception(self) -> Optional[str]: default_excp = [excp for excp in self.exceptions for code in excp.status_codes if code == "default"] @@ -175,7 +146,6 @@ def default_exception(self) -> Optional[str]: # in this case, it's just an AnySchema return "\'object\'" - @property def status_code_exceptions(self) -> List[SchemaResponse]: return [excp for excp in self.exceptions if list(excp.status_codes) != ["default"]] @@ -187,20 +157,14 @@ def status_code_exceptions_status_codes(self) -> List[Union[str, int]]: excp.status_codes for excp in self.status_code_exceptions ])) - def imports(self, code_model, async_mode: bool) -> FileImport: + def _imports_shared(self) -> FileImport: file_import = FileImport() + file_import.add_from_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) + for param in self.parameters.method: + file_import.merge(param.imports()) - # Exceptions - file_import.add_from_import("azure.core.exceptions", "map_error", ImportType.AZURECORE) - if code_model.options["azure_arm"]: - file_import.add_from_import("azure.mgmt.core.exceptions", "ARMErrorFormat", ImportType.AZURECORE) - file_import.add_from_import("azure.core.exceptions", "HttpResponseError", ImportType.AZURECORE) - for parameter in self.parameters: - file_import.merge(parameter.imports()) - - if self.multiple_media_type_parameters: - for parameter in self.multiple_media_type_parameters: - file_import.merge(parameter.imports()) + for param in self.multiple_media_type_parameters: + file_import.merge(param.imports()) for response in [r for r in self.responses if r.has_body]: file_import.merge(cast(BaseSchema, response.schema).imports()) @@ -208,14 +172,32 @@ def imports(self, code_model, async_mode: bool) -> FileImport: if len([r for r in self.responses if r.has_body]) > 1: file_import.add_from_import("typing", "Union", ImportType.STDLIB, TypingSection.CONDITIONAL) + if self.is_stream_response: + file_import.add_from_import("typing", "IO", ImportType.STDLIB, TypingSection.CONDITIONAL) + return file_import + + + def imports_for_multiapi(self, code_model, async_mode: bool) -> FileImport: # pylint: disable=unused-argument + return self._imports_shared() + + def imports(self, code_model, async_mode: bool) -> FileImport: + file_import = self._imports_shared() + + # Exceptions + file_import.add_from_import("azure.core.exceptions", "map_error", ImportType.AZURECORE) + if code_model.options["azure_arm"]: + file_import.add_from_import("azure.mgmt.core.exceptions", "ARMErrorFormat", ImportType.AZURECORE) + file_import.add_from_import("azure.core.exceptions", "HttpResponseError", ImportType.AZURECORE) + + + file_import.add_import("functools", ImportType.STDLIB) file_import.add_from_import("typing", "Callable", ImportType.STDLIB, TypingSection.CONDITIONAL) file_import.add_from_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL) file_import.add_from_import("typing", "Dict", ImportType.STDLIB, TypingSection.CONDITIONAL) - file_import.add_from_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) file_import.add_from_import("typing", "TypeVar", ImportType.STDLIB, TypingSection.CONDITIONAL) file_import.add_from_import("typing", "Generic", ImportType.STDLIB, TypingSection.CONDITIONAL) file_import.add_from_import("azure.core.pipeline", "PipelineResponse", ImportType.AZURECORE) - file_import.add_from_import("azure.core.pipeline.transport", "HttpRequest", ImportType.AZURECORE) + file_import.add_from_import("azure.core.rest", "HttpRequest", ImportType.AZURECORE) if async_mode: file_import.add_from_import("azure.core.pipeline.transport", "AsyncHttpResponse", ImportType.AZURECORE) else: @@ -226,79 +208,67 @@ def imports(self, code_model, async_mode: bool) -> FileImport: if True: # pylint: disable=using-constant-test file_import.add_import("warnings", ImportType.STDLIB) + operation_group_name = self.request_builder.operation_group_name + rest_import_path = "..." if async_mode else ".." + if operation_group_name: + file_import.add_from_import( + f"{rest_import_path}{code_model.rest_layer_name}", + name_import=operation_group_name, + import_type=ImportType.LOCAL, + alias=f"rest_{operation_group_name}" + ) + else: + file_import.add_from_import( + rest_import_path, + code_model.rest_layer_name, + import_type=ImportType.LOCAL, + alias="rest" + ) return file_import + def convert_multiple_media_type_parameters(self) -> None: + type_annot = ", ".join([ + param.schema.operation_type_annotation + for param in self.multiple_media_type_parameters + ]) + docstring_type = " or ".join([ + param.schema.docstring_type for param in self.multiple_media_type_parameters + ]) + try: + # get an optional param with object first. These params are the top choice + # bc they have more info about how to serialize the body + chosen_parameter = next( + p for p in self.multiple_media_type_parameters if not p.required and isinstance(p.schema, ObjectSchema) + ) + except StopIteration: # pylint: disable=broad-except + # otherwise, we get the first optional param, if that exists. If not, we just grab the first one + optional_parameters = [p for p in self.multiple_media_type_parameters if not p.required] + chosen_parameter = optional_parameters[0] if optional_parameters else self.multiple_media_type_parameters[0] + if not chosen_parameter: + raise ValueError("You are missing a parameter that has multiple media types") + chosen_parameter.multiple_media_types_type_annot = f"Union[{type_annot}]" + chosen_parameter.multiple_media_types_docstring_type = docstring_type + self.parameters.append(chosen_parameter) + + @staticmethod + def get_parameter_converter() -> Callable: + return Parameter.from_yaml + @classmethod def from_yaml(cls, yaml_data: Dict[str, Any]) -> "Operation": name = yaml_data["language"]["python"]["name"] _LOGGER.debug("Parsing %s operation", name) - first_request = yaml_data["requests"][0] - - multiple_requests = len(yaml_data["requests"]) > 1 - - multiple_media_type_parameters: List[Parameter] = [] - parameters = [Parameter.from_yaml(yaml) for yaml in yaml_data.get("parameters", [])] - - for request in yaml_data["requests"]: - for yaml in request.get("parameters", []): - parameter = Parameter.from_yaml(yaml) - if yaml["language"]["python"]["name"] in _M4_HEADER_PARAMETERS: - parameter.is_kwarg = True - parameters.append(parameter) - elif multiple_requests: - multiple_media_type_parameters.append(parameter) - else: - parameters.append(parameter) - - if multiple_requests: - parameters = _remove_multiple_m4_header_parameters(parameters) - chosen_parameter = multiple_media_type_parameters[0] - - # binary body parameters are required, while object - # ones are not. We default to optional in this case. - optional_parameters = [p for p in multiple_media_type_parameters if not p.required] - if optional_parameters: - chosen_parameter = optional_parameters[0] - else: - chosen_parameter = multiple_media_type_parameters[0] - chosen_parameter.has_multiple_media_types = True - parameters.append(chosen_parameter) - - if multiple_media_type_parameters: - body_parameters_name_set = set( - p.serialized_name for p in multiple_media_type_parameters - ) - if len(body_parameters_name_set) > 1: - raise ValueError( - f"The body parameter with multiple media types has different names: {body_parameters_name_set}" - ) - - - parameters_index = {id(parameter.yaml_data): parameter for parameter in parameters} - - # Need to connect the groupBy and originalParameter - for parameter in parameters: - parameter_grouped_by_id = id(parameter.grouped_by) - if parameter_grouped_by_id in parameters_index: - parameter.grouped_by = parameters_index[parameter_grouped_by_id] - - parameter_original_id = id(parameter.original_parameter) - if parameter_original_id in parameters_index: - parameter.original_parameter = parameters_index[parameter_original_id] + parameters, multiple_media_type_parameters = get_converted_parameters(yaml_data, cls.get_parameter_converter()) return cls( yaml_data=yaml_data, name=name, description=yaml_data["language"]["python"]["description"], - url=first_request["protocol"]["http"]["path"], - method=first_request["protocol"]["http"]["method"], - multipart=first_request["protocol"]["http"].get("multipart", False), api_versions=set(value_dict["version"] for value_dict in yaml_data["apiVersions"]), - requests=[SchemaRequest.from_yaml(yaml) for yaml in yaml_data["requests"]], + parameters=ParameterList(parameters), + multiple_media_type_parameters=ParameterList(multiple_media_type_parameters), summary=yaml_data["language"]["python"].get("summary"), - parameters=parameters, - multiple_media_type_parameters=multiple_media_type_parameters, responses=[SchemaResponse.from_yaml(yaml) for yaml in yaml_data.get("responses", [])], # Exception with no schema means default exception, we don't store them exceptions=[SchemaResponse.from_yaml(yaml) for yaml in yaml_data.get("exceptions", []) if "schema" in yaml], diff --git a/autorest/codegen/models/operation_group.py b/autorest/codegen/models/operation_group.py index 9658090321d..6b0b87d4195 100644 --- a/autorest/codegen/models/operation_group.py +++ b/autorest/codegen/models/operation_group.py @@ -37,6 +37,12 @@ def __init__( self.operations = operations self.api_versions = api_versions + def imports_for_multiapi(self, async_mode: bool) -> FileImport: + file_import = FileImport() + for operation in self.operations: + file_import.merge(operation.imports_for_multiapi(self.code_model, async_mode)) + return file_import + def imports(self, async_mode: bool, has_schemas: bool) -> FileImport: file_import = FileImport() file_import.add_from_import("azure.core.exceptions", "ClientAuthenticationError", ImportType.AZURECORE) @@ -53,13 +59,14 @@ def imports(self, async_mode: bool, has_schemas: bool) -> FileImport: file_import.add_from_import( "azure.core.tracing.decorator", "distributed_trace", ImportType.AZURECORE, ) + local_path = "..." if async_mode else ".." if has_schemas: - if async_mode: - file_import.add_from_import("...", "models", ImportType.LOCAL, alias="_models") - else: - file_import.add_from_import("..", "models", ImportType.LOCAL, alias="_models") + file_import.add_from_import(local_path, "models", ImportType.LOCAL, alias="_models") + + # import request builders return file_import + @property def filename(self) -> str: basename = self.name diff --git a/autorest/codegen/models/paging_operation.py b/autorest/codegen/models/paging_operation.py index eacdef9af5e..6fc9fabffac 100644 --- a/autorest/codegen/models/paging_operation.py +++ b/autorest/codegen/models/paging_operation.py @@ -4,14 +4,14 @@ # license information. # -------------------------------------------------------------------------- import logging -from typing import cast, Dict, List, Any, Optional, Set, Union +from typing import cast, Dict, List, Any, Optional, Set from .operation import Operation -from .parameter import Parameter from .schema_response import SchemaResponse -from .schema_request import SchemaRequest +from .request_builder import RequestBuilder from .imports import ImportType, FileImport, TypingSection from .object_schema import ObjectSchema +from .parameter_list import ParameterList _LOGGER = logging.getLogger(__name__) @@ -22,14 +22,10 @@ def __init__( yaml_data: Dict[str, Any], name: str, description: str, - url: str, - method: str, - multipart: bool, api_versions: Set[str], - requests: List[SchemaRequest], + parameters: ParameterList, + multiple_media_type_parameters: ParameterList, summary: Optional[str] = None, - parameters: Optional[List[Parameter]] = None, - multiple_media_type_parameters: Optional[List[Parameter]] = None, responses: Optional[List[SchemaResponse]] = None, exceptions: Optional[List[SchemaResponse]] = None, want_description_docstring: bool = True, @@ -41,14 +37,10 @@ def __init__( yaml_data, name, description, - url, - method, - multipart, api_versions, - requests, - summary, parameters, multiple_media_type_parameters, + summary, responses, exceptions, want_description_docstring, @@ -118,12 +110,23 @@ def get_pager(self, async_mode: bool) -> str: return self.get_pager_path(async_mode).split(".")[-1] @property - def success_status_code(self) -> List[Union[str, int]]: - """The list of all successfull status code. - """ - if self.override_success_response_to_200: - return [200] - return super(PagingOperation, self).success_status_code + def next_request_builder(self) -> Optional[RequestBuilder]: + if not self.next_operation: + return None + next_request_builder = self.next_operation.request_builder + return next_request_builder + + def imports_for_multiapi(self, code_model, async_mode: bool) -> FileImport: + file_import = super().imports_for_multiapi(code_model, async_mode) + pager_import_path = ".".join(self.get_pager_path(async_mode).split(".")[:-1]) + pager = self.get_pager(async_mode) + + file_import.add_from_import(pager_import_path, pager, ImportType.AZURECORE, TypingSection.CONDITIONAL) + if async_mode: + file_import.add_from_import("typing", "AsyncIterable", ImportType.STDLIB, TypingSection.CONDITIONAL) + else: + file_import.add_from_import("typing", "Iterable", ImportType.STDLIB, TypingSection.CONDITIONAL) + return file_import def imports(self, code_model, async_mode: bool) -> FileImport: file_import = super(PagingOperation, self).imports(code_model, async_mode) diff --git a/autorest/codegen/models/parameter.py b/autorest/codegen/models/parameter.py index b6ce8a87f12..5bcae1b9792 100644 --- a/autorest/codegen/models/parameter.py +++ b/autorest/codegen/models/parameter.py @@ -3,8 +3,9 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from enum import Enum import logging +from enum import Enum + from typing import Dict, Optional, List, Any, Union, Tuple, cast from .imports import FileImport, ImportType, TypingSection @@ -18,6 +19,8 @@ _LOGGER = logging.getLogger(__name__) +_HIDDEN_KWARGS = ["content_type"] + class ParameterLocation(Enum): Path = "path" @@ -43,7 +46,7 @@ class ParameterStyle(Enum): multipart = "multipart" -class Parameter(BaseModel): # pylint: disable=too-many-instance-attributes +class Parameter(BaseModel): # pylint: disable=too-many-instance-attributes, too-many-public-methods def __init__( self, yaml_data: Dict[str, Any], @@ -81,11 +84,18 @@ def __init__( self.flattened = flattened self.grouped_by = grouped_by self.original_parameter = original_parameter - self._client_default_value = client_default_value - self.is_kwarg: bool = self.rest_api_name == "Content-Type" and self.constant + self.client_default_value = client_default_value 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) + + def __hash__(self) -> int: + return hash(self.serialized_name) + + @staticmethod + def serialize_line(function_name: str, parameters_line: str): + return f'self._serialize.{function_name}({parameters_line})' def build_serialize_data_call(self, function_name: str) -> str: @@ -128,7 +138,7 @@ def build_serialize_data_call(self, function_name: str) -> str: ] parameters_line = ', '.join(parameters) - serialize_line = f'self._serialize.{function_name}({parameters_line})' + serialize_line = self.serialize_line(function_name, parameters_line) if self.explode: return f"[{serialize_line} if q is not None else '' for q in {origin_name}]" @@ -144,6 +154,10 @@ 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: @@ -158,6 +172,10 @@ def constant_declaration(self) -> str: def xml_serialization_ctxt(self) -> str: return self.schema.xml_serialization_ctxt() or "" + @property + def is_body(self) -> bool: + return self.location == ParameterLocation.Body + @property def in_method_signature(self) -> bool: return not( @@ -168,9 +186,7 @@ def in_method_signature(self) -> bool: # If I'm grouped, my grouper will be on signature, not me or self.grouped_by # If I'm body and it's flattened, I'm not either - or (self.location == ParameterLocation.Body and self.flattened) - # If I'm a kwarg, don't include in the signature - or self.is_kwarg + or (self.is_body and self.flattened) ) @property @@ -187,7 +203,11 @@ def corresponding_grouped_property(self) -> Property: @property def in_method_code(self) -> bool: - return not (self.constant and self.location == ParameterLocation.Other) + return not ( + self.constant and + self.location == ParameterLocation.Other or + self.rest_api_name == '$host' + ) @property def implementation(self) -> str: @@ -198,11 +218,11 @@ def implementation(self) -> str: def _default_value(self) -> Tuple[Optional[Any], str, str]: type_annot = self.multiple_media_types_type_annot or self.schema.operation_type_annotation - if not self.required: + if not self.required and not type_annot == "Any": type_annot = f"Optional[{type_annot}]" - if self._client_default_value is not None: - return self._client_default_value, self.schema.get_declaration(self._client_default_value), type_annot + if self.client_default_value is not None: + return self.client_default_value, self.schema.get_declaration(self.client_default_value), type_annot if self.multiple_media_types_type_annot: # means this parameter has multiple media types. We force default value to be None. @@ -223,12 +243,28 @@ def _default_value(self) -> Tuple[Optional[Any], str, str]: return default_value, default_value_declaration, type_annot + @property + def description_keyword(self) -> str: + return "keyword" if self.is_kwarg or self.is_keyword_only else "param" + + @property + def docstring_type_keyword(self) -> str: + return "paramtype" if self.is_kwarg or self.is_keyword_only else "type" + @property def default_value(self) -> Optional[Any]: # exposing default_value because client_default_value doesn't get updated with # default values we bubble up from the schema return self._default_value()[0] + @property + def default_value_declaration(self) -> Optional[Any]: + return self._default_value()[1] + + @property + def type_annotation(self) -> str: + return self._default_value()[2] + @property def serialization_type(self) -> str: return self.schema.serialization_type @@ -237,15 +273,18 @@ def serialization_type(self) -> str: def docstring_type(self) -> str: return self.multiple_media_types_docstring_type or self.schema.docstring_type + @property + def has_default_value(self): + return self.default_value is not None or not self.required + def method_signature(self, async_mode: bool) -> str: - default_value, default_value_declaration, type_annot = self._default_value() - if default_value is not None or not self.required: - if async_mode: - return f"{self.serialized_name}: {type_annot} = {default_value_declaration}," - return f"{self.serialized_name}={default_value_declaration}, # type: {type_annot}" if async_mode: - return f"{self.serialized_name}: {type_annot}," - return f"{self.serialized_name}, # type: {type_annot}" + if self.has_default_value: + return f"{self.serialized_name}: {self.type_annotation} = {self.default_value_declaration}," + return f"{self.serialized_name}: {self.type_annotation}," + if self.has_default_value: + return f"{self.serialized_name}={self.default_value_declaration}, # type: {self.type_annotation}" + return f"{self.serialized_name}, # type: {self.type_annotation}" @property def full_serialized_name(self) -> str: @@ -254,6 +293,24 @@ def full_serialized_name(self) -> str: origin_name = f"self._config.{self.serialized_name}" return origin_name + @property + def is_kwarg(self) -> bool: + # this means "am I in **kwargs?" + return self.serialized_name == "content_type" + + @property + def is_keyword_only(self) -> bool: + # this means in async mode, I am documented like def hello(positional_1, *, me!) + return False + + @property + def is_documented(self) -> bool: + return self.serialized_name not in _HIDDEN_KWARGS + + @property + def is_positional(self) -> bool: + return self.in_method_signature and not (self.is_keyword_only or self.is_kwarg) + @classmethod def from_yaml(cls, yaml_data: Dict[str, Any]) -> "Parameter": http_protocol = yaml_data["protocol"].get("http", {"in": ParameterLocation.Other}) @@ -287,3 +344,9 @@ def imports(self) -> FileImport: if self.has_multiple_media_types: file_import.add_from_import("typing", "Union", ImportType.STDLIB, TypingSection.CONDITIONAL) return file_import + +class ParameterOnlyPathsPositional(Parameter): + + @property + def is_keyword_only(self) -> bool: + return not (self.location == ParameterLocation.Path or self.location == ParameterLocation.Body) diff --git a/autorest/codegen/models/parameter_list.py b/autorest/codegen/models/parameter_list.py index 53692fddeec..56a7e87f2a4 100644 --- a/autorest/codegen/models/parameter_list.py +++ b/autorest/codegen/models/parameter_list.py @@ -5,22 +5,27 @@ # -------------------------------------------------------------------------- from collections.abc import MutableSequence import logging -from typing import cast, List, Callable, Optional +from typing import cast, List, Callable, Optional, TypeVar, Dict from .parameter import Parameter, ParameterLocation from .object_schema import ObjectSchema from .constant_schema import ConstantSchema +from .base_schema import BaseSchema +from .enum_schema import EnumSchema +T = TypeVar('T') +OrderedSet = Dict[T, None] _LOGGER = logging.getLogger(__name__) -class ParameterList(MutableSequence): +class ParameterList(MutableSequence): # pylint: disable=too-many-public-methods def __init__( - self, parameters: Optional[List[Parameter]] = None, implementation: str = "Method" + self, parameters: Optional[List[Parameter]] = None ) -> None: self.parameters = parameters or [] - self.implementation = implementation + self._json_body: Optional[BaseSchema] = None + self._content_types: Optional[List[str]] = None # MutableSequence @@ -52,6 +57,12 @@ def get_from_predicate(self, predicate: Callable[[Parameter], bool]) -> List[Par def get_from_location(self, location: ParameterLocation) -> List[Parameter]: return self.get_from_predicate(lambda parameter: parameter.location == location) + @property + def json_body(self) -> BaseSchema: + if not self._json_body: + self._json_body = self.body[0].schema + return self._json_body + @property def has_body(self) -> bool: return self.has_any_location(ParameterLocation.Body) @@ -61,15 +72,26 @@ def body(self) -> List[Parameter]: if not self.has_body: raise ValueError(f"Can't get body parameter") # Should we check if there is two body? Modeler role right? - return self.get_from_location(ParameterLocation.Body) + body_params = self.get_from_location(ParameterLocation.Body) + return body_params + + @staticmethod + def _wanted_path_parameter(parameter: Parameter): + # TODO add 'and parameter.location == "Method"' as requirement to this check once + # I can use send_request on operations. + # Don't want to duplicate code from send_request. + return parameter.location == ParameterLocation.Uri and parameter.rest_api_name != "$host" + + @property + def implementation(self) -> str: + return "Method" @property def path(self) -> List[Parameter]: return [ parameter for parameter in self.parameters - if parameter.location in [ParameterLocation.Uri, ParameterLocation.Path] - and parameter.rest_api_name != "$host" + if self._wanted_path_parameter(parameter) ] @property @@ -78,12 +100,29 @@ def query(self) -> List[Parameter]: @property def headers(self) -> List[Parameter]: - return self.get_from_location(ParameterLocation.Header) + headers = self.get_from_location(ParameterLocation.Header) + if not headers: + return headers + return list({ + header.serialized_name: header + for header in headers + }.values()) @property def grouped(self) -> List[Parameter]: return self.get_from_predicate(lambda parameter: cast(bool, parameter.grouped_by)) + @property + def groupers(self) -> List[Parameter]: + groupers: List[Parameter] = [] + for parameter in self.parameters: + if any([ + p for p in self.grouped + if p.grouped_by and id(p.grouped_by.yaml_data) == id(parameter.yaml_data) + ]): + groupers.append(parameter) + return groupers + @property def constant(self) -> List[Parameter]: """Return the constants of this parameter list. @@ -97,23 +136,59 @@ def constant(self) -> List[Parameter]: ) @property - def content_type_parameter(self) -> Parameter: - try: - content_type_param = next(iter( - [ - p for p in self.parameters - if p.rest_api_name == "Content-Type" - ] - )) - return content_type_param - except StopIteration: - raise ValueError("You are looking for a Content-Type parameter, but there is none for this operation.") + def constant_bodies(self) -> List[Parameter]: + constants = self.constant + if not constants: + return [] + return [c for c in constants if c.location == ParameterLocation.Body] @property - def content_type(self) -> str: - if isinstance(self.content_type_parameter.schema, ConstantSchema): - return self.content_type_parameter.schema.get_declaration(self.content_type_parameter.schema.value) - return self.content_type_parameter.schema.default_value_declaration + def has_multipart(self) -> bool: + return any(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)) + + @property + def content_types(self) -> List[str]: + if self._content_types is not None: + return self._content_types + content_type_params = self.get_from_predicate( + lambda parameter: parameter.serialized_name == "content_type" + ) + content_types: OrderedSet[str] = {} + for param in content_type_params: + if isinstance(param.schema, dict): + if param.schema.get("value"): + content_types[param.schema["value"]["value"]] = None + if param.schema.get("choices"): + for choice in param.schema['choices']: + content_types[choice['value']] = None + elif isinstance(param.schema, ConstantSchema) and param.schema.value: + content_types[param.schema.value] = None + elif isinstance(param.schema, EnumSchema): + # enums + content_types.update({v.value: None for v in param.schema.values}) + if param.client_default_value: + content_types.update({param.client_default_value: None}) + self._content_types = [k for k in content_types if k is not None] + return self._content_types + + @property + def default_content_type(self) -> str: + json_content_types = [c for c in self.content_types if "json" in c] + if json_content_types: + if "application/json" in json_content_types: + return "application/json" + return json_content_types[0] + + xml_content_types = [c for c in self.content_types if "xml" in c] + if xml_content_types: + if "application/xml" in xml_content_types: + return "application/xml" + return xml_content_types[0] + return self.content_types[0] @property def method(self) -> List[Parameter]: @@ -127,6 +202,9 @@ def method(self) -> List[Parameter]: lambda parameter: parameter.implementation == self.implementation ) for parameter in parameters_of_this_implementation: + # we don't want content_type in operation level + if parameter.serialized_name == "content_type": + continue if parameter.in_method_signature: if not parameter.default_value and parameter.required: signature_parameters_no_default_value.append(parameter) @@ -137,7 +215,66 @@ def method(self) -> List[Parameter]: return signature_parameters def method_signature(self, async_mode: bool) -> List[str]: - return [parameter.method_signature(async_mode) for parameter in self.method] + positional = self.method_signature_positional(async_mode) + if async_mode: + positional += self.method_signature_keyword_only(async_mode) + kwargs = self.method_signature_kwargs(async_mode) + return positional + kwargs + + def method_signature_positional(self, async_mode: bool) -> List[str]: + return [parameter.method_signature(async_mode) for parameter in self.positional] + + def method_signature_keyword_only(self, async_mode: bool) -> List[str]: + if not self.keyword_only: + return [] + return ["*,"] + [parameter.method_signature(async_mode) for parameter in self.keyword_only] + + @staticmethod + def method_signature_kwargs(async_mode: bool) -> List[str]: + return ["**kwargs: Any"] if async_mode else ["**kwargs # type: Any"] + + @property + def positional(self) -> List[Parameter]: + return [p for p in self.method if p.is_positional] + + @property + def keyword_only(self) -> List[Parameter]: + return [p for p in self.method if p.is_keyword_only] + + @property + def kwargs(self) -> List[Parameter]: + return [p for p in self.method if p.is_kwarg] + + def kwargs_to_pop(self, async_mode: bool) -> List[Parameter]: + seen_kwargs = set() + # we want to default to constant schemas for the kwargs if there are multiple + # case example: when looking at multiple content type params, we want the one with the constant schema + # so we can default to that value when popping + kwargs = [p for p in self.parameters if p.is_kwarg] + retval = [] + def _iterate_kwargs(kwargs_to_iterate): + for kwarg in kwargs_to_iterate: + if kwarg.rest_api_name in seen_kwargs: + continue + seen_kwargs.add(kwarg.rest_api_name) + retval.append(kwarg) + _iterate_kwargs([k for k in kwargs if isinstance(k.schema, ConstantSchema)]) + _iterate_kwargs([k for k in kwargs if not isinstance(k.schema, ConstantSchema)]) + if not async_mode: + _iterate_kwargs([k for k in self.method if k.is_kwarg]) + return retval + + @property + def call(self) -> List[str]: + retval = [ + p.serialized_name for p in self.positional + ] + retval.extend([ + f"{p.serialized_name}={p.serialized_name}" + for p in self.keyword_only + ]) + retval.append("**kwargs") + return retval @property def is_flattened(self) -> bool: @@ -157,3 +294,17 @@ def build_flattened_object(self) -> str: ) object_schema = cast(ObjectSchema, self.body[0].schema) return f"{self.body[0].serialized_name} = _models.{object_schema.name}({parameter_string})" + +class GlobalParameterList(ParameterList): + + @property + def implementation(self) -> str: + return "Client" + + @staticmethod + def _wanted_path_parameter(parameter: Parameter) -> bool: + return ( + parameter.location == ParameterLocation.Uri and + parameter.implementation == "Client" and + parameter.rest_api_name != "$host" + ) diff --git a/autorest/codegen/models/primitive_schemas.py b/autorest/codegen/models/primitive_schemas.py index 435c9cf3206..629b0eef27e 100644 --- a/autorest/codegen/models/primitive_schemas.py +++ b/autorest/codegen/models/primitive_schemas.py @@ -21,6 +21,21 @@ def __init__(self, string: str) -> None: def __repr__(self) -> str: return "r'{}'".format(self.string.replace('\'', '\\\'')) +def _add_optional_and_default_value_template_representation( + representation: str, # pylint: disable=unused-argument + *, + optional: bool = True, + default_value_declaration: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any +): + if optional: + representation += " (optional)" + if default_value_declaration and default_value_declaration != "None": # not doing None bc that's assumed + representation += f". Default value is {default_value_declaration}" + if description: + representation += f". {description}" + return representation class PrimitiveSchema(BaseSchema): _TYPE_MAPPINGS = { @@ -46,6 +61,20 @@ def type_annotation(self) -> str: def docstring_text(self) -> str: return self.docstring_type + def get_json_template_representation(self, **kwargs: Any) -> Any: + return _add_optional_and_default_value_template_representation( + representation=self.docstring_text, + **kwargs + ) + + def get_files_template_representation(self, **kwargs: Any) -> Any: + """Template of what the files input should look like + """ + return _add_optional_and_default_value_template_representation( + representation=self.docstring_text, + **kwargs + ) + class IOSchema(PrimitiveSchema): def __init__(self, namespace, yaml_data) -> None: @@ -73,6 +102,8 @@ def imports(self) -> FileImport: file_import.add_from_import("typing", "IO", ImportType.STDLIB, TypingSection.CONDITIONAL) return file_import + def get_json_template_representation(self, **kwargs: Any) -> Any: + raise TypeError("No JSON representation of IOSchema") class AnySchema(PrimitiveSchema): @property @@ -92,7 +123,6 @@ def imports(self) -> FileImport: file_import.add_from_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) return file_import - class NumberSchema(PrimitiveSchema): def __init__(self, namespace: str, yaml_data: Dict[str, Any]) -> None: super(NumberSchema, self).__init__(namespace=namespace, yaml_data=yaml_data) @@ -154,7 +184,6 @@ def type_annotation(self) -> str: return "int" return python_type - class StringSchema(PrimitiveSchema): def __init__(self, namespace: str, yaml_data: Dict[str, Any]) -> None: diff --git a/autorest/codegen/models/property.py b/autorest/codegen/models/property.py index 43c616fad78..21e09d2598c 100644 --- a/autorest/codegen/models/property.py +++ b/autorest/codegen/models/property.py @@ -125,6 +125,15 @@ def type_annotation(self) -> str: return self.schema.type_annotation return f"Optional[{self.schema.type_annotation}]" + def get_json_template_representation(self, **kwargs: Any) -> Any: + kwargs["optional"] = not self.required + kwargs["default_value_declaration"] = self.default_value_declaration + return self.schema.get_json_template_representation(**kwargs) + + def get_files_template_representation(self, **kwargs: Any) -> Any: + kwargs["optional"] = not self.required + return self.schema.get_files_template_representation(**kwargs) + def model_file_imports(self) -> FileImport: file_import = self.schema.model_file_imports() if not self.required: diff --git a/autorest/codegen/models/request_builder.py b/autorest/codegen/models/request_builder.py new file mode 100644 index 00000000000..1a926cf7506 --- /dev/null +++ b/autorest/codegen/models/request_builder.py @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any, Dict, List, TypeVar, Optional, Callable + +from .base_builder import BaseBuilder, get_converted_parameters +from .request_builder_parameter import RequestBuilderParameter +from .request_builder_parameter_list import RequestBuilderParameterList +from .schema_request import SchemaRequest +from .schema_response import SchemaResponse +from .imports import FileImport, ImportType, TypingSection + + +T = TypeVar('T') +OrderedSet = Dict[T, None] + +class RequestBuilder(BaseBuilder): + def __init__( + self, + yaml_data: Dict[str, Any], + name: str, + url: str, + method: str, + multipart: bool, + schema_requests: List[SchemaRequest], + parameters: RequestBuilderParameterList, + description: str, + summary: str, + responses: Optional[List[SchemaResponse]] = None, + ): + super().__init__( + yaml_data=yaml_data, + name=name, + description=description, + parameters=parameters, + responses=responses, + summary=summary, + ) + self.url = url + self.method = method + self.multipart = multipart + self.schema_requests = schema_requests + + @property + def is_stream(self) -> bool: + """Is the request we're preparing a stream, like an upload.""" + return any(request.is_stream_request for request in self.schema_requests) + + @property + def operation_group_name(self) -> str: + return self.yaml_data["language"]["python"]["operationGroupName"] + + def imports(self) -> FileImport: + file_import = FileImport() + for parameter in self.parameters: + file_import.merge(parameter.imports()) + + file_import.add_from_import( + "azure.core.rest", + "HttpRequest", + ImportType.AZURECORE, + ) + if self.parameters.path: + file_import.add_from_import( + "azure.core.pipeline.transport._base", "_format_url_section", ImportType.AZURECORE + ) + file_import.add_from_import( + "typing", "Any", ImportType.STDLIB, typing_section=TypingSection.CONDITIONAL + ) + return file_import + + @staticmethod + def get_parameter_converter() -> Callable: + return RequestBuilderParameter.from_yaml + + @classmethod + def from_yaml(cls, yaml_data: Dict[str, Any], *, code_model) -> "RequestBuilder": + + names = [ + "build", + yaml_data["language"]["python"]["name"], + "request" + ] + name = "_".join([n for n in names if n]) + + first_request = yaml_data["requests"][0] + + parameters, multiple_media_type_parameters = ( + get_converted_parameters(yaml_data, cls.get_parameter_converter()) + ) + parameter_list = RequestBuilderParameterList(parameters + multiple_media_type_parameters) + parameter_list.add_body_kwargs() + + request_builder_class = cls( + yaml_data=yaml_data, + name=name, + url=first_request["protocol"]["http"]["path"], + method=first_request["protocol"]["http"]["method"].upper(), + multipart=first_request["protocol"]["http"].get("multipart", False), + schema_requests=[SchemaRequest.from_yaml(yaml) for yaml in yaml_data["requests"]], + parameters=parameter_list, + description=yaml_data["language"]["python"]["description"], + responses=[SchemaResponse.from_yaml(yaml) for yaml in yaml_data.get("responses", [])], + summary=yaml_data["language"]["python"].get("summary"), + ) + code_model.request_builder_ids[id(yaml_data)] = request_builder_class + return request_builder_class diff --git a/autorest/codegen/models/request_builder_parameter.py b/autorest/codegen/models/request_builder_parameter.py new file mode 100644 index 00000000000..1085663aca7 --- /dev/null +++ b/autorest/codegen/models/request_builder_parameter.py @@ -0,0 +1,109 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any, Dict, Optional +from .parameter import ParameterOnlyPathsPositional, ParameterLocation, ParameterStyle +from .constant_schema import ConstantSchema + +def _make_public(name): + if name[0] == "_": + return name[1:] + return name + +class RequestBuilderParameter(ParameterOnlyPathsPositional): + + @staticmethod + def serialize_line(function_name: str, parameters_line: str): + return f'_SERIALIZER.{function_name}({parameters_line})' + + @property + def in_method_signature(self) -> bool: + return not( + # constant bodies still go in method signature bc we don't support that in our request builder + (self.constant and not self.location == ParameterLocation.Body) + # If i'm not in the method code, no point in being in signature + or not self.in_method_code + # If I'm a flattened property of a body, don't want me, want the body param + or self.target_property_name + or not self.in_method_code + ) + + @property + def name_in_high_level_operation(self) -> str: + if self.is_body: + if self.is_multipart: + return "files" + if self.is_partial_body: + return "data" + return "json" + name = self.yaml_data["language"]["python"]["name"] + if self.implementation == "Client" and self.in_method_code: + # for these, we're passing the client params to the request builder. + # Need the self._config prefix + name = f"self._config.{name}" + return name + + @property + def in_method_code(self) -> bool: + if isinstance(self.schema, ConstantSchema) and self.location == ParameterLocation.Body: + # constant bodies aren't really a thing in requests + # users need to explicitly pass the constant body through the method signature + return True + if self.location == ParameterLocation.Uri: + # don't want any base url path formatting arguments + return False + return super(RequestBuilderParameter, self).in_method_code + + @property + def default_value(self) -> Optional[Any]: + if self.location == ParameterLocation.Body: + return None + return super(RequestBuilderParameter, self).default_value + + @property + def default_value_declaration(self) -> Optional[str]: + if self.serialized_name == "content_type": + # in request builders we're in a weird scenario + # we need to know what the types of content_type are + # but we want to serialize content_type with no default. + # So, we just return None in default_value_declaration for now + return "None" + return super().default_value_declaration + + @property + def is_keyword_only(self) -> bool: + return not self.location == ParameterLocation.Path and not self.is_kwarg + + @property + def full_serialized_name(self) -> str: + return self.serialized_name + + @classmethod + def from_yaml(cls, yaml_data: Dict[str, Any]) -> "RequestBuilderParameter": + http_protocol = yaml_data["protocol"].get("http", {"in": ParameterLocation.Other}) + name = yaml_data["language"]["python"]["name"] + location = ParameterLocation(http_protocol["in"]) + return cls( + yaml_data=yaml_data, + schema=yaml_data.get("schema", None), # FIXME replace by operation model + # See also https://github.com/Azure/autorest.modelerfour/issues/80 + rest_api_name=yaml_data["language"]["default"].get( + "serializedName", yaml_data["language"]["default"]["name"] + ), + serialized_name=_make_public(name), + description=yaml_data["language"]["python"]["description"], + implementation=yaml_data["implementation"], + required=yaml_data.get("required", False), + location=location, + skip_url_encoding=yaml_data.get("extensions", {}).get("x-ms-skip-url-encoding", False), + constraints=[], # FIXME constraints + target_property_name=id(yaml_data["targetProperty"]) if yaml_data.get("targetProperty") else None, + style=ParameterStyle(http_protocol["style"]) if "style" in http_protocol else None, + explode=http_protocol.get("explode", False), + grouped_by=yaml_data.get("groupedBy", None), + original_parameter=yaml_data.get("originalParameter", None), + flattened=yaml_data.get("flattened", False), + client_default_value=yaml_data.get("clientDefaultValue"), + ) diff --git a/autorest/codegen/models/request_builder_parameter_list.py b/autorest/codegen/models/request_builder_parameter_list.py new file mode 100644 index 00000000000..df309ef86c7 --- /dev/null +++ b/autorest/codegen/models/request_builder_parameter_list.py @@ -0,0 +1,170 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from copy import copy +from typing import List, Optional, TypeVar, Dict +from .request_builder_parameter import RequestBuilderParameter +from .parameter_list import ParameterList +from .parameter import ParameterLocation, Parameter +from .primitive_schemas import IOSchema, AnySchema +from .dictionary_schema import DictionarySchema +from .base_schema import BaseSchema + +T = TypeVar('T') +OrderedSet = Dict[T, None] + +_REQUEST_BUILDER_BODY_NAMES = ["files", "json", "content", "data"] + + +class RequestBuilderParameterList(ParameterList): + def __init__( + self, parameters: Optional[List[RequestBuilderParameter]] = None + ) -> None: + super(RequestBuilderParameterList, self).__init__( + parameters # type: ignore + ) + self.body_kwarg_names: OrderedSet[str] = {} + self.parameters: List[RequestBuilderParameter] = parameters or [] # type: ignore + + + @property + def constant(self) -> List[Parameter]: + """We don't do constant bodies in the request builder + """ + return [ + c for c in super(RequestBuilderParameterList, self).constant + if c.location != ParameterLocation.Body + ] + + def _change_body_param_name(self, parameter: Parameter, name: str) -> None: + self.body_kwarg_names[name] = None + parameter.serialized_name = name + + def add_body_kwargs(self) -> None: + try: + body_kwargs_added = [] + body_method_param = next( + p for p in self.parameters if p.location == ParameterLocation.Body + ) + if body_method_param.is_multipart: + file_kwarg = copy(body_method_param) + self._change_body_param_name(file_kwarg, "files") + file_kwarg.schema = DictionarySchema( + namespace="", + yaml_data={}, + element_type=AnySchema(namespace="", yaml_data={}), + ) + file_kwarg.description = ( + "Multipart input for files. See the template in our example to find the input shape. " + + file_kwarg.description + ) + body_kwargs_added.append(file_kwarg) + if body_method_param.is_partial_body: + data_kwarg = copy(body_method_param) + self._change_body_param_name(data_kwarg, "data") + data_kwarg.schema = DictionarySchema( + namespace="", + yaml_data={}, + element_type=AnySchema(namespace="", yaml_data={}), + ) + data_kwarg.description = ( + "Pass in dictionary that contains form data to include in the body of the request. " + + data_kwarg.description + ) + body_kwargs_added.append(data_kwarg) + if any([ct for ct in self.content_types if "json" in ct]): + json_kwarg = copy(body_method_param) + self._change_body_param_name(json_kwarg, "json") + json_kwarg.description = ( + "Pass in a JSON-serializable object (usually a dictionary). " + "See the template in our example to find the input shape. " + + json_kwarg.description + ) + json_kwarg.schema = AnySchema(namespace="", yaml_data={}) + body_kwargs_added.append(json_kwarg) + content_kwarg = copy(body_method_param) + self._change_body_param_name(content_kwarg, "content") + content_kwarg.schema = AnySchema(namespace="", yaml_data={}) + content_kwarg.description = ( + "Pass in binary content you want in the body of the request (typically bytes, " + "a byte iterator, or stream input). " + + content_kwarg.description + ) + body_kwargs_added.append(content_kwarg) + if len(body_kwargs_added) == 1: + body_kwargs_added[0].required = body_method_param.required + else: + for kwarg in body_kwargs_added: + kwarg.required = False + self.parameters = body_kwargs_added + self.parameters + except StopIteration: + pass + + @property + def json_body(self) -> BaseSchema: + if not self._json_body: + try: + json_param = next( + b for b in self.body if b.serialized_name not in _REQUEST_BUILDER_BODY_NAMES and + not isinstance(b.schema, IOSchema) + ) + self._json_body = json_param.schema + return self._json_body + except StopIteration: + raise ValueError("There is no JSON body in these parameters") + return self._json_body + + def kwargs_to_pop(self, async_mode: bool) -> List[Parameter]: + # we don't want to pop the body kwargs in py2.7. We send them straight to HttpRequest + kwargs = super().kwargs_to_pop(async_mode=async_mode) + if not async_mode: + kwargs.extend([k for k in self.keyword_only if k.serialized_name not in self.body_kwarg_names.keys()]) + return kwargs + + @property + def method(self) -> List[Parameter]: + """The list of parameter used in method signature. Includes both positional and kwargs + """ + signature_parameters_no_default_value = [] + signature_parameters_default_value = [] + + # Want all method parameters. + # Also allow client parameters if they're going to be used in the request body. + # i.e., path parameter, query parameter, header. + parameters = self.get_from_predicate( + lambda parameter: parameter.implementation == self.implementation or parameter.in_method_code + ) + seen_content_type = False + + for parameter in parameters: + if ( + parameter.location == ParameterLocation.Body and + parameter.serialized_name not in _REQUEST_BUILDER_BODY_NAMES + ): + # we keep the original body param from the swagger for documentation purposes + # we don't want it in the method signature + continue + if any([g for g in self.groupers if id(g.yaml_data) == id(parameter.yaml_data)]): + # we don't allow a grouped parameter for the body param + continue + if seen_content_type and parameter.serialized_name == "content_type": + # we ony want one content type + # there can be multiple content types in the case of multiple media types + continue + if parameter.serialized_name == "content_type": + seen_content_type = True + if parameter.in_method_signature: + if not parameter.default_value and parameter.required: + signature_parameters_no_default_value.append(parameter) + else: + signature_parameters_default_value.append(parameter) + + signature_parameters = signature_parameters_no_default_value + signature_parameters_default_value + signature_parameters.sort(key=lambda item: item.is_keyword_only) + return signature_parameters + + @staticmethod + def _wanted_path_parameter(parameter): + return parameter.location == ParameterLocation.Path diff --git a/autorest/codegen/models/rest.py b/autorest/codegen/models/rest.py new file mode 100644 index 00000000000..b7ff200cb2a --- /dev/null +++ b/autorest/codegen/models/rest.py @@ -0,0 +1,42 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any, Dict, List +from .base_model import BaseModel +from .request_builder import RequestBuilder +from .imports import FileImport, ImportType + +class Rest(BaseModel): + """Everything that goes into the request_builders + """ + def __init__( + self, + yaml_data: Dict[str, Any], + request_builders: List[RequestBuilder] + ): + super(Rest, self). __init__(yaml_data=yaml_data) + self.request_builders = request_builders + + def imports(self) -> FileImport: + file_import = FileImport() + for request_builder in self.request_builders: + file_import.merge(request_builder.imports()) + file_import.add_from_import("msrest", "Serializer", ImportType.AZURECORE) + return file_import + + @classmethod + def from_yaml(cls, yaml_data: Dict[str, Any], *, code_model) -> "Rest": + request_builders = [] + if yaml_data.get("operationGroups"): + request_builders = [ + RequestBuilder.from_yaml(operation_yaml, code_model=code_model) + for og_group in yaml_data["operationGroups"] + for operation_yaml in og_group["operations"] + ] + + return cls( + yaml_data=yaml_data, + request_builders=request_builders + ) diff --git a/autorest/codegen/models/schema_request.py b/autorest/codegen/models/schema_request.py index 88ca10fbe03..1abd6089e66 100644 --- a/autorest/codegen/models/schema_request.py +++ b/autorest/codegen/models/schema_request.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Dict, List, Any +from typing import Dict, List, Any, Optional from .base_model import BaseModel from .parameter import Parameter @@ -14,11 +14,11 @@ def __init__( self, yaml_data: Dict[str, Any], media_types: List[str], - parameters: List[Parameter] + parameters: ParameterList, ) -> None: super().__init__(yaml_data) self.media_types = media_types - self.parameters = ParameterList(parameters) + self.parameters = parameters @property def pre_semicolon_media_types(self) -> List[str]: @@ -42,7 +42,8 @@ def is_stream_request(self) -> bool: @classmethod def from_yaml(cls, yaml_data: Dict[str, Any]) -> "SchemaRequest": - parameters = [ + + parameters: Optional[List[Parameter]] = [ Parameter.from_yaml(yaml) for yaml in yaml_data.get("parameters", []) ] @@ -50,7 +51,7 @@ def from_yaml(cls, yaml_data: Dict[str, Any]) -> "SchemaRequest": return cls( yaml_data=yaml_data, media_types=yaml_data["protocol"]["http"].get("mediaTypes", []), - parameters=parameters + parameters=ParameterList(parameters) ) def __repr__(self) -> str: diff --git a/autorest/codegen/serializers/__init__.py b/autorest/codegen/serializers/__init__.py index 9b36715a32b..ec4d0d74641 100644 --- a/autorest/codegen/serializers/__init__.py +++ b/autorest/codegen/serializers/__init__.py @@ -3,13 +3,13 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from typing import List from pathlib import Path - from jinja2 import PackageLoader, Environment from ...jsonrpc import AutorestAPI from ..models import CodeModel - +from ..models.request_builder import RequestBuilder from .enum_serializer import EnumSerializer from .general_serializer import GeneralSerializer from .model_generic_serializer import ModelGenericSerializer @@ -18,6 +18,7 @@ from .operations_init_serializer import OperationsInitSerializer from .operation_group_serializer import OperationGroupSerializer from .metadata_serializer import MetadataSerializer +from .rest_serializer import RestPython3Serializer, RestGenericSerializer, RestSerializer __all__ = [ "JinjaSerializer", @@ -49,24 +50,26 @@ def serialize(self, code_model: CodeModel) -> None: self._autorestapi.read_file(namespace_path / "_patch.py") ) - if code_model.schemas or code_model.enums: - self._serialize_and_write_models_folder(code_model=code_model, env=env, namespace_path=namespace_path) - self._serialize_and_write_top_level_folder(code_model=code_model, env=env, namespace_path=namespace_path) - - if code_model.operation_groups: - self._serialize_and_write_operations_folder(code_model=code_model, env=env, namespace_path=namespace_path) - + if code_model.rest.request_builders: + self._serialize_and_write_rest_layer(code_model=code_model, env=env, namespace_path=namespace_path) if not code_model.options["no_async"]: - self._serialize_and_write_aio_folder( + self._serialize_and_write_aio_top_level_folder( code_model=code_model, env=env, namespace_path=namespace_path, ) + if code_model.show_operations and code_model.operation_groups: + self._serialize_and_write_operations_folder(code_model=code_model, env=env, namespace_path=namespace_path) + if code_model.options["multiapi"]: self._serialize_and_write_metadata( code_model, env=env, namespace_path=namespace_path ) + if code_model.show_models and (code_model.schemas or code_model.enums): + self._serialize_and_write_models_folder(code_model=code_model, env=env, namespace_path=namespace_path) + + def _serialize_and_write_models_folder(self, code_model: CodeModel, env: Environment, namespace_path: Path) -> None: # Write the models folder models_path = namespace_path / Path("models") @@ -86,6 +89,55 @@ def _serialize_and_write_models_folder(self, code_model: CodeModel, env: Environ models_path / Path("__init__.py"), ModelInitSerializer(code_model=code_model, env=env).serialize() ) + def _serialize_and_write_rest_layer( + self, code_model: CodeModel, env: Environment, namespace_path: Path + ) -> None: + rest_path = namespace_path / Path(code_model.rest_layer_name) + operation_group_names = { + rb.operation_group_name for rb in code_model.rest.request_builders + } + + for operation_group_name in operation_group_names: + output_path = rest_path / Path(operation_group_name) if operation_group_name else rest_path + request_builders = [ + r for r in code_model.rest.request_builders if r.operation_group_name == operation_group_name + ] + self._serialize_and_write_single_rest_layer( + code_model, env, output_path, request_builders + ) + if not "" in operation_group_names: + self._autorestapi.write_file( + rest_path / Path("__init__.py"), code_model.options['license_header'] + ) + + + def _serialize_and_write_single_rest_layer( + self, code_model: CodeModel, env: Environment, output_path: Path, request_builders: List[RequestBuilder] + ) -> None: + + # write generic request builders file + self._autorestapi.write_file( + output_path / Path("_request_builders.py"), + RestGenericSerializer( + code_model=code_model, env=env, request_builders=request_builders + ).serialize_request_builders() + ) + + # write python3 request builders file + self._autorestapi.write_file( + output_path / Path("_request_builders_py3.py"), + RestPython3Serializer( + code_model=code_model, env=env, request_builders=request_builders + ).serialize_request_builders() + ) + + # write rest init file + self._autorestapi.write_file( + output_path / Path("__init__.py"), RestSerializer( + code_model=code_model, env=env, request_builders=request_builders + ).serialize_init() + ) + def _serialize_and_write_operations_folder( self, code_model: CodeModel, env: Environment, namespace_path: Path ) -> None: @@ -156,7 +208,7 @@ def _serialize_and_write_top_level_folder( ) -> None: general_serializer = GeneralSerializer(code_model=code_model, env=env, async_mode=False) - if code_model.operation_groups: + if code_model.rest.request_builders: self._autorestapi.write_file( namespace_path / Path("__init__.py"), general_serializer.serialize_init_file() ) @@ -173,7 +225,7 @@ def _serialize_and_write_top_level_folder( p = p.parent # Write the service client - if code_model.operation_groups: + if code_model.rest.request_builders: self._autorestapi.write_file( namespace_path / Path(f"_{code_model.module_name}.py"), general_serializer.serialize_service_client_file() @@ -185,7 +237,7 @@ def _serialize_and_write_top_level_folder( self._autorestapi.write_file(namespace_path / Path("py.typed"), "# Marker file for PEP 561.") # Write the config file - if code_model.operation_groups: + if code_model.rest.request_builders: self._autorestapi.write_file( namespace_path / Path("_configuration.py"), general_serializer.serialize_config_file() ) @@ -194,7 +246,9 @@ def _serialize_and_write_top_level_folder( if code_model.options["basic_setup_py"]: self._autorestapi.write_file(Path("setup.py"), general_serializer.serialize_setup_file()) - def _serialize_and_write_aio_folder(self, code_model: CodeModel, env: Environment, namespace_path: Path) -> None: + def _serialize_and_write_aio_top_level_folder( + self, code_model: CodeModel, env: Environment, namespace_path: Path + ) -> None: aio_general_serializer = GeneralSerializer(code_model=code_model, env=env, async_mode=True) aio_path = namespace_path / Path("aio") @@ -213,6 +267,7 @@ def _serialize_and_write_aio_folder(self, code_model: CodeModel, env: Environmen aio_path / Path("_configuration.py"), aio_general_serializer.serialize_config_file() ) + def _serialize_and_write_metadata(self, code_model: CodeModel, env: Environment, namespace_path: Path) -> None: metadata_serializer = MetadataSerializer(code_model, env) self._autorestapi.write_file(namespace_path / Path("_metadata.json"), metadata_serializer.serialize()) diff --git a/autorest/codegen/serializers/builder_serializer.py b/autorest/codegen/serializers/builder_serializer.py new file mode 100644 index 00000000000..bad0f7e4e1c --- /dev/null +++ b/autorest/codegen/serializers/builder_serializer.py @@ -0,0 +1,871 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from functools import partial +from itertools import groupby +import json +from collections import defaultdict +from abc import abstractmethod, ABC +from typing import Any, Callable, List, TypeVar, Dict, Union, Optional, cast +from ..models import ( + Operation, + CodeModel, + PagingOperation, + LROOperation, + LROPagingOperation, + BuilderType, + ObjectSchema, + DictionarySchema, + ListSchema, + BaseSchema, + SchemaRequest, + Parameter, + RequestBuilder, + RequestBuilderParameter, +) +from . import utils + +T = TypeVar("T") +OrderedSet = Dict[T, None] + + +def _serialize_json_dict(template_representation: str, indent: int = 4) -> Any: + # only for template use, since it wraps everything in strings + return json.dumps(template_representation, sort_keys=True, indent=indent) + + +def _serialize_files_dict(multipart_parameters: List[Parameter]) -> str: + # only for template use + template = { + param.serialized_name: param.schema.get_files_template_representation( + optional=not param.required, + description=param.description, + ) + for param in multipart_parameters + } + return json.dumps(template, sort_keys=True, indent=4) + + +def _serialize_parameters_dict(parameters: List[Parameter], dict_name: str, value_callable: Callable) -> List[str]: + retval = [f"{dict_name} = {{"] + for parameter in parameters: + retval.append(f' "{parameter.rest_api_name}": {value_callable(parameter)},') + retval.append("}") + return retval + +def _content_type_error_check(builder: BuilderType) -> List[str]: + retval = ["else:"] + retval.append(" raise ValueError(") + retval.append(" \"The content_type '{}' is not one of the allowed values: \"") + retval.append(f' "{builder.parameters.content_types}".format(content_type)') + retval.append(" )") + return retval + +def _serialize_files_parameter(builder: BuilderType) -> List[str]: + retval = ["files = {"] + for parameter in builder.parameters.body: + retval.append(f' "{parameter.rest_api_name}": {parameter.serialized_name},') + retval.append("}") + return retval + +def _serialize_body_call( + builder: BuilderType, send_xml: bool, ser_ctxt: Optional[str], ser_ctxt_name: str +) -> str: + body_param = builder.parameters.body[0] + body_is_xml = ", is_xml=True" if send_xml else "" + pass_ser_ctxt = f", {ser_ctxt_name}={ser_ctxt_name}" if ser_ctxt else "" + return ( + f"{builder.serialized_body_kwarg} = self._serialize.body({body_param.serialized_name}, " + f"'{ body_param.serialization_type }'{body_is_xml}{ pass_ser_ctxt })" + ) + +def _serialize_body(builder: BuilderType) -> List[str]: + retval = [] + send_xml = bool(builder.parameters.has_body and any(["xml" in ct for ct in builder.parameters.content_types])) + ser_ctxt_name = "serialization_ctxt" + ser_ctxt = builder.parameters.body[0].xml_serialization_ctxt if send_xml else None + if ser_ctxt: + retval.append(f'{ser_ctxt_name} = {{"xml": {{{ser_ctxt}}}}}') + body_param = builder.parameters.body[0] + serialize_body_call = _serialize_body_call( + builder, + send_xml, + ser_ctxt, + ser_ctxt_name, + ) + if body_param.required: + retval.append(serialize_body_call) + else: + retval.append(f"if {body_param.serialized_name} is not None:") + retval.append(" " + serialize_body_call) + if len(builder.body_kwargs_to_pass_to_request_builder) == 1: + retval.append("else:") + retval.append(f" {builder.serialized_body_kwarg} = None") + return retval + +def _set_body_content_kwarg(builder: BuilderType, schema_request: SchemaRequest): + retval = [] + if schema_request.is_stream_request: + retval.append(f"content = {builder.parameters.body[0].serialized_name}") + elif schema_request.body_parameter_has_schema and not builder.request_builder.multipart: + retval.extend(_serialize_body(builder)) + return retval + + +def _serialize_body_parameters( + builder: BuilderType, +) -> List[str]: + retval = [] + if len(builder.request_builder.schema_requests) == 1: + retval.extend(_set_body_content_kwarg(builder, builder.request_builder.schema_requests[0])) + else: + for idx, schema_request in enumerate(builder.request_builder.schema_requests): + if_statement = "if" if idx == 0 else "elif" + retval.append( + f'{if_statement} content_type.split(";")[0] in {schema_request.pre_semicolon_media_types}:' + ) + retval.extend([" " + line for line in _set_body_content_kwarg(builder, schema_request)]) + retval.extend(_content_type_error_check(builder)) + + return retval + +def _serialize_grouped_parameters(builder: BuilderType) -> List[str]: + retval = [] + for grouped_parameter in builder.parameters.grouped: + retval.append(f"{grouped_parameter.serialized_name} = None") + for grouper_name, grouped_parameters in groupby( + builder.parameters.grouped, key=lambda a: cast(Parameter, a.grouped_by).serialized_name + ): + retval.append(f"if {grouper_name} is not None:") + for grouped_parameter in grouped_parameters: + retval.append( + f" {grouped_parameter.serialized_name} = " + f"{ grouper_name }.{ grouped_parameter.corresponding_grouped_property.name }" + ) + return retval + +def _content_type_docstring(builder: BuilderType) -> str: + content_type_str = ( + ":keyword str content_type: Media type of the body sent to the API. " + + f'Default value is "{builder.parameters.default_content_type}". ' + + 'Allowed values are: "{}."'.format('", "'.join(builder.parameters.content_types)) + ) + return content_type_str + +class BuilderSerializerProtocol(ABC): + @property + @abstractmethod + def _is_in_class(self) -> bool: + ... + + @property + @abstractmethod + def _function_definition(self) -> str: + """The def keyword for the function, i.e. 'def' or 'async def'""" + ... + + @property + @abstractmethod + def _want_inline_type_hints(self) -> bool: + """Whether you want inline type hints. If false, your type hints will be commented'""" + ... + + @abstractmethod + def _method_signature(self, builder: BuilderType) -> str: + """Signature of the builder. Does not include return type annotation""" + ... + + @abstractmethod + def _response_type_annotation(self, builder: BuilderType, modify_if_head_as_boolean: bool = True) -> str: + """The mypy type annotation for the response""" + ... + + @abstractmethod + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + """Any wrappers that you want to go around the response type annotation""" + ... + + @staticmethod + @abstractmethod + def _method_signature_and_response_type_annotation_template( + method_signature: str, response_type_annotation: str + ) -> str: + """Template for how to combine the method signature + the response type annotation together. Called by + method_signature_and_response_type_annotation""" + ... + + @abstractmethod + def method_signature_and_response_type_annotation(self, builder: BuilderType) -> str: + """Combines the method signature + the response type annotation together""" + ... + + @abstractmethod + def description_and_summary(self, builder: BuilderType) -> List[str]: + """Description + summary from the swagger. Will be formatted into the overall operation description""" + ... + + @abstractmethod + def response_docstring(self, builder: BuilderType) -> List[str]: + """Response portion of the docstring""" + ... + + @abstractmethod + def want_example_template(self, builder: BuilderType) -> bool: + ... + + @abstractmethod + def get_example_template(self, builder: BuilderType) -> List[str]: + ... + + @abstractmethod + def _get_json_example_template(self, builder: BuilderType) -> List[str]: + ... + + @abstractmethod + def _has_json_example_template(self, builder: BuilderType) -> bool: + ... + + @abstractmethod + def _has_files_example_template(self, builder: BuilderType) -> bool: + ... + + @abstractmethod + def _json_example_param_name(self, builder: BuilderType) -> str: + ... + + @abstractmethod + def _get_json_response_template(self, builder: BuilderType) -> List[str]: + ... + + @abstractmethod + def _get_json_response_template_to_status_codes(self, builder: BuilderType) -> Dict[str, List[str]]: + ... + + @abstractmethod + def _serialize_path_format_parameters(self, builder: BuilderType) -> List[str]: + ... + + @abstractmethod + def _get_kwargs_to_pop(self, builder: BuilderType) -> List[Parameter]: + ... + + @abstractmethod + def pop_kwargs_from_signature(self, builder: BuilderType) -> List[str]: + ... + + +class BuilderBaseSerializer(BuilderSerializerProtocol): # pylint: disable=abstract-method + def __init__(self, code_model: CodeModel) -> None: + self.code_model = code_model + + def _method_signature(self, builder: BuilderType) -> str: + return utils.serialize_method( + function_def=self._function_definition, + method_name=builder.name, + is_in_class=self._is_in_class, + method_param_signatures=builder.parameters.method_signature(self._want_inline_type_hints), + ) + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return [] + + def method_signature_and_response_type_annotation(self, builder: BuilderType) -> str: + method_signature = self._method_signature(builder) + response_type_annotation = self._response_type_annotation(builder) + for wrapper in self._response_type_annotation_wrapper(builder)[::-1]: + response_type_annotation = f"{wrapper}[{response_type_annotation}]" + return self._method_signature_and_response_type_annotation_template(method_signature, response_type_annotation) + + def description_and_summary(self, builder: BuilderType) -> List[str]: + description_list: List[str] = [] + description_list.append(f"{ builder.summary.strip() if builder.summary else builder.description.strip() }") + if builder.summary and builder.description: + description_list.append("") + description_list.append(builder.description.strip()) + description_list.append("") + return description_list + + 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 m.is_documented]: + description_list.extend( + f":{parameter.description_keyword} { parameter.serialized_name }: { parameter.description }".replace( + "\n", "\n " + ).split("\n") + ) + description_list.append( + f":{parameter.docstring_type_keyword} { parameter.serialized_name }: { parameter.docstring_type }" + ) + try: + request_builder: RequestBuilder = cast(Operation, builder).request_builder + except AttributeError: + request_builder = cast(RequestBuilder, builder) + + if len(request_builder.schema_requests) > 1: + description_list.append(_content_type_docstring(builder)) + return description_list + + def param_description_and_response_docstring(self, builder: BuilderType) -> List[str]: + return self.param_description(builder) + self.response_docstring(builder) + + def _get_json_response_template_to_status_codes(self, builder: BuilderType) -> Dict[str, List[str]]: + # successful status codes of responses that have bodies + responses = [ + response + for response in builder.responses + if any(code in builder.success_status_code for code in response.status_codes) + and isinstance(response.schema, (DictionarySchema, ListSchema, ObjectSchema)) + ] + retval = defaultdict(list) + for response in responses: + status_codes = [str(status_code) for status_code in response.status_codes] + response_json = _serialize_json_dict(cast(BaseSchema, response.schema).get_json_template_representation()) + retval[response_json].extend(status_codes) + return retval + + def get_example_template(self, builder: BuilderType) -> List[str]: + template = [] + if self._has_json_example_template(builder): + template.append("") + template += self._get_json_example_template(builder) + # if self._has_files_example_template(builder): + # template.append("") + # template += self._get_files_example_template(builder) + if self._get_json_response_template_to_status_codes(builder): + template.append("") + template += self._get_json_response_template(builder) + return template + + def _get_json_example_template(self, builder: BuilderType) -> List[str]: + template = [] + json_body = builder.parameters.json_body + object_schema = cast(ObjectSchema, json_body) + try: + discriminator_name = object_schema.discriminator_name + subtype_map = object_schema.subtype_map + except AttributeError: + discriminator_name = None + subtype_map = None + if subtype_map: + template.append("{} = '{}'".format(discriminator_name, "' or '".join(subtype_map.values()))) + template.append("") + + try: + property_with_discriminator = object_schema.property_with_discriminator + except AttributeError: + property_with_discriminator = None + if property_with_discriminator: + polymorphic_schemas = [ + s + for s in self.code_model.sorted_schemas + if s.name in property_with_discriminator.schema.subtype_map.values() + ] + num_schemas = min(self.code_model.options["polymorphic_examples"], len(polymorphic_schemas)) + for i in range(num_schemas): + schema = polymorphic_schemas[i] + polymorphic_property = _serialize_json_dict( + schema.get_json_template_representation(), + ) + template.extend(f"{property_with_discriminator.name} = {polymorphic_property}".splitlines()) + if i != num_schemas - 1: + template.append("# OR") + template.append("") + template.append("# JSON input template you can fill out and use as your `json` input.") + json_template = _serialize_json_dict( + builder.parameters.json_body.get_json_template_representation(), + ) + template.extend(f"{self._json_example_param_name(builder)} = {json_template}".splitlines()) + return template + + # def _get_files_example_template(self, builder: BuilderType) -> List[str]: + # multipart_params = builder.parameters._multipart_parameters + # if multipart_params: + # return [ + # "# multipart input template you can fill out and use as your `files` input.", + # f"files = {_serialize_files_dict(list(multipart_params))}", + # ] + # raise ValueError( + # "You're trying to get a template for your multipart params, but you don't have multipart params" + # ) + + def _get_json_response_template(self, builder: BuilderType) -> List[str]: + template = [] + for response_body, status_codes in self._get_json_response_template_to_status_codes(builder).items(): + template.append("# response body for status code(s): {}".format(", ".join(status_codes))) + template.extend(f"response.json() == {response_body}".splitlines()) + return template + + def _serialize_path_format_parameters(self, builder: BuilderType) -> List[str]: + return _serialize_parameters_dict( + builder.parameters.path, + dict_name="path_format_arguments", + value_callable=partial( + Parameter.build_serialize_data_call, + function_name="url", + ), + ) + + def pop_kwargs_from_signature(self, builder: BuilderType) -> List[str]: + retval = [] + for kwarg in self._get_kwargs_to_pop(builder): + if kwarg.has_default_value: + retval.append( + f"{kwarg.serialized_name} = kwargs.pop('{kwarg.serialized_name}', " + + f"{kwarg.default_value_declaration}) # type: {kwarg.type_annotation}" + ) + else: + retval.append( + f"{kwarg.serialized_name} = kwargs.pop('{kwarg.serialized_name}') # type: {kwarg.type_annotation}" + ) + return retval + + +############################## REQUEST BUILDERS ############################## + + +class RequestBuilderBaseSerializer(BuilderBaseSerializer): # pylint: disable=abstract-method + def description_and_summary(self, builder: BuilderType) -> List[str]: + retval = super().description_and_summary(builder) + retval += [ + "See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this " + "request builder into your code flow.", + "", + ] + return retval + + def want_example_template(self, builder: BuilderType) -> bool: + if self.code_model.rest_layer_name == "_rest": + 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(self._get_json_response_template_to_status_codes(builder)) + + @property + def _function_definition(self) -> str: + return "def" + + @property + def _is_in_class(self) -> bool: + return False + + def _response_type_annotation(self, builder: BuilderType, modify_if_head_as_boolean: bool = True) -> str: + return "HttpRequest" + + def response_docstring(self, builder: BuilderType) -> List[str]: + response_str = ( + f":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_str = f":rtype: ~azure.core.rest.HttpRequest" + return [response_str, rtype_str] + + def _json_example_param_name(self, builder: BuilderType) -> str: + return "json" + + def _has_json_example_template(self, builder: BuilderType) -> bool: + return "json" in builder.parameters.body_kwarg_names + + def _has_files_example_template(self, builder: BuilderType) -> bool: + return "files" in builder.parameters.body_kwarg_names + + +class RequestBuilderGenericSerializer(RequestBuilderBaseSerializer): + @property + def _want_inline_type_hints(self) -> bool: + return False + + @staticmethod + def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str): + return utils.method_signature_and_response_type_annotation_template( + async_mode=False, method_signature=method_signature, response_type_annotation=response_type_annotation + ) + + def _get_kwargs_to_pop(self, builder: BuilderType): + return builder.parameters.kwargs_to_pop(async_mode=False) + + +class RequestBuilderPython3Serializer(RequestBuilderBaseSerializer): + @property + def _want_inline_type_hints(self) -> bool: + return True + + @staticmethod + def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str): + return utils.method_signature_and_response_type_annotation_template( + async_mode=True, method_signature=method_signature, response_type_annotation=response_type_annotation + ) + + def _get_kwargs_to_pop(self, builder: BuilderType): + return builder.parameters.kwargs_to_pop(async_mode=True) + + +############################## NORMAL OPERATIONS ############################## + + +class OperationBaseSerializer(BuilderBaseSerializer): # pylint: disable=abstract-method + def description_and_summary(self, builder: BuilderType) -> List[str]: + retval = super().description_and_summary(builder) + if builder.deprecated: + retval.append(".. warning::") + retval.append(" This method is deprecated") + retval.append("") + return retval + + @property + def _is_in_class(self) -> bool: + return True + + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: disable=unused-argument, no-self-use + return [] + + def param_description(self, builder: BuilderType) -> List[str]: # pylint: disable=no-self-use + description_list = super().param_description(builder) + description_list.append( + ":keyword callable cls: A custom type or function that will be passed the direct response" + ) + return description_list + + def _response_docstring_type_template(self, builder: BuilderType) -> str: + retval = "{}" + for wrapper in self._response_docstring_type_wrapper(builder)[::-1]: + retval = f"{wrapper}[{retval}]" + return retval + + def _response_type_annotation(self, builder: BuilderType, modify_if_head_as_boolean: bool = True) -> str: + if ( + modify_if_head_as_boolean + and builder.request_builder.method == "head" + and self.code_model.options["head_as_boolean"] + ): + return "bool" + response_body_annotations: OrderedSet[str] = {} + for response in [r for r in builder.responses if r.has_body]: + response_body_annotations[response.operation_type_annotation] = None + response_str = ", ".join(response_body_annotations.keys()) or "None" + if len(response_body_annotations) > 1: + response_str = f"Union[{response_str}]" + if builder.has_optional_return_type: + response_str = f"Optional[{response_str}]" + return response_str + + def cls_type_annotation(self, builder: BuilderType) -> str: + return f"# type: ClsType[{self._response_type_annotation(builder, modify_if_head_as_boolean=False)}]" + + def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use, unused-argument + return "{}, or the result of cls(response)" + + def response_docstring(self, builder: BuilderType) -> List[str]: + responses_with_body = [r for r in builder.responses if r.has_body] + if builder.request_builder.method == "head" and self.code_model.options["head_as_boolean"]: + response_docstring_text = "bool" + rtype = "bool" + elif responses_with_body: + response_body_docstring_text: OrderedSet[str] = { + response.docstring_text: None for response in responses_with_body + } + response_docstring_text = " or ".join(response_body_docstring_text.keys()) + response_body_docstring_type: OrderedSet[str] = { + response.docstring_type: None for response in responses_with_body + } + rtype = " or ".join(response_body_docstring_type.keys()) + if builder.has_optional_return_type: + rtype += " or None" + else: + response_docstring_text = "None" + rtype = "None" + response_str = f":return: {self._response_docstring_text_template(builder).format(response_docstring_text)}" + rtype_str = f":rtype: {self._response_docstring_type_template(builder).format(rtype)}" + return [response_str, rtype_str, ":raises: ~azure.core.exceptions.HttpResponseError"] + + def want_example_template(self, builder: BuilderType) -> bool: + if self.code_model.show_models: + return False + if builder.parameters.has_body: + body_params = builder.parameters.body + return any([b for b in body_params if isinstance(b.schema, (DictionarySchema, ListSchema, ObjectSchema))]) + return bool(self._get_json_response_template_to_status_codes(builder)) + + 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 + + def _has_files_example_template(self, builder: BuilderType) -> bool: + return False + + def _call_request_builder_helper( + self, + builder: BuilderType, + request_builder: RequestBuilder, + template_url: Optional[str] = None, + ) -> List[str]: + retval = [] + if len(builder.body_kwargs_to_pass_to_request_builder) > 1: + for k in builder.body_kwargs_to_pass_to_request_builder: + retval.append(f"{k} = None") + if builder.parameters.grouped: + # request builders don't allow grouped parameters, so we group them before making the call + retval.extend(_serialize_grouped_parameters(builder)) + if request_builder.multipart: + # we have to construct our form data before passing to the request as well + retval.append("# Construct form data") + retval.extend(_serialize_files_parameter(builder)) + if builder.parameters.is_flattened: + # unflatten before passing to request builder as well + retval.append(builder.parameters.build_flattened_object()) + # we also don't do constant bodies in request builders + for constant_body in builder.parameters.constant_bodies: + retval.append(f"{constant_body.serialized_name} = {constant_body.constant_declaration}") + if builder.parameters.has_body: + retval.extend(_serialize_body_parameters(builder)) + operation_group_name = request_builder.operation_group_name + request_path_name = "rest{}.{}".format( + ("_" + operation_group_name) if operation_group_name else "", request_builder.name + ) + retval.append("") + retval.append(f"request = {request_path_name}(") + for parameter in request_builder.parameters.method: + if parameter.is_body: + continue + high_level_name = cast(RequestBuilderParameter, parameter).name_in_high_level_operation + retval.append(f" {parameter.serialized_name}={high_level_name},") + if request_builder.parameters.has_body: + for kwarg in builder.body_kwargs_to_pass_to_request_builder: + retval.append(f" {kwarg}={kwarg},") + template_url = template_url or f"self.{builder.name}.metadata['url']" + retval.append(f" template_url={template_url},") + retval.append(")._to_pipeline_transport_request()") + if builder.parameters.path: + retval.extend(self._serialize_path_format_parameters(builder)) + retval.append( + "request.url = self._client.format_url(request.url{})".format( + ", **path_format_arguments" if builder.parameters.path else "" + ) + ) + return retval + + def call_request_builder(self, builder: BuilderType) -> List[str]: + return self._call_request_builder_helper(builder, builder.request_builder) + + +class SyncOperationSerializer(OperationBaseSerializer): + @property + def _want_inline_type_hints(self) -> bool: + return False + + @property + def _function_definition(self) -> str: + return "def" + + @staticmethod + def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str): + return utils.method_signature_and_response_type_annotation_template( + async_mode=False, method_signature=method_signature, response_type_annotation=response_type_annotation + ) + + def _get_kwargs_to_pop(self, builder: BuilderType): + return builder.parameters.kwargs_to_pop(async_mode=False) + + +class AsyncOperationSerializer(OperationBaseSerializer): + @property + def _want_inline_type_hints(self) -> bool: + return True + + @property + def _function_definition(self) -> str: + return "async def" + + @staticmethod + def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str): + return utils.method_signature_and_response_type_annotation_template( + async_mode=True, method_signature=method_signature, response_type_annotation=response_type_annotation + ) + + def _get_kwargs_to_pop(self, builder: BuilderType): + return builder.parameters.kwargs_to_pop(async_mode=True) + + +############################## PAGING OPERATIONS ############################## + + +class PagingOperationBaseSerializer(OperationBaseSerializer): # pylint: disable=abstract-method + def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use, unused-argument + return "An iterator like instance of either {} or the result of cls(response)" + + def cls_type_annotation(self, builder: BuilderType) -> str: + interior = super()._response_type_annotation(builder, modify_if_head_as_boolean=False) + return f"# type: ClsType[{interior}]" + + def call_next_link_request_builder(self, builder: BuilderType) -> List[str]: + if builder.next_request_builder: + request_builder = builder.next_request_builder + template_url = f"'{request_builder.url}'" + else: + request_builder = builder.request_builder + template_url = "next_link" + request_builder = builder.next_request_builder or builder.request_builder + return self._call_request_builder_helper( + builder, + request_builder, + template_url=template_url, + ) + + +class SyncPagingOperationSerializer(PagingOperationBaseSerializer, SyncOperationSerializer): + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use + return [f"~{builder.get_pager_path(async_mode=False)}"] + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return ["Iterable"] + + +class AsyncPagingOperationSerializer(PagingOperationBaseSerializer, AsyncOperationSerializer): + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use + return [f"~{builder.get_pager_path(async_mode=True)}"] + + @property + def _function_definition(self) -> str: + return "def" + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return ["AsyncIterable"] + + +############################## LRO OPERATIONS ############################## + + +class LROOperationBaseSerializer(OperationBaseSerializer): # pylint: disable=abstract-method + def cls_type_annotation(self, builder: BuilderType) -> str: + return f"# type: ClsType[{super()._response_type_annotation(builder, modify_if_head_as_boolean=False)}]" + + @abstractmethod + def _default_polling_method(self, builder: BuilderType) -> str: + ... + + @property + @abstractmethod + def _polling_method_type(self): + ... + + def param_description(self, builder: BuilderType) -> List[str]: + retval = super().param_description(builder) + retval.append(":keyword str continuation_token: A continuation token to restart a poller from a saved state.") + retval.append( + f":keyword polling: By default, your polling method will be {self._default_polling_method(builder)}. " + "Pass in False for this operation to not poll, or pass in your own initialized polling object for a" + " personal polling strategy." + ) + retval.append(f":paramtype polling: bool or ~{self._polling_method_type}") + retval.append( + ":keyword int polling_interval: Default waiting time between two polls for LRO operations " + "if no Retry-After header is present." + ) + return retval + + +class SyncLROOperationSerializer(LROOperationBaseSerializer, SyncOperationSerializer): + def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use + lro_section = f"An instance of {builder.get_poller(async_mode=False)} " + return lro_section + "that returns either {} or the result of cls(response)" + + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use + return [f"~{builder.get_poller_path(async_mode=False)}"] + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return [builder.get_poller(async_mode=False)] + + def _default_polling_method(self, builder: BuilderType) -> str: + return builder.get_default_polling_method(async_mode=False, azure_arm=self.code_model.options["azure_arm"]) + + @property + def _polling_method_type(self): + return "azure.core.polling.PollingMethod" + + +class AsyncLROOperationSerializer(LROOperationBaseSerializer, AsyncOperationSerializer): + + def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use + lro_section = f"An instance of {builder.get_poller(async_mode=True)} " + return lro_section + "that returns either {} or the result of cls(response)" + + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use + return [f"~{builder.get_poller_path(async_mode=True)}"] + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return [builder.get_poller(async_mode=True)] + + def _default_polling_method(self, builder: BuilderType) -> str: + return builder.get_default_polling_method(async_mode=True, azure_arm=self.code_model.options["azure_arm"]) + + @property + def _polling_method_type(self): + return "azure.core.polling.AsyncPollingMethod" + + +############################## LRO PAGING OPERATIONS ############################## + + +class SyncLROPagingOperationSerializer(SyncLROOperationSerializer, SyncPagingOperationSerializer): + + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: + return SyncLROOperationSerializer._response_docstring_type_wrapper( + self, builder + ) + SyncPagingOperationSerializer._response_docstring_type_wrapper(self, builder) + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return SyncLROOperationSerializer._response_type_annotation_wrapper(self, builder) + [ + builder.get_pager(async_mode=False) + ] + + def _response_docstring_text_template(self, builder: BuilderType) -> str: + lro_doc = SyncLROOperationSerializer._response_docstring_text_template(self, builder) + paging_doc = SyncPagingOperationSerializer._response_docstring_text_template(self, builder) + paging_doc = paging_doc.replace(paging_doc[0], paging_doc[0].lower(), 1) + return lro_doc.format(paging_doc).replace(" or the result of cls(response)", "", 1).replace("either ", "", 1) + + def cls_type_annotation(self, builder: BuilderType) -> str: + return f"# type: ClsType[{self._response_type_annotation(builder, modify_if_head_as_boolean=False)}]" + + +class AsyncLROPagingOperationSerializer(AsyncLROOperationSerializer, AsyncPagingOperationSerializer): + @property + def _function_definition(self) -> str: + return "async def" + + def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: + return AsyncLROOperationSerializer._response_docstring_type_wrapper( + self, builder + ) + AsyncPagingOperationSerializer._response_docstring_type_wrapper(self, builder) + + def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]: + return AsyncLROOperationSerializer._response_type_annotation_wrapper(self, builder) + [ + builder.get_pager(async_mode=True) + ] + + def _response_docstring_text_template(self, builder: BuilderType) -> str: + lro_doc = AsyncLROOperationSerializer._response_docstring_text_template(self, builder) + paging_doc = AsyncPagingOperationSerializer._response_docstring_text_template(self, builder) + paging_doc = paging_doc.replace(paging_doc[0], paging_doc[0].lower(), 1) + return lro_doc.format(paging_doc).replace(" or the result of cls(response)", "", 1).replace("either ", "", 1) + + +def get_operation_serializer(builder: BuilderType, code_model, async_mode: bool) -> OperationBaseSerializer: + retcls = AsyncOperationSerializer if async_mode else SyncOperationSerializer + if isinstance(builder, LROPagingOperation): + retcls = AsyncLROPagingOperationSerializer if async_mode else SyncLROPagingOperationSerializer + elif isinstance(builder, LROOperation): + retcls = AsyncLROOperationSerializer if async_mode else SyncLROOperationSerializer + elif isinstance(builder, PagingOperation): + retcls = AsyncPagingOperationSerializer if async_mode else SyncPagingOperationSerializer + return retcls(code_model) + + +def get_request_builder_serializer(code_model, is_python_3_file: bool) -> RequestBuilderBaseSerializer: + retcls = RequestBuilderPython3Serializer if is_python_3_file else RequestBuilderGenericSerializer + return retcls(code_model) diff --git a/autorest/codegen/serializers/client_serializer.py b/autorest/codegen/serializers/client_serializer.py new file mode 100644 index 00000000000..778bb8b7daa --- /dev/null +++ b/autorest/codegen/serializers/client_serializer.py @@ -0,0 +1,139 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import List +from . import utils +from ..models import CodeModel + + +class ClientSerializer: + def __init__(self, code_model: CodeModel) -> None: + self.code_model = code_model + + def _init_signature(self, async_mode: bool) -> str: + return utils.serialize_method( + function_def="def", + method_name="__init__", + is_in_class=True, + method_param_signatures=self.code_model.service_client.method_parameters_signature(async_mode), + ) + + def init_signature_and_response_type_annotation(self, async_mode: bool) -> str: + init_signature = self._init_signature(async_mode) + return utils.method_signature_and_response_type_annotation_template( + async_mode=async_mode, + method_signature=init_signature, + response_type_annotation="None", + ) + + def class_definition(self, async_mode) -> str: + class_name = self.code_model.class_name + has_mixin_og = any(og for og in self.code_model.operation_groups if og.is_empty_operation_group) + base_class = "" + if has_mixin_og: + base_class = f"{class_name}OperationsMixin" + elif not async_mode: + base_class = "object" + if base_class: + return f"class {class_name}({base_class}):" + return f"class {class_name}:" + + def property_descriptions(self, async_mode: bool) -> List[str]: + retval: List[str] = [] + operations_folder = ".aio.operations." if async_mode else ".operations." + for og in [og for og in self.code_model.operation_groups if not og.is_empty_operation_group]: + retval.append(f":ivar {og.name}: {og.class_name} operations") + retval.append(f":vartype {og.name}: {self.code_model.namespace}{operations_folder}{og.class_name}") + for param in self.code_model.service_client.method_parameters: + retval.append(f":param {param.serialized_name}: {param.description}") + retval.append(f":type {param.serialized_name}: {param.docstring_type}") + if self.code_model.has_lro_operations: + retval.append( + ":keyword int polling_interval: Default waiting time between two polls for LRO operations " + "if no Retry-After header is present." + ) + retval.append('"""') + return retval + + def serializers_and_operation_groups_properties(self) -> List[str]: + retval = [] + if self.code_model.sorted_schemas: + client_models_value = "{k: v for k, v in models.__dict__.items() if isinstance(v, type)}" + else: + client_models_value = "{} # type: Dict[str, Any]" + retval.append(f"client_models = {client_models_value}") + retval.append(f"self._serialize = Serializer(client_models)") + retval.append(f"self._deserialize = Deserializer(client_models)") + if not self.code_model.options["client_side_validation"]: + retval.append("self._serialize.client_side_validation = False") + operation_groups = [og for og in self.code_model.operation_groups if not og.is_empty_operation_group] + if operation_groups: + retval.extend( + [ + f"self.{og.name} = {og.class_name}(self._client, self._config, self._serialize, self._deserialize)" + for og in operation_groups + ] + ) + return retval + + def _send_request_signature(self, async_mode: bool) -> str: + return utils.serialize_method( + function_def="def", + method_name=self.code_model.send_request_name, + is_in_class=True, + method_param_signatures=self.code_model.service_client.send_request_signature(async_mode), + ) + + def send_request_signature_and_response_type_annotation(self, async_mode: bool) -> str: + send_request_signature = self._send_request_signature(async_mode) + return utils.method_signature_and_response_type_annotation_template( + async_mode=async_mode, + method_signature=send_request_signature, + response_type_annotation="Awaitable[AsyncHttpResponse]" if async_mode else "HttpResponse", + ) + + def _request_builder_example(self, async_mode: bool) -> List[str]: + retval = [] + http_response = "AsyncHttpResponse" if async_mode else "HttpResponse" + request_builder = self.code_model.rest.request_builders[0] + request_builder_signature = ", ".join(request_builder.parameters.call) + if request_builder.operation_group_name: + rest_imported = request_builder.operation_group_name + request_builder_name = f"{request_builder.operation_group_name}.{request_builder.name}" + else: + rest_imported = request_builder.name + request_builder_name = request_builder.name + retval.append(f">>> from {self.code_model.namespace}.{self.code_model.rest_layer_name} import {rest_imported}") + retval.append(f">>> request = {request_builder_name}({request_builder_signature})") + retval.append(f"") + retval.append( + f">>> response = {'await ' if async_mode else ''}client.{self.code_model.send_request_name}(request)" + ) + retval.append(f"<{http_response}: 200 OK>") + return retval + + def send_request_description(self, async_mode: bool) -> List[str]: + retval = ['"""Runs the network request through the client\'s chained policies.'] + retval.append("") + retval.append( + f"We have helper methods to create requests specific to this service in `{self.code_model.namespace}.rest`." + ) + retval.append("Use these helper methods to create the request you pass to this method. See our example below:") + retval.append("") + retval.extend(self._request_builder_example(async_mode)) + retval.append("") + retval.append("For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart") + retval.append(f"") + retval.append(f"For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest`") + retval.append(f"and pass it in.") + retval.append("") + retval.append(":param request: The network request you want to make. Required.") + retval.append(f":type request: ~azure.core.rest.HttpRequest") + retval.append(":keyword bool stream: Whether the response payload will be streamed. Defaults to False.") + retval.append(":return: The response of your network call. Does not do error handling on your response.") + http_response = "AsyncHttpResponse" if async_mode else "HttpResponse" + retval.append(f":rtype: ~azure.core.rest.{http_response}") + retval.append('"""') + return retval diff --git a/autorest/codegen/serializers/general_serializer.py b/autorest/codegen/serializers/general_serializer.py index 55b181503b2..56723b9957b 100644 --- a/autorest/codegen/serializers/general_serializer.py +++ b/autorest/codegen/serializers/general_serializer.py @@ -6,7 +6,7 @@ from jinja2 import Environment from .import_serializer import FileImportSerializer, TypingSection from ..models import FileImport, ImportType, CodeModel, TokenCredentialSchema, ParameterList - +from .client_serializer import ClientSerializer def config_imports(code_model, global_parameters: ParameterList, async_mode: bool) -> FileImport: file_import = FileImport() @@ -43,11 +43,6 @@ def _correct_credential_parameter(self): credential_param.schema = TokenCredentialSchema(async_mode=self.async_mode) def serialize_service_client_file(self) -> str: - def _service_client_imports() -> FileImport: - file_import = self.code_model.service_client.imports(self.code_model, self.async_mode) - for gp in self.code_model.global_parameters: - file_import.merge(gp.imports()) - return file_import template = self.env.get_template("service_client.py.jinja2") @@ -60,8 +55,9 @@ def _service_client_imports() -> FileImport: return template.render( code_model=self.code_model, async_mode=self.async_mode, + serializer=ClientSerializer(self.code_model), imports=FileImportSerializer( - _service_client_imports(), + self.code_model.service_client.imports(self.async_mode), is_python_3_file=self.async_mode ), ) diff --git a/autorest/codegen/serializers/metadata_serializer.py b/autorest/codegen/serializers/metadata_serializer.py index f713a516324..40b0a094beb 100644 --- a/autorest/codegen/serializers/metadata_serializer.py +++ b/autorest/codegen/serializers/metadata_serializer.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +import functools import copy import json from typing import List, Optional, Set, Tuple, Dict, Union @@ -17,20 +18,19 @@ TokenCredentialSchema, ParameterList, TypingSection, - ImportType + ImportType, + GlobalParameterList, ) +from .builder_serializer import get_operation_serializer + def _correct_credential_parameter(global_parameters: ParameterList, async_mode: bool) -> None: - credential_param = [ - gp for gp in global_parameters.parameters if isinstance(gp.schema, TokenCredentialSchema) - ][0] + credential_param = [gp for gp in global_parameters.parameters if isinstance(gp.schema, TokenCredentialSchema)][0] credential_param.schema = TokenCredentialSchema(async_mode=async_mode) + def _json_serialize_imports( - imports: Dict[ - TypingSection, - Dict[ImportType, Dict[str, Set[Optional[Union[str, Tuple[str, str]]]]]] - ] + imports: Dict[TypingSection, Dict[ImportType, Dict[str, Set[Optional[Union[str, Tuple[str, str]]]]]]] ): if not imports: return None @@ -54,15 +54,17 @@ def _json_serialize_imports( json_serialize_imports[typing_section_key] = json_import_type_dictionary return json.dumps(json_serialize_imports) + def _mixin_imports(mixin_operation_group: Optional[OperationGroup]) -> Tuple[Optional[str], Optional[str]]: if not mixin_operation_group: return None, None - sync_mixin_imports = mixin_operation_group.imports(async_mode=False, has_schemas=False) - async_mixin_imports = mixin_operation_group.imports(async_mode=True, has_schemas=False) + sync_mixin_imports = mixin_operation_group.imports_for_multiapi(async_mode=False) + async_mixin_imports = mixin_operation_group.imports_for_multiapi(async_mode=True) return _json_serialize_imports(sync_mixin_imports.imports), _json_serialize_imports(async_mixin_imports.imports) + class MetadataSerializer: def __init__(self, code_model: CodeModel, env: Environment) -> None: self.code_model = code_model @@ -78,7 +80,7 @@ def _choose_api_version(self) -> Tuple[str, List[str]]: total_api_version_list.sort() # switching ' to " so json can decode the dict we end up writing to file - total_api_version_list = [str(api_version).replace("'", "\"") for api_version in total_api_version_list] + total_api_version_list = [str(api_version).replace("'", '"') for api_version in total_api_version_list] if len(total_api_version_list) == 1: chosen_version = total_api_version_list[0] elif len(total_api_version_list) > 1: @@ -89,16 +91,13 @@ def _choose_api_version(self) -> Tuple[str, List[str]]: return chosen_version, total_api_version_list - def _make_async_copy_of_global_parameters(self) -> ParameterList: + def _make_async_copy_of_global_parameters(self) -> GlobalParameterList: global_parameters = copy.deepcopy(self.code_model.global_parameters) _correct_credential_parameter(global_parameters, True) return global_parameters def _service_client_imports( - self, - global_parameters: ParameterList, - mixin_operation_group: Optional[OperationGroup], - async_mode: bool + self, global_parameters: ParameterList, mixin_operation_group: Optional[OperationGroup], async_mode: bool ) -> str: file_import = FileImport() for gp in global_parameters: @@ -115,11 +114,9 @@ def _service_client_imports( file_import.add_from_import( "._operations_mixin", f"{self.code_model.class_name}OperationsMixin", ImportType.LOCAL ) - - file_import.merge(self.code_model.service_client.imports(self.code_model, async_mode=async_mode)) + file_import.merge(self.code_model.service_client.imports_for_multiapi(async_mode=async_mode)) return _json_serialize_imports(file_import.imports) - def serialize(self) -> str: def _is_lro(operation): return isinstance(operation, LROOperation) @@ -128,9 +125,12 @@ def _is_paging(operation): return isinstance(operation, PagingOperation) mixin_operation_group: Optional[OperationGroup] = next( - (operation_group - for operation_group in self.code_model.operation_groups if operation_group.is_empty_operation_group), - None + ( + operation_group + for operation_group in self.code_model.operation_groups + if operation_group.is_empty_operation_group + ), + None, ) mixin_operations = mixin_operation_group.operations if mixin_operation_group else [] sync_mixin_imports, async_mixin_imports = _mixin_imports(mixin_operation_group) @@ -160,9 +160,9 @@ def _is_paging(operation): template = self.env.get_template("metadata.json.jinja2") # setting to true, because for multiapi we always generate with a version file with version 0.1.0 - self.code_model.options['package_version'] = '0.1.0' - if self.code_model.options['azure_arm'] and not self.code_model.base_url: - self.code_model.base_url = 'https://management.azure.com' + self.code_model.options["package_version"] = "0.1.0" + if self.code_model.options["azure_arm"] and not self.code_model.service_client.base_url: + self.code_model.service_client.base_url = "https://management.azure.com" return template.render( chosen_version=chosen_version, total_api_version_list=total_api_version_list, @@ -183,5 +183,11 @@ def _is_paging(operation): ), async_config_imports=_json_serialize_imports( config_imports(self.code_model, async_global_parameters, async_mode=True).imports - ) + ), + get_async_operation_serializer=functools.partial( + get_operation_serializer, code_model=self.code_model, async_mode=True + ), + get_sync_operation_serializer=functools.partial( + get_operation_serializer, code_model=self.code_model, async_mode=False + ), ) diff --git a/autorest/codegen/serializers/operation_group_serializer.py b/autorest/codegen/serializers/operation_group_serializer.py index ba073a0043d..8f5d2ed740d 100644 --- a/autorest/codegen/serializers/operation_group_serializer.py +++ b/autorest/codegen/serializers/operation_group_serializer.py @@ -3,10 +3,12 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +import functools from jinja2 import Environment from .import_serializer import FileImportSerializer from ..models import LROOperation, PagingOperation, CodeModel, OperationGroup +from .builder_serializer import get_operation_serializer class OperationGroupSerializer: @@ -29,17 +31,17 @@ def _is_paging(operation): if self.operation_group.is_empty_operation_group: operation_group_template = self.env.get_template("operations_container_mixin.py.jinja2") + has_schemas = self.code_model.schemas or self.code_model.enums return operation_group_template.render( code_model=self.code_model, operation_group=self.operation_group, imports=FileImportSerializer( - self.operation_group.imports( - self.async_mode, - bool(self.code_model.schemas or self.code_model.enums) - ), - is_python_3_file=self.async_mode + self.operation_group.imports(self.async_mode, bool(has_schemas)), is_python_3_file=self.async_mode ), async_mode=self.async_mode, is_lro=_is_lro, is_paging=_is_paging, + get_operation_serializer=functools.partial( + get_operation_serializer, code_model=self.code_model, async_mode=self.async_mode + ), ) diff --git a/autorest/codegen/serializers/rest_serializer.py b/autorest/codegen/serializers/rest_serializer.py new file mode 100644 index 00000000000..419401ed80b --- /dev/null +++ b/autorest/codegen/serializers/rest_serializer.py @@ -0,0 +1,52 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import List +from jinja2 import Environment + +from ..models import RequestBuilder +from .import_serializer import FileImportSerializer +from ..models import CodeModel +from .builder_serializer import ( + RequestBuilderGenericSerializer, + RequestBuilderPython3Serializer, +) + + +class RestSerializer: + def __init__(self, code_model: CodeModel, env: Environment, request_builders: List[RequestBuilder]) -> None: + self.code_model = code_model + self.env = env + self.request_builders = request_builders + + def serialize_init(self) -> str: + template = self.env.get_template("rest_init.py.jinja2") + return template.render(code_model=self.code_model, request_builders=self.request_builders) + + +class RestPython3Serializer(RestSerializer): + def serialize_request_builders(self) -> str: + template = self.env.get_template("request_builders.py.jinja2") + + return template.render( + code_model=self.code_model, + request_builders=self.request_builders, + imports=FileImportSerializer(self.code_model.rest.imports(), is_python_3_file=True), + is_python_3_file=True, + request_builder_serializer=RequestBuilderPython3Serializer(self.code_model), + ) + + +class RestGenericSerializer(RestSerializer): + def serialize_request_builders(self) -> str: + template = self.env.get_template("request_builders.py.jinja2") + + return template.render( + code_model=self.code_model, + request_builders=self.request_builders, + imports=FileImportSerializer(self.code_model.rest.imports(), is_python_3_file=False), + is_python_3_file=False, + request_builder_serializer=RequestBuilderGenericSerializer(self.code_model), + ) diff --git a/autorest/codegen/serializers/utils.py b/autorest/codegen/serializers/utils.py new file mode 100644 index 00000000000..3d580997cdd --- /dev/null +++ b/autorest/codegen/serializers/utils.py @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import List + + +def serialize_method( + *, + function_def: str, + method_name: str, + is_in_class: bool, + method_param_signatures: List[str], +): + lines: List[str] = [] + lines.append(f"{function_def} {method_name}(") + if is_in_class: + lines.append(" self,") + lines.extend([ + (" " + line) + for line in method_param_signatures + ]) + lines.append(")") + return "\n".join(lines) + +def method_signature_and_response_type_annotation_template( + *, + async_mode: bool, + method_signature: str, + response_type_annotation: str, +) -> str: + if async_mode: + return f"{method_signature} -> {response_type_annotation}:" + return f"{method_signature}:\n # type: (...) -> {response_type_annotation}" diff --git a/autorest/codegen/templates/config.py.jinja2 b/autorest/codegen/templates/config.py.jinja2 index 92ed724657f..b5d5cd2184b 100644 --- a/autorest/codegen/templates/config.py.jinja2 +++ b/autorest/codegen/templates/config.py.jinja2 @@ -1,12 +1,11 @@ +{% import 'keywords.jinja2' as keywords with context %} {% set version_import = ".._version" if async_mode else "._version" %} -{% set async_prefix = "Async" if async_mode else "" %} {% macro method_signature() %} def __init__( self, {% for param_signature in code_model.global_parameters.method_signature(async_mode) %} {{ param_signature }} {% endfor %} - {{ "**kwargs: Any" if async_mode else "**kwargs # type: Any" }} ){{" -> None" if async_mode else "" }}:{% endmacro %} {# actual template starts here #} # coding=utf-8 @@ -27,8 +26,8 @@ class {{ code_model.class_name }}Configuration(Configuration): {% endif %} {% for parameter in code_model.global_parameters.method %} - :param {{ parameter.serialized_name }}: {{ parameter.description }} - :type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} + :{{ parameter.description_keyword }} {{ parameter.serialized_name }}: {{ parameter.description }} + :{{ parameter.docstring_type_keyword }} {{ parameter.serialized_name }}: {{ parameter.docstring_type }} {% endfor %} """ @@ -68,9 +67,9 @@ class {{ code_model.class_name }}Configuration(Configuration): 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 {{ "ARM" if code_model.options['azure_arm'] else "policies." }}HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.{{ async_prefix }}RetryPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.{{ keywords.async_class }}RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.{{ async_prefix }}RedirectPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.{{ keywords.async_class }}RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') {% if code_model.options['credential'] %} {# only adding this if credential_scopes is not passed during code generation #} diff --git a/autorest/codegen/templates/keywords.jinja2 b/autorest/codegen/templates/keywords.jinja2 index bc89d81436f..81ed939ecc2 100644 --- a/autorest/codegen/templates/keywords.jinja2 +++ b/autorest/codegen/templates/keywords.jinja2 @@ -2,4 +2,5 @@ {% set async_prefix = "a" if async_mode else "" %} {% set await = "await " if async_mode else "" %} {% set async_class = "Async" if async_mode else "" %} -{% macro escape_str(s) %}'{{ s|replace("'", "\\'") }}'{% endmacro %} \ No newline at end of file +{% macro escape_str(s) %}'{{ s|replace("'", "\\'") }}'{% endmacro %} +{% set kwargs_declaration = "**kwargs: Any" if async_mode else "**kwargs # type: Any" %} \ No newline at end of file diff --git a/autorest/codegen/templates/lro_operation.py.jinja2 b/autorest/codegen/templates/lro_operation.py.jinja2 index 5ea3899578d..877a3b9321a 100644 --- a/autorest/codegen/templates/lro_operation.py.jinja2 +++ b/autorest/codegen/templates/lro_operation.py.jinja2 @@ -1,17 +1,9 @@ -{% import 'operation_tools.jinja2' as op_tools %} -{% import 'lro_operation_helper.jinja2' as helper %} +{% import 'operation_tools.jinja2' as op_tools with context %} +{% import 'lro_operation_helper.jinja2' as helper with context %} {% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %} -{% set operation_name = "begin_"+operation.python_name %} {% macro return_docstring(async_mode) %} :return: An instance of {{ operation.get_poller(async_mode) }} that returns either {{ operation.responses[0].docstring_text }} or the result of cls(response) :rtype: ~{{ operation.get_poller_path(async_mode)}}[{{ operation.responses[0].docstring_type }}]{% endmacro %} -{% macro response_headers(response) %} -response_headers = { - {% for response_header in response.headers %} - '{{ response_header.name }}': self._deserialize('{{ response_header.serialization_type }}', response.headers.get('{{ response_header.name }}')), - {% endfor %} -} -{% endmacro %} {% macro operation_docstring(async_mode) %} {{ helper.operation_docstring_helper(code_model, operation, async_mode) }} {{ return_docstring(async_mode) }} @@ -21,21 +13,18 @@ response_headers = { {% if code_model.options['tracing'] %} {{ trace_decorator }} {% endif %} -{% set return_type_wrapper = [operation.get_poller(async_mode)] %} -{{ op_tools.method_signature(operation, operation_name, async_mode=async_mode, coroutine=async_mode, return_type_wrapper=return_type_wrapper) }} -{%- if not async_mode %} - {{ op_tools.sync_return_type_annotation(operation, return_type_wrapper) }} -{% endif %} - {{ operation_docstring(async_mode) | indent }} -{{ helper.lro_operation(code_model, operation, async_mode) }} - +{{ operation_serializer.method_signature_and_response_type_annotation(operation) }} + {{ op_tools.description(operation, operation_serializer) | indent }}{{ helper.lro_operation() }} + {% if operation.parameters.kwargs_to_pop(async_mode) %} + {{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }} + {% endif %} def get_long_running_output(pipeline_response): {% if operation.lro_response.has_headers %} response_headers = {} - response = pipeline_response.http_response {% endif %} {% if operation.lro_response %} - {{ op_tools.response_handling(operation.lro_response)|indent(8) }} + response = pipeline_response.http_response + {{ op_tools.response_headers_and_deserialization(operation.lro_response, code_model)|indent(8) }} {% endif %} if cls: return cls(pipeline_response, {{ 'deserialized' if operation.lro_response.has_body else 'None'}}, {{ 'response_headers' if operation.lro_response.has_headers else '{}' }}) @@ -43,4 +32,4 @@ response_headers = { return deserialized {% endif %} -{{ helper.lro_operation_return(code_model, operation, async_mode) }} \ No newline at end of file +{{ helper.lro_operation_return() }} diff --git a/autorest/codegen/templates/lro_operation_helper.jinja2 b/autorest/codegen/templates/lro_operation_helper.jinja2 index 63f70eda569..d565d8de142 100644 --- a/autorest/codegen/templates/lro_operation_helper.jinja2 +++ b/autorest/codegen/templates/lro_operation_helper.jinja2 @@ -1,49 +1,15 @@ {% import 'operation_tools.jinja2' as op_tools %} - -{% macro param_documentation_string(parameter) %}:param {{ parameter.serialized_name }}: {{ parameter.description }}{% endmacro %} - -{% macro operation_docstring_helper(code_model, operation, async_mode) %} -{% import 'keywords.jinja2' as keywords with context %} -"""{{ operation.summary if operation.summary else operation.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n') }} -{% if operation.summary and operation.description %} - -{{ operation.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n') }} -{% endif %} - -{% if operation.deprecated -%} -.. warning:: - This method is deprecated - -{% endif -%} -{% for parameter in operation.parameters.method %} -{%- for doc_string in param_documentation_string(parameter).replace('\n', '\n ').split('\n') %} -{{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ')}} -{% endfor %} -:type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} -{% endfor %} -{% if (operation.requests | length) > 1 %} -{{ op_tools.content_type_docstring(operation) }} -{% endif %} -:keyword callable cls: A custom type or function that will be passed the direct response -:keyword str continuation_token: A continuation token to restart a poller from a saved state. -:keyword polling: By default, your polling method will be {{ operation.get_default_polling_method(async_mode, code_model.options["azure_arm"]) }}. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. -:paramtype polling: bool or ~azure.core.polling.{{ keywords.async_class }}PollingMethod -:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. -{%- endmacro -%} - - -{% macro lro_operation(code_model, operation, async_mode) %} {% import 'keywords.jinja2' as keywords with context %} +{% macro lro_operation() %} polling = kwargs.pop('polling', True) # type: Union[bool, {{ keywords.async_class }}PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[{{ op_tools.return_type_annotation(operation) }}] + cls = kwargs.pop('cls', None) {{ operation_serializer.cls_type_annotation(operation) }} lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = {{ keywords.await }}self._{{ operation.name }}_initial( + raw_result = {{ keywords.await }}self.{{ operation.initial_operation.name }}( {% for parameter in operation.parameters.method %} {{ parameter.serialized_name }}={{ parameter.serialized_name }}, {% endfor %} @@ -55,11 +21,11 @@ kwargs.pop('content_type', None) {%- endmacro -%} - {% macro lro_operation_return(code_model, operation, async_mode) %} + {% macro lro_operation_return() %} {% import 'keywords.jinja2' as keywords with context %} + {% set request_builder = operation.request_builder %} {% set path_format_arguments = "" %} {% set lro_options = (", lro_options={'final-state-via': '"+ operation.lro_options['final-state-via'] + "'}") if operation.lro_options else "" %} - {% set operation_name = "begin_"+operation.python_name %} {% if operation.parameters.path %} {% set path_format_arguments = ", path_format_arguments=path_format_arguments" %} {% if operation.parameters.path|selectattr("constant") %} @@ -82,5 +48,5 @@ ) else: return {{ operation.get_poller(async_mode) }}(self._client, raw_result, get_long_running_output, polling_method) -{{ operation_name }}.metadata = {'url': '{{ operation.url }}'} # type: ignore -{%- endmacro -%} \ No newline at end of file +{{ operation.python_name }}.metadata = {'url': '{{ request_builder.url }}'} # type: ignore +{%- endmacro -%} diff --git a/autorest/codegen/templates/lro_paging_operation.py.jinja2 b/autorest/codegen/templates/lro_paging_operation.py.jinja2 index b43b5b2ad67..a61e3c06f94 100644 --- a/autorest/codegen/templates/lro_paging_operation.py.jinja2 +++ b/autorest/codegen/templates/lro_paging_operation.py.jinja2 @@ -1,30 +1,16 @@ -{% import 'operation_tools.jinja2' as op_tools %} +{% import 'operation_tools.jinja2' as op_tools with context %} {% import 'keywords.jinja2' as keywords with context %} -{% import 'lro_operation_helper.jinja2' as lro_helper %} -{% import 'paging_operation_helper.jinja2' as paging_helper %} +{% import 'lro_operation_helper.jinja2' as lro_helper with context %} +{% import 'paging_operation_helper.jinja2' as paging_helper with context %} {% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %} -{% set operation_name = "begin_"+operation.python_name %} -{% macro return_docstring(async_mode) %} -:return: An instance of {{ operation.get_poller(async_mode) }} that returns an iterator like instance of either {{ operation.responses[0].docstring_text }} or the result of cls(response) -:rtype: ~{{ operation.get_poller_path(async_mode) }}[~{{ operation.get_pager_path(async_mode) }}[{{ operation.responses[0].docstring_type }}]]{% endmacro %} -{% macro operation_docstring(async_mode) %} -{{ lro_helper.operation_docstring_helper(code_model, operation, async_mode) }} -{{ return_docstring(async_mode) }} -:raises ~azure.core.exceptions.HttpResponseError: -"""{% endmacro %} {# actual template starts here #} {% if code_model.options['tracing'] %} {{ trace_decorator }} {% endif %} -{% set return_type_wrapper = [operation.get_poller(async_mode), operation.get_pager(async_mode)] %} -{{ op_tools.method_signature(operation, operation_name, async_mode=async_mode, coroutine=async_mode, return_type_wrapper=return_type_wrapper) }} -{%- if not async_mode %} - {{ op_tools.sync_return_type_annotation(operation, return_type_wrapper) }} -{% endif %} - {{ operation_docstring(async_mode) | indent }} - {{ paging_helper.paging_operation(code_model, operation, async_mode) }} +{{ operation_serializer.method_signature_and_response_type_annotation(operation) }} + {{ op_tools.description(operation, operation_serializer) | indent }} {{ paging_helper.paging_operation() }} -{{ lro_helper.lro_operation(code_model, operation, async_mode) }} +{{ lro_helper.lro_operation() }} def get_long_running_output(pipeline_response): {{ keywords.def }} internal_get_next(next_link=None): if next_link is None: @@ -35,4 +21,4 @@ return {{ operation.get_pager(async_mode) }}( internal_get_next, extract_data ) -{{ lro_helper.lro_operation_return(code_model, operation, async_mode) }} \ No newline at end of file +{{ lro_helper.lro_operation_return() }} diff --git a/autorest/codegen/templates/metadata.json.jinja2 b/autorest/codegen/templates/metadata.json.jinja2 index 94f5bda2663..eaf4be01496 100644 --- a/autorest/codegen/templates/metadata.json.jinja2 +++ b/autorest/codegen/templates/metadata.json.jinja2 @@ -7,8 +7,8 @@ "name": {{ code_model.class_name | tojson }}, "filename": {{ ("_" + code_model.module_name) | tojson }}, "description": {{ code_model.description | tojson }}, - "base_url": {{ (keywords.escape_str(code_model.base_url) if code_model.base_url else None) | tojson }}, - "custom_base_url": {{ (keywords.escape_str(code_model.custom_base_url) if code_model.custom_base_url else None) | tojson }}, + "base_url": {{ (keywords.escape_str(code_model.service_client.base_url) if code_model.service_client.base_url else None) | tojson }}, + "custom_base_url": {{ (keywords.escape_str(code_model.service_client.custom_base_url) if code_model.service_client.custom_base_url else None) | tojson }}, "azure_arm": {{ code_model.options["azure_arm"] | tojson }}, "has_lro_operations": {{ code_model.has_lro_operations | tojson }}, "client_side_validation": {{ code_model.options["client_side_validation"] | tojson }}, @@ -19,7 +19,7 @@ "sync": { {% for gp in sync_global_parameters.method %} {{ gp.serialized_name | tojson }}: { - "signature": {{ gp.method_signature(False) | tojson }}, + "signature": {{ gp.method_signature(async_mode=False) | tojson }}, "description": {{ gp.description | tojson }}, "docstring_type": {{ gp.docstring_type | tojson }}, "required": {{ gp.required | tojson }} @@ -29,7 +29,7 @@ "async": { {% for gp in async_global_parameters.method %} {{ gp.serialized_name | tojson }}: { - "signature": {{ (gp.method_signature(True)) | tojson }}, + "signature": {{ (gp.method_signature(async_mode=True)) | tojson }}, "description": {{ gp.description | tojson }}, "docstring_type": {{ gp.docstring_type | tojson }}, "required": {{ gp.required | tojson }} @@ -50,7 +50,7 @@ "docstring_type": "str", "required": false }, - {% if not code_model.custom_base_url %} + {% if not code_model.service_client.custom_base_url %} "base_url": { "signature": {{ code_model.base_url_method_signature(False) | tojson }}, "description": "Service URL", @@ -72,7 +72,7 @@ "docstring_type": "str", "required": false }, - {% if not code_model.custom_base_url %} + {% if not code_model.service_client.custom_base_url %} "base_url": { "signature": {{ code_model.base_url_method_signature(True) | tojson }}, "description": "Service URL", @@ -108,9 +108,10 @@ "async_imports": {{ str(async_mixin_imports) | tojson }}, "operations": { {% for operation in mixin_operations %} - {% set operation_name = "begin_" + operation.name if is_lro(operation) else operation.name %} - {{ operation_name | tojson }} : { + {{ operation.python_name | tojson }} : { + {% set request_builder = operation.request_builder %} "sync": { + {% set operation_serializer = get_sync_operation_serializer(operation) %} {% if is_lro(operation) and is_paging(operation) %} {% from "lro_paging_operation.py.jinja2" import operation_docstring with context %} {% set sync_return_type_wrapper = [operation.get_poller(async_mode=False), operation.get_pager(async_mode=False)] %} @@ -124,11 +125,12 @@ {% from "operation.py.jinja2" import operation_docstring with context %} {% set sync_return_type_wrapper = "" %} {% endif %} - "signature": {{ op_tools.method_signature(operation, operation_name, False, False, sync_return_type_wrapper) | tojson }}, - "doc": {{ operation_docstring(async_mode=False) | tojson }} + "signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation) + "\n") | tojson }}, + "doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }} }, "async": { - {% set coroutine = False if is_paging(operation) else True %} + {% set coroutine = False if (is_paging(operation) and not is_lro(operation)) else True %} + {% set operation_serializer = get_async_operation_serializer(operation) %} "coroutine": {{ coroutine | tojson }}, {% if is_lro(operation) and is_paging(operation) %} {% from "lro_paging_operation.py.jinja2" import operation_docstring with context %} @@ -143,8 +145,8 @@ {% from "operation.py.jinja2" import operation_docstring with context %} {% set async_return_type_wrapper = "" %} {% endif %} - "signature": {{ op_tools.method_signature(operation, operation_name, True, coroutine, async_return_type_wrapper) | tojson }}, - "doc": {{ operation_docstring(async_mode=True) | tojson }} + "signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation) + "\n") | tojson }}, + "doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }} }, "call": {{ operation.parameters.method | map(attribute="serialized_name") | join(', ') | tojson }} }{{ "," if not loop.last else "" }} diff --git a/autorest/codegen/templates/operation.py.jinja2 b/autorest/codegen/templates/operation.py.jinja2 index 97f2695caed..bbae684bbca 100644 --- a/autorest/codegen/templates/operation.py.jinja2 +++ b/autorest/codegen/templates/operation.py.jinja2 @@ -2,136 +2,22 @@ {% import 'operation_tools.jinja2' as op_tools %} {% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %} {% set stream_request_parameter = "stream=" ~ ("True" if operation.is_stream_response else "False") %} -{# return_type is a variable that holds the return type if we already know what it is #} -{% set return_type = "bool" if operation.method == 'head' and code_model.options['head_as_boolean'] else None %} -{% macro param_documentation_string(parameter) %}:param {{ parameter.serialized_name }}: {{ parameter.description }}{% endmacro %} -{% macro return_docstring(async_mode, return_type=None) %} -{%- if return_type -%} -:return: {{ return_type }}, or the result of cls(response) -:rtype: {{ return_type }} -{%- else -%} - {% if operation.responses | selectattr('has_body') | first %} -:return: {{ operation.responses|selectattr('has_body')|map(attribute='docstring_text')|unique|join(' or ') }}, or the result of cls(response) -:rtype: {{ operation.responses|selectattr('has_body')| map(attribute='docstring_type')|unique|join(' or ') }}{{ " or None" if operation.has_optional_return_type }} - {%- else %} -:return: None, or the result of cls(response) -:rtype: None - {%- endif -%} -{%- endif -%} -{% endmacro %} -{% macro operation_docstring(async_mode, return_type=None) %} -"""{{ operation.summary if operation.summary else operation.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n') }} -{% if operation.summary and operation.description %} - -{{ operation.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n') }} -{% endif %} - -{% if operation.deprecated -%} -.. warning:: - This method is deprecated - -{% endif -%} -{% for parameter in operation.parameters.method %} -{%- for doc_string in param_documentation_string(parameter).replace('\n', '\n ').split('\n') %} -{{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ')}} -{% endfor %} -:type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} -{% endfor %} -{% if (operation.requests | length) > 1 %} -{{ op_tools.content_type_docstring(operation) }} -{% endif %} -:keyword callable cls: A custom type or function that will be passed the direct response -{{ return_docstring(async_mode, return_type=return_type) }} -:raises: ~azure.core.exceptions.HttpResponseError -"""{% endmacro %} {# actual template starts here #} {%- if code_model.options['tracing'] and operation.want_tracing -%} {{ trace_decorator }} {% endif %} -{{ op_tools.method_signature(operation, operation.python_name, async_mode=async_mode, coroutine=async_mode, return_type_wrapper="", return_type=return_type) }} -{%- if not async_mode %} - {{ op_tools.sync_return_type_annotation(operation, "", return_type=return_type) }} -{% endif %} +{{ operation_serializer.method_signature_and_response_type_annotation(operation) }} {% if operation.want_description_docstring %} - {{ operation_docstring(async_mode, return_type=return_type)|indent }} -{% endif %} - cls = kwargs.pop('cls', None) # type: {{ op_tools.return_type_annotation(operation, ["ClsType"]) }} + {{ op_tools.description(operation, operation_serializer) | indent }}{% endif %} + cls = kwargs.pop('cls', None) {{ operation_serializer.cls_type_annotation(operation) }} {% if operation.deprecated %} warnings.warn('Method {{operation.name}} is deprecated', DeprecationWarning) {% endif %} {{ op_tools.error_map(operation, code_model)|indent }} -{% if operation.parameters.grouped %} - {{ op_tools.grouped_parameters(operation)|indent }} -{%- endif -%} -{% if operation.parameters.is_flattened %} - - {{ operation.parameters.build_flattened_object() }} -{% endif %} -{% if operation.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") %} - {% for constant_parameter in operation.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") %} - {% if constant_parameter.is_kwarg and constant_parameter.rest_api_name == "Content-Type" %} - {{ constant_parameter.serialized_name }} = kwargs.pop("content_type", {{ constant_parameter.constant_declaration }}) - {% else %} - {{ constant_parameter.serialized_name }} = {{ constant_parameter.constant_declaration }} - {% endif %} - {% endfor %} -{% endif %} - -{% if operation.parameters.has_body %} - {% set content_type_parameter = operation.parameters.content_type_parameter %} - {% if not content_type_parameter.constant %} - {{ content_type_parameter.serialized_name }} = kwargs.pop("content_type", {{ content_type_parameter.schema.default_value_declaration }}) + {% if operation.parameters.kwargs_to_pop(async_mode) %} + {{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }} {% endif %} -{% endif %} - # Construct URL - url = self.{{ operation.python_name }}.metadata['url'] # type: ignore -{% if operation.parameters.path %} - {{ op_tools.path_format_arguments(operation.parameters.path)|indent }} - {{ op_tools.format_path_format_arguments()|indent }} -{% endif %} - - {{ op_tools.query_parameters(operation, async_mode)|indent }} - {{ op_tools.header_parameters(code_model, operation, async_mode)|indent }} - {{ op_tools.body_parameters(operation)|indent }} - pipeline_response = {{ keywords.await }}self._client._pipeline.run(request, {{ stream_request_parameter }}, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in {{ operation.success_status_code|string() }}: - map_error(status_code=response.status_code, response=response, error_map=error_map) - {% if operation.default_exception %} - error = self._deserialize.failsafe_deserialize({{ operation.default_exception }}, response) - {% endif %} - raise HttpResponseError(response=response{{ ", model=error" if operation.default_exception else "" }}{{ ", error_format=ARMErrorFormat" if code_model.options['azure_arm'] else "" }}) - -{% if operation.any_response_has_headers %} - response_headers = {} -{% endif %} -{# now we only initialize deserialized to None if we know there is both > 1 response with body and > 1 response of None #} -{# otherwise, we know that deserialized will be set to a value then returned #} -{% if operation.has_optional_return_type %} - deserialized = None -{% endif %} -{% if operation.has_response_body or operation.any_response_has_headers %} - {% if operation.responses|count > 1 %} - {% for status_code in operation.success_status_code %} - {% set response = operation.get_response_from_status(status_code) %} - {% if response.headers or response.has_body %} - if response.status_code == {{ status_code }}: - {{ op_tools.response_handling(response)|indent(8) }} - {% endif %} - {% endfor %} - {% else %} - {% set response = operation.responses[0] %} - {{ op_tools.response_handling(response)|indent }} - {% endif %} -{% endif %} - if cls: - return cls(pipeline_response, {{ 'deserialized' if operation.has_response_body else 'None'}}, {{ 'response_headers' if operation.any_response_has_headers else '{}' }}) - -{% if operation.has_response_body %} - return deserialized -{% endif %} -{% if operation.method == 'head' and code_model.options['head_as_boolean'] %} - return 200 <= response.status_code <= 299 -{% endif %} -{{ operation.python_name }}.metadata = {'url': {{ keywords.escape_str(operation.url) }}} # type: ignore \ No newline at end of file + {{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent }} + pipeline_response = {{ keywords.await }}self._client.send_request(request, {{ stream_request_parameter }}, _return_pipeline_response=True, **kwargs) + {{ op_tools.handle_response(code_model, operation) | indent }} +{{ operation.python_name }}.metadata = {'url': {{ keywords.escape_str(request_builder.url) }}} # type: ignore diff --git a/autorest/codegen/templates/operation_tools.jinja2 b/autorest/codegen/templates/operation_tools.jinja2 index dea43a108d8..8980baa1bd9 100644 --- a/autorest/codegen/templates/operation_tools.jinja2 +++ b/autorest/codegen/templates/operation_tools.jinja2 @@ -1,33 +1,35 @@ -{% macro return_type_annotation(operation, return_type_wrapper, return_type=None) %} -{%- if return_type -%} -{{ return_type }} -{%- else -%} -{{ ((return_type_wrapper | join("[") + "[") if return_type_wrapper else "") ~ ("Optional[" if operation.has_optional_return_type else "" ) ~ ("Union[" if operation.responses | selectattr('has_body') | map(attribute='operation_type_annotation') | unique | list | length > 1 else "") ~ -(operation.responses | selectattr('has_body') | map(attribute='operation_type_annotation') | unique | join(', ')) ~ -("]" if operation.responses | selectattr('has_body') | map(attribute='operation_type_annotation')| unique | list | length > 1 else "") ~ ("]" if operation.has_optional_return_type else "") ~ ( ("]" * return_type_wrapper | count ) if return_type_wrapper else "") -if operation.responses | selectattr('has_body') | first -else ((return_type_wrapper | join("[") + "[") if return_type_wrapper else "") ~ ("Optional[" if operation.has_optional_return_type else "" ) ~ "None" ~ ("]" if operation.has_optional_return_type else "") ~ ( ("]" * return_type_wrapper | count ) if return_type_wrapper else "") }}{%- endif -%}{% endmacro %} -{# get async mypy typing #} -{% macro async_return_type_annotation(operation, return_type_wrapper, return_type=None) %} -{{ " -> " + return_type_annotation(operation, return_type_wrapper, return_type) }}{% endmacro %} -{# get sync mypy typing #} -{% macro sync_return_type_annotation(operation, return_type_wrapper, return_type=None) %} -{{ "# type: (...) -> " + return_type_annotation(operation, return_type_wrapper, return_type) }}{% endmacro %} -{# get method signature #} -{% macro method_signature(operation, operation_name, async_mode, coroutine, return_type_wrapper, return_type=None) %} -{{ "async " if coroutine else "" }}def {{ operation_name }}( - self, -{% for param_signature in operation.parameters.method_signature(async_mode) %} - {{ param_signature }} +{% macro wrap_string(string, wrapstring) %}{{ string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrapstring)}}{% endmacro %} + +{% macro description(builder, serializer) %} + {% for description in serializer.description_and_summary(builder) %} + {% if description %} +{% set description = wrap_string(description, wrapstring='\n') %} +{{ '"""' + description if loop.first else description }} + {% else %} + + {% endif %} + {% endfor %} + {% for description in serializer.param_description_and_response_docstring(builder) %} + {% if description %} +{{ wrap_string(description, wrapstring='\n ') }} + {% else %} + + {% endif %} {% endfor %} - {{ "**kwargs: Any" if async_mode else "**kwargs # type: Any" }} -){{ async_return_type_annotation(operation, return_type_wrapper, return_type) if async_mode }}: -{% endmacro %} +{% if serializer.want_example_template(builder) %} -{# content type docstring #} -{% macro content_type_docstring(operation) %} -:keyword str content_type: Media type of the body sent to the API. Default value is {{ operation.parameters.content_type }}. - Allowed values are: "{{ operation.requests | map(attribute="media_types") | sum(start = []) | unique | list | join ('", "') }}".{% endmacro %} +Example: + .. code-block:: python + {% for template_line in serializer.get_example_template(builder) %} + {% if template_line %} + {{ template_line }} + {% else %} + + {% endif %} + {% endfor %} +{% endif %} +""" +{% endmacro %} {# error map handling #} {% macro error_map(operation, code_model) %} @@ -68,61 +70,48 @@ error_map = { } {% endif %} error_map.update(kwargs.pop('error_map', {})){%- endmacro -%} -{% macro response_handling(response) %} - {% if response.headers %} - {% for response_header in response.headers %} + +{% macro response_headers(response) %} +{% for response_header in response.headers %} response_headers['{{ response_header.name }}']=self._deserialize('{{ response_header.serialization_type }}', response.headers.get('{{ response_header.name }}')) - {% endfor %} - {% endif %} - {% if response.is_stream_response %} +{% endfor %}{% endmacro %} + +{% macro response_headers_and_deserialization(response, code_model) %} +{% if response.headers %} +{{ response_headers(response) }} + {% endif %} + {% if response.is_stream_response %} deserialized = response.stream_download(self._client._pipeline) - {% elif response.has_body %} + {% elif response.has_body %} deserialized = self._deserialize('{{ response.serialization_type }}', pipeline_response) - {% endif %} + {% endif %} {% endmacro %} -{# write grouped parameters #} -{% macro grouped_parameters(operation) %} -{% if operation.parameters.grouped %} - {% for grouped_parameter in operation.parameters.grouped %} -{{ grouped_parameter.serialized_name }} = None - {% endfor %} - {% for grouper_name, grouped_parameters in operation.parameters.grouped|groupby("grouped_by.serialized_name") %} -if {{ grouper_name }} is not None: - {% for grouped_parameter in grouped_parameters %} - {{ grouped_parameter.serialized_name }} = {{ grouper_name }}.{{ grouped_parameter.corresponding_grouped_property.name }} - {% endfor %} - {% endfor %} -{% endif %} -{% endmacro %} {# write queryparameters #} -{% macro query_parameters(operation, async_mode) %} +{% macro query_parameters(request_builder, async_mode) %} # Construct parameters -query_parameters = {} # type: Dict[str, Any] -{% if operation.parameters.query %} - {% for query_parameter in operation.parameters.query %} - {%if query_parameter.required %} +query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] +{% for query_parameter in request_builder.parameters.query %} + {%if query_parameter.required %} query_parameters['{{ query_parameter.rest_api_name }}'] = {{ query_parameter.build_serialize_data_call("query") }} - {% else %} + {% else %} if {{ query_parameter.full_serialized_name }} is not None: query_parameters['{{ query_parameter.rest_api_name }}'] = {{ query_parameter.build_serialize_data_call("query") }} - {% endif %} - {% endfor %} -{% endif %}{% endmacro %} -{# write request headers #} -{% macro header_parameters(code_model, operation, async_mode) %} + {% endif %} +{% endfor %}{% endmacro %} + +{# write request_builder headers #} +{% macro header_parameters(code_model, request_builder, async_mode) %} # Construct headers -header_parameters = {} # type: Dict[str, Any] -{% if operation.parameters.headers %} - {% for header_parameter in operation.parameters.headers %} - {%if header_parameter.required %} +header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] +{% for header_parameter in request_builder.parameters.headers %} + {%if header_parameter.required %} header_parameters['{{ header_parameter.rest_api_name }}'] = {{ header_parameter.build_serialize_data_call("header") }} - {% else %} + {% else %} if {{ header_parameter.full_serialized_name }} is not None: header_parameters['{{ header_parameter.rest_api_name }}'] = {{ header_parameter.build_serialize_data_call("header") }} - {% endif %} - {% endfor %} -{% endif %}{% endmacro %} + {% endif %} +{% endfor %}{% endmacro %} {# path format arguments #} {% macro path_format_arguments(path_parameters) %} @@ -135,62 +124,127 @@ path_format_arguments = { {% macro format_path_format_arguments(url_name="url") %} {{ url_name }} = self._client.format_url({{ url_name }}, **path_format_arguments){% endmacro %} -{# helper for stream body params #} -{% macro stream_body_params(operation) %}body_content_kwargs['stream_content'] = {{ operation.parameters.body[0].serialized_name }}{% endmacro %} {# helper for non-stream body params with schema #} -{% macro non_stream_body_params(operation, send_xml, request_as_xml) %} +{% macro serialize_body(operation) %} +{% set send_xml = "xml" if operation.parameters.has_body and "xml" in operation.parameters.content_types %} {% set ser_ctxt = operation.parameters.body[0].xml_serialization_ctxt if send_xml else None %} +{% set body_is_xml = ", is_xml=True" if send_xml else "" %} {% if ser_ctxt %} serialization_ctxt = {'xml': {{ "{" }}{{ ser_ctxt }}{{ "}}" }} {% endif %} {% if operation.parameters.body[0].required %} -body_content = self._serialize.body({{ operation.parameters.body[0].serialized_name }}, '{{ operation.parameters.body[0].serialization_type }}'{{ request_as_xml }}{{ ", serialization_ctxt=serialization_ctxt" if ser_ctxt else "" }}) +{{ operation_serializer.body_serialization_str }} {% else %} if {{ operation.parameters.body[0].serialized_name }} is not None: - body_content = self._serialize.body({{ operation.parameters.body[0].serialized_name }}, '{{ operation.parameters.body[0].serialization_type }}'{{ request_as_xml }}{{ ", serialization_ctxt=serialization_ctxt" if ser_ctxt else "" }}) + {{ operation_serializer.body_serialization_str }} else: - body_content = None -{% endif %} -body_content_kwargs['content'] = body_content{% endmacro %} + json = None +{% endif %}{% endmacro %} + +{% macro set_body_content_kwarg(operation, schema_request) %} +{% if schema_request.is_stream_request %} +content = {{ operation.parameters.body[0].serialized_name }} +{% elif schema_request.body_parameter_has_schema and not operation.request_builder.multipart %} +{{ serialize_body(operation) }}{% endif %}{% endmacro %} + {# write body parameters #} -{% macro body_parameters(operation, http_verb=None) %} -{% set body_content_kwargs_signature = "" %} -{% set form_content_kwarg_signature = "" %} -{% if operation.multipart %} - {% set form_content_kwarg_signature = ", form_content=_form_content" %} -# Construct form data -_form_content = { - {% for param in operation.parameters.body %} - '{{ param.rest_api_name }}': {{ param.serialized_name }}, - {% endfor %} -} -{% else %} - {% set send_xml = "xml" if operation.parameters.has_body and "xml" in operation.parameters.content_type %} - {% set request_as_xml = ", is_xml=True" if send_xml else "" %} - {% if operation.parameters.has_body %} - {% set body_content_kwargs_signature = ", **body_content_kwargs" %} -body_content_kwargs = {} # type: Dict[str, Any] - {% if (operation.requests | length) == 1 %} - {% if operation.requests[0].is_stream_request %} -{{ stream_body_params(operation) }} - {% elif operation.requests[0].body_parameter_has_schema %} -{{ non_stream_body_params(operation, send_xml, request_as_xml) }} - {% endif %} - {% else %} - {% for request in operation.requests %} -{{ "el" if not loop.first }}if header_parameters['Content-Type'].split(";")[0] in {{ request.pre_semicolon_media_types }}: - {% if request.is_stream_request %} - {{ stream_body_params(operation)|indent }} - {% elif request.body_parameter_has_schema %} - {{ non_stream_body_params(request, send_xml, request_as_xml)|indent }} - {% endif %} +{% macro body_parameters(operation) %} +{% if operation.parameters.has_body %} + {% if (operation.request_builder.schema_requests | length) == 1 %} +{{ set_body_content_kwarg(operation, operation.request_builder.schema_requests[0]) }} + {% else %} +content = input + {% for schema_request in operation.request_builder.schema_requests | rejectattr("is_stream_request")%} +{{ "el" if not loop.first }}if content_type.split(";")[0] in {{ schema_request.pre_semicolon_media_types }}: + {{ set_body_content_kwarg(operation, schema_request)|indent }} + {% endfor %} +{% endif %}{% endif %}{% endmacro %} + +{# create HTTPRequest #} +{% macro create_http_request(request_builder, is_python_3_file) %} +return HttpRequest( + method="{{ request_builder.method }}", + url=url, + {% if request_builder.parameters.query %} + params=query_parameters, + {% endif %} + {% if request_builder.parameters.headers %} + headers=header_parameters, + {% endif %} + {% if request_builder.parameters.has_body %} + {% if is_python_3_file %} + {% for body_kwarg in request_builder.parameters.body_kwarg_names.keys() | list %} + {{ body_kwarg }}={{ body_kwarg }}, {% endfor %} -else: - raise ValueError( - "The content_type '{}' is not one of the allowed values: " - "{{ operation.requests | map(attribute="media_types") | sum(start = []) | unique | list }}".format(header_parameters['Content-Type']) - ) {% endif %} {% endif %} + **kwargs +) +{% endmacro %} + + +{% macro handle_error_response(code_model, operation) %} +if response.status_code not in {{ operation.success_status_code|string() }}: + map_error(status_code=response.status_code, response=response, error_map=error_map) + {% set error_model = "" %} + {% if operation.default_exception %} + error = self._deserialize.failsafe_deserialize({{ operation.default_exception }}, response) + {% set error_model = ", model=error" %} + {% endif %} + raise HttpResponseError(response=response{{ error_model }}{{ ", error_format=ARMErrorFormat" if code_model.options['azure_arm'] else "" }}){% endmacro %} + +{# deal with response #} +{% macro handle_response(code_model, operation) %} +response = pipeline_response.http_response + +{{ handle_error_response(code_model, operation) }} + +{# now we only initialize deserialized to None if we know there is both > 1 response with body and > 1 response of None #} +{# otherwise, we know that deserialized will be set to a value then returned #} +{% if operation.has_optional_return_type %} +deserialized = None +{% endif %} +{% if operation.any_response_has_headers %} +response_headers = {} +{% endif %} +{% if operation.has_response_body or operation.any_response_has_headers %} + {% if operation.responses|count > 1 %} + {% for status_code in operation.success_status_code %} + {% set response = operation.get_response_from_status(status_code) %} + {% if response.headers or response.has_body %} +if response.status_code == {{ status_code }}: + {{ response_headers_and_deserialization(response, code_model)|indent }} + {% endif %} + {% endfor %} + {% else %} + {% set response = operation.responses[0] %} +{{ response_headers_and_deserialization(response, code_model) }} + {% endif %} +{% endif %} +if cls: + return cls(pipeline_response, {{ 'deserialized' if operation.has_response_body else 'None'}}, {{ 'response_headers' if operation.any_response_has_headers else '{}' }}) +{% if operation.has_response_body %} + +return deserialized {% endif %} -request = self._client.{{ http_verb if http_verb else operation.method }}(url, query_parameters, header_parameters{{ form_content_kwarg_signature }}{{ body_content_kwargs_signature }}){% endmacro %} \ No newline at end of file +{% if operation.request_builder.method == 'HEAD' and code_model.options['head_as_boolean'] %} +return 200 <= response.status_code <= 299 +{% endif %}{% endmacro %} + +{% macro serialize(lines) %} +{% for line in lines %} + {% if line %} +{{ line }} + {% else %} + + {% endif %} +{% endfor %}{% endmacro %} + +{% macro serialize_with_wrap(lines, wrapstring) %} +{% for line in lines %} + {% if line %} +{{ wrap_string(line, wrapstring=wrapstring) }} + {% else %} + + {% endif %} +{% endfor %}{% endmacro %} diff --git a/autorest/codegen/templates/operations_container.py.jinja2 b/autorest/codegen/templates/operations_container.py.jinja2 index d19459e4887..7b999ea3125 100644 --- a/autorest/codegen/templates/operations_container.py.jinja2 +++ b/autorest/codegen/templates/operations_container.py.jinja2 @@ -35,14 +35,16 @@ class {{ operation_group.class_name }}{{ object_base_class }}: self._config = config {% for operation in operation_group.operations %} +{% set request_builder = operation.request_builder %} +{% set operation_serializer = get_operation_serializer(operation) %} {% if is_lro(operation) and is_paging(operation) %} - {% macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %} + {%- macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %} {% elif is_lro(operation) %} - {% macro someop() %}{% include "lro_operation.py.jinja2" %}{% endmacro %} + {%- macro someop() %}{% include "lro_operation.py.jinja2" %}{% endmacro %} {% elif is_paging(operation) %} {% macro someop() %}{% include "paging_operation.py.jinja2" %}{% endmacro %} {% else %} {% macro someop() %}{% include "operation.py.jinja2" %}{% endmacro %} - {%- endif %} + {% endif %} {{ someop()|indent }} {% endfor %} \ No newline at end of file diff --git a/autorest/codegen/templates/operations_container_mixin.py.jinja2 b/autorest/codegen/templates/operations_container_mixin.py.jinja2 index cff9347387c..3cda42b6215 100644 --- a/autorest/codegen/templates/operations_container_mixin.py.jinja2 +++ b/autorest/codegen/templates/operations_container_mixin.py.jinja2 @@ -9,6 +9,8 @@ class {{ operation_group.class_name }}{{ object_base_class }}: {% for operation in operation_group.operations %} +{% set request_builder = operation.request_builder %} +{% set operation_serializer = get_operation_serializer(operation) %} {% if is_lro(operation) and is_paging(operation) %} {%- macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %} {% elif is_lro(operation) %} diff --git a/autorest/codegen/templates/paging_operation.py.jinja2 b/autorest/codegen/templates/paging_operation.py.jinja2 index e744670f7df..17f3a17279e 100644 --- a/autorest/codegen/templates/paging_operation.py.jinja2 +++ b/autorest/codegen/templates/paging_operation.py.jinja2 @@ -1,58 +1,24 @@ -{% import 'operation_tools.jinja2' as op_tools %} -{% import 'paging_operation_helper.jinja2' as helper %} -{% set send_xml = "xml" if operation.parameters.has_body and "xml" in operation.parameters.content_type %} +{% import 'operation_tools.jinja2' as op_tools with context %} +{% import 'paging_operation_helper.jinja2' as helper with context %} +{% set send_xml = "xml" if operation.parameters.has_body and "xml" in operation.request_content_type %} {% set request_as_xml = ", is_xml=True" if send_xml else "" %} -{% macro return_docstring(async_mode) %} -{% if operation.responses | selectattr('has_body') | first %} -:return: An iterator like instance of either {{ operation.responses|selectattr('has_body')|map(attribute='docstring_text')|unique|join(' or ') }} or the result of cls(response) -:rtype: ~{{ operation.get_pager_path(async_mode) }}[{% for response in operation.responses %}{{response.docstring_type if response.has_body else "None"}}{% if not loop.last -%} or {% endif %}{% endfor %}] -{%- else -%} -:return: None -:rtype: None{%- endif -%}{%- endmacro -%} -{% macro operation_docstring(async_mode) %} -"""{{ operation.summary if operation.summary else operation.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n') }} -{% if operation.summary and operation.description %} - -{{ operation.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n') }} -{% endif %} - -{% if operation.deprecated -%} -.. warning:: - This method is deprecated - -{% endif -%} -{% for parameter in operation.parameters.method %} -{%- for doc_string in param_documentation_string(parameter).replace('\n', '\n ').split('\n') %} -{{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ')}} -{% endfor %} -:type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} -{% endfor %} -{% if (operation.requests | length) > 1 %} -{{ op_tools.content_type_docstring(operation) }} -{% endif %} -:keyword callable cls: A custom type or function that will be passed the direct response -{{ return_docstring(async_mode) }} -:raises: ~azure.core.exceptions.HttpResponseError -"""{% endmacro %} {% macro param_documentation_string(parameter) %}:param {{ parameter.serialized_name }}: {{ parameter.description }}{% endmacro %} {# actual template starts here #} {% if code_model.options['tracing'] and operation.want_tracing %} @distributed_trace {% endif %} -{% set return_type_wrapper = ["AsyncIterable" if async_mode else "Iterable"] %} -{{ op_tools.method_signature(operation, operation.python_name, async_mode=async_mode, coroutine=False, return_type_wrapper=return_type_wrapper) }} -{%- if not async_mode %} - {{ op_tools.sync_return_type_annotation(operation, return_type_wrapper) }} -{% endif %} +{{ operation_serializer.method_signature_and_response_type_annotation(operation) }} {% if operation.want_description_docstring %} - {{ operation_docstring(async_mode) | indent }} -{% endif %} + {{ op_tools.description(operation, operation_serializer) | indent }}{% endif %} {% if operation.deprecated %} warnings.warn('Method {{operation.name}} is deprecated', DeprecationWarning) {% endif %} - {{ helper.paging_operation(code_model, operation, async_mode) }} + {% if operation.parameters.kwargs_to_pop(async_mode) %} + {{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }} + {% endif %} + {{ helper.paging_operation() }} return {{ operation.get_pager(async_mode) }}( get_next, extract_data ) -{{ operation.python_name }}.metadata = {'url': '{{ operation.url|replace("'", "\\'") }}'} # type: ignore \ No newline at end of file +{{ operation.python_name }}.metadata = {'url': '{{ request_builder.url|replace("'", "\\'") }}'} # type: ignore \ No newline at end of file diff --git a/autorest/codegen/templates/paging_operation_helper.jinja2 b/autorest/codegen/templates/paging_operation_helper.jinja2 index 969ad18cfe0..e527de4abb7 100644 --- a/autorest/codegen/templates/paging_operation_helper.jinja2 +++ b/autorest/codegen/templates/paging_operation_helper.jinja2 @@ -1,57 +1,31 @@ -{% import 'operation_tools.jinja2' as op_tools %} -{% macro paging_operation(code_model, operation, async_mode) %} +{% import 'operation_tools.jinja2' as op_tools with context %} +{% macro paging_operation() %} {% import 'keywords.jinja2' as keywords with context %} -{% set next_link_str = "deserialized." + operation.next_link_name + " or None" if operation.next_link_name else "None" %} {% set stream_request_parameter = "stream=" ~ ("True" if operation.is_stream_response else "False") %} -cls = kwargs.pop('cls', None) # type: ClsType[{{ op_tools.return_type_annotation(operation) }}] +{% set request_builder = operation.request_builder %} +cls = kwargs.pop('cls', None) {{ operation_serializer.cls_type_annotation(operation) }} {{ op_tools.error_map(operation, code_model)|indent }} -{% if operation.parameters.grouped %} - {{ op_tools.grouped_parameters(operation)|indent }} -{%- endif -%} -{% if operation.parameters.is_flattened %} - {{ operation.parameters.build_flattened_object() }} -{% endif %} -{% if operation.parameters.constant|selectattr("implementation", "equalto", "Method") %} - {% for constant_parameter in operation.parameters.constant|selectattr("implementation", "equalto", "Method") %} - {{ constant_parameter.serialized_name }} = {{ constant_parameter.constant_declaration }} - {% endfor %} -{% endif %} - def prepare_request(next_link=None): - {{ op_tools.header_parameters(code_model, operation, async_mode)|indent(8) }} if not next_link: - # Construct URL - url = self.{{ operation.python_name }}.metadata['url'] # type: ignore - {% if operation.parameters.path %} - {{ op_tools.path_format_arguments(operation.parameters.path)|indent(12) }} - {{ op_tools.format_path_format_arguments()|indent(12) }} - {% endif %} - {{ op_tools.query_parameters(operation, async_mode)|indent(12) }} - {{ op_tools.body_parameters(operation)|indent(12) }} + {{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent(12) }} else: -{% if operation.next_operation %} - url = '{{ operation.next_operation.url }}' - {% if operation.next_operation.parameters.path %} - {{ op_tools.path_format_arguments(operation.next_operation.parameters.path)|indent(12) }} - {{ op_tools.format_path_format_arguments()|indent(12) }} - {% endif %} - {{ op_tools.query_parameters(operation.next_operation, async_mode)|indent(12) }} - {{ op_tools.body_parameters(operation.next_operation)|indent(12) }} -{% else %} - url = next_link - query_parameters = {} # type: Dict[str, Any] - {% if operation.parameters.path and not code_model.base_url%} + {% set url = keywords.escape_str(operation.next_request_builder.url) if operation.next_request_builder else None %} + {{ op_tools.serialize(operation_serializer.call_next_link_request_builder(operation)) | indent(12) }} + {% if not operation.next_request_builder %} + {% if operation.parameters.path %} {{ op_tools.path_format_arguments(operation.parameters.path)|indent(12) }} - {{ op_tools.format_path_format_arguments()|indent(12) }} - {% endif %} - {{ op_tools.body_parameters(operation, http_verb="get")|indent(12) }} -{% endif %} + {% endif %} + request.method = "GET" + {% endif %} return request {{ keywords.def }} extract_data(pipeline_response): {% set response = operation.responses[0] %} - deserialized = self._deserialize('{{ response.serialization_type }}', pipeline_response) - list_of_elem = deserialized.{{ operation.item_name }} + {% set deserialized_str = "self._deserialize('" + response.serialization_type + "', pipeline_response)" %} + {% set list_of_elem_str = "deserialized." + operation.item_name %} + {% set next_link_str = "deserialized." + operation.next_link_name + " or None" if operation.next_link_name else "None" %} + deserialized = {{ deserialized_str }} + list_of_elem = {{ list_of_elem_str }} if cls: list_of_elem = cls(list_of_elem) {% if async_mode %} @@ -66,12 +40,7 @@ cls = kwargs.pop('cls', None) # type: ClsType[{{ op_tools.return_type_annotatio pipeline_response = {{ keywords.await }}self._client._pipeline.run(request, {{ stream_request_parameter }}, **kwargs) response = pipeline_response.http_response - if response.status_code not in {{ operation.success_status_code|string() }}: - {% if operation.default_exception %} - error = self._deserialize.failsafe_deserialize({{ operation.default_exception }}, response) - {% endif %} - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response{{ ", model=error" if operation.default_exception else "" }}{{ ", error_format=ARMErrorFormat" if code_model.options['azure_arm'] else "" }}) + {{ op_tools.handle_error_response(code_model, operation) | indent(12) }} return pipeline_response {%- endmacro -%} \ No newline at end of file diff --git a/autorest/codegen/templates/request_builder.py.jinja2 b/autorest/codegen/templates/request_builder.py.jinja2 new file mode 100644 index 00000000000..81e12432e51 --- /dev/null +++ b/autorest/codegen/templates/request_builder.py.jinja2 @@ -0,0 +1,26 @@ +{% import 'keywords.jinja2' as keywords with context %} +{% import 'operation_tools.jinja2' as op_tools with context %} +{{ request_builder_serializer.method_signature_and_response_type_annotation(request_builder) }} + {{ op_tools.description(request_builder, request_builder_serializer) | indent }} +{% if request_builder.parameters.kwargs_to_pop(is_python_3_file) %} + {{ op_tools.serialize(request_builder_serializer.pop_kwargs_from_signature(request_builder)) | indent }} +{% endif %} +{% if request_builder.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") %} + {% for constant_parameter in request_builder.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") %} + {{ constant_parameter.serialized_name }} = {{ constant_parameter.constant_declaration }} + {% endfor %} +{% endif %} + # Construct URL + url = kwargs.pop("template_url", {{ keywords.escape_str(request_builder.url) }}) +{% if request_builder.parameters.path %} + {{ op_tools.path_format_arguments(request_builder.parameters.path)|indent }} + url = _format_url_section(url, **path_format_arguments) +{% endif %} + +{% if request_builder.parameters.query %} + {{ op_tools.query_parameters(request_builder, is_python_3_file)|indent }} +{% endif %} +{% if request_builder.parameters.headers %} + {{ op_tools.header_parameters(code_model, request_builder, is_python_3_file)|indent }} +{% endif %} + {{ op_tools.create_http_request(request_builder, is_python_3_file)|indent }} diff --git a/autorest/codegen/templates/request_builders.py.jinja2 b/autorest/codegen/templates/request_builders.py.jinja2 new file mode 100644 index 00000000000..6f4dffed65e --- /dev/null +++ b/autorest/codegen/templates/request_builders.py.jinja2 @@ -0,0 +1,13 @@ +# coding=utf-8 +{{ code_model.options['license_header'] }} +{{ imports }} + +_SERIALIZER = Serializer() + +{% if not is_python_3_file %} +# fmt: off +{% endif %} +{% for request_builder in request_builders %} + +{% include "request_builder.py.jinja2" %} +{% endfor %} \ No newline at end of file diff --git a/autorest/codegen/templates/rest_init.py.jinja2 b/autorest/codegen/templates/rest_init.py.jinja2 new file mode 100644 index 00000000000..4ec028d4bbe --- /dev/null +++ b/autorest/codegen/templates/rest_init.py.jinja2 @@ -0,0 +1,17 @@ +# coding=utf-8 +{{ code_model.options['license_header'] }} + +try: + {% for request_builder in request_builders %} + from ._request_builders_py3 import {{ request_builder.name }} + {% endfor %} +except (SyntaxError, ImportError): + {% for request_builder in request_builders %} + from ._request_builders import {{ request_builder.name }} # type: ignore + {% endfor %} + +__all__ = [ + {% for request_builder in request_builders %} + '{{ request_builder.name }}', + {% endfor %} +] diff --git a/autorest/codegen/templates/service_client.py.jinja2 b/autorest/codegen/templates/service_client.py.jinja2 index 609e8f71054..a086b185da8 100644 --- a/autorest/codegen/templates/service_client.py.jinja2 +++ b/autorest/codegen/templates/service_client.py.jinja2 @@ -1,110 +1,38 @@ {% import 'keywords.jinja2' as keywords with context %} -{% set path_to_models = ".." if async_mode else "." %} {% import 'operation_tools.jinja2' as op_tools %} -{% macro method_signature() %} -def __init__( - self, - {% for param_signature in code_model.global_parameters.method_signature(async_mode) %} - {{ param_signature }} - {% endfor %} - {% if code_model.base_url %} - {{ code_model.base_url_method_signature(async_mode) }} - {% endif %} - {{ "**kwargs: Any" if async_mode else "**kwargs # type: Any" }} -){{" -> None" if async_mode else "" }}:{% endmacro %} -{% set config_signature = code_model.global_parameters.method|join(', ', attribute='serialized_name') ~ (", " if code_model.global_parameters.method else "") %} -{% set has_mixin_operation_group = code_model.operation_groups|selectattr("is_empty_operation_group")|first %} -{% macro mixin_operation_group_name() %}{{ code_model.class_name }}OperationsMixin{% endmacro %} -{% set base_class = mixin_operation_group_name() if has_mixin_operation_group else "object" %} {# actual template starts here #} # coding=utf-8 {{ code_model.options['license_header'] }} {{ imports }} -from ._configuration import {{ code_model.class_name }}Configuration -{% for operation_group in code_model.operation_groups %} -from .operations import {{ operation_group.class_name }} -{% endfor %} -{% if code_model.sorted_schemas %} -from {{ path_to_models }} import models -{% endif %} - - -class {{ code_model.class_name }}({{ base_class }}): +{{ serializer.class_definition(async_mode) }} """{{ code_model.description }} - {% for operation_group in code_model.operation_groups|rejectattr("is_empty_operation_group") %} - :ivar {{ operation_group.name }}: {{ operation_group.class_name }} operations - {% if async_mode %} - :vartype {{ operation_group.name }}: {{ code_model.namespace }}.aio.operations.{{ operation_group.class_name }} - {% else %} - :vartype {{ operation_group.name }}: {{ code_model.namespace }}.operations.{{ operation_group.class_name }} - {% endif %} - {% endfor %} -{% for parameter in code_model.global_parameters.method %} - :param {{ parameter.serialized_name }}: {{ parameter.description }} - :type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} -{% endfor %} - {% if not code_model.custom_base_url %} - :param str base_url: Service URL - {% endif %} - {% if code_model.has_lro_operations %} - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - {% endif %} - """ - - {{ method_signature()|indent }} - {% if not async_mode %} - # type: (...) -> None - {% endif %} - {% if not code_model.base_url %} - base_url = {{ keywords.escape_str(code_model.custom_base_url) }} + {{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }} + {{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }} + {% if not code_model.service_client.base_url %} + base_url = {{ keywords.escape_str(code_model.service_client.custom_base_url) }} {% else %} if not base_url: - base_url = {{ keywords.escape_str(code_model.base_url) }} - {% endif %} - self._config = {{ code_model.class_name }}Configuration({{ config_signature }}**kwargs) - self._client = {{ code_model.service_client.pipeline_class(code_model, async_mode) }}(base_url=base_url, config=self._config, **kwargs) - - {% if code_model.sorted_schemas %} - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - {% else %} - client_models = {} # type: Dict[str, Any] - {% endif %} - self._serialize = Serializer(client_models) - {% if not code_model.options['client_side_validation'] %} - self._serialize.client_side_validation = False + base_url = {{ keywords.escape_str(code_model.service_client.base_url) }} {% endif %} - self._deserialize = Deserializer(client_models) + self._config = {{ code_model.class_name }}Configuration({{ code_model.service_client.config_initialization }}) + self._client = {{ code_model.service_client.pipeline_class(async_mode) }}(base_url=base_url, config=self._config, **kwargs) - {% for operation_group in code_model.operation_groups|rejectattr("is_empty_operation_group") %} - self.{{ operation_group.name }} = {{ operation_group.class_name }}( - self._client, self._config, self._serialize, self._deserialize) - {% endfor %} - - {% set http_response = "AsyncHttpResponse" if async_mode else "HttpResponse" %} - {{ keywords.def }} _send_request(self, http_request{{ ": HttpRequest" if async_mode }}, **kwargs{{ ": Any" if async_mode }}){{ (" -> " + http_response) if async_mode else "" }}: - {% if not async_mode %} - # type: (HttpRequest, Any) -> {{ http_response }} - {% endif %} - """Runs the network request through the client's chained policies. + {{ op_tools.serialize(serializer.serializers_and_operation_groups_properties()) | indent(8) }} - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.{{ http_response }} - """ + {% set http_response = keywords.async_class + "HttpResponse" %} + {{ serializer.send_request_signature_and_response_type_annotation(async_mode) | indent }} + {{ op_tools.serialize(serializer.send_request_description(async_mode)) | indent(8) }} + request_copy = deepcopy(request) {% if code_model.global_parameters.path %} {{ op_tools.path_format_arguments(code_model.global_parameters.path)|indent(8) }} - {{ op_tools.format_path_format_arguments(url_name="http_request.url")|indent(8) }} + {{ op_tools.format_path_format_arguments(url_name="request_copy.url")|indent(8) }} {% else %} - http_request.url = self._client.format_url(http_request.url) + request_copy.url = self._client.format_url(request_copy.url) {% endif %} - stream = kwargs.pop("stream", True) - pipeline_response = {{ keywords.await }}self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + return self._client.send_request(request_copy, **kwargs) {{ keywords.def }} close(self){{ " -> None" if async_mode else "" }}: {% if not async_mode %} diff --git a/autorest/codegen/templates/setup.py.jinja2 b/autorest/codegen/templates/setup.py.jinja2 index f1433121652..577d51d7d7c 100644 --- a/autorest/codegen/templates/setup.py.jinja2 +++ b/autorest/codegen/templates/setup.py.jinja2 @@ -16,7 +16,7 @@ VERSION = "{{ code_model.options.get('package_version', '0.0.0') }}" # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.8.2"{{ azure_mgmt_core_import }}] +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.16.0"{{ azure_mgmt_core_import }}] setup( name=NAME, diff --git a/autorest/multiapi/models/operation_mixin_group.py b/autorest/multiapi/models/operation_mixin_group.py index 538181754cc..bad3d65f6e6 100644 --- a/autorest/multiapi/models/operation_mixin_group.py +++ b/autorest/multiapi/models/operation_mixin_group.py @@ -24,8 +24,10 @@ def imports(self, async_mode: bool) -> FileImport: for metadata_json in self.version_path_to_metadata.values(): if not metadata_json.get('operation_mixins'): continue - current_version_imports = FileImport(json.loads(metadata_json['operation_mixins'][imports_to_load])) - imports.merge(current_version_imports) + mixin_imports = metadata_json['operation_mixins'][imports_to_load] + if mixin_imports != "None": + current_version_imports = FileImport(json.loads(mixin_imports)) + imports.merge(current_version_imports) return imports def _use_metadata_of_default_api_version( diff --git a/autorest/namer/name_converter.py b/autorest/namer/name_converter.py index 25f5df801de..b6cdd34f091 100644 --- a/autorest/namer/name_converter.py +++ b/autorest/namer/name_converter.py @@ -7,7 +7,7 @@ from typing import cast, Any, Dict, List, Match, Optional from .python_mappings import basic_latin_chars, reserved_words, PadType - +_M4_HEADER_PARAMETERS = ["content_type", "accept"] class NameConverter: @staticmethod def convert_yaml_names(yaml_data: Dict[str, Any]) -> None: @@ -37,29 +37,92 @@ def _convert_operation_groups(operation_groups: List[Dict[str, Any]], code_model NameConverter._convert_language_default_python_case( operation_group, pad_string=PadType.Model, convert_name=True ) - if not operation_group['language']['default']['name']: + operation_group_name = operation_group['language']['default']['name'] + if not operation_group_name: operation_group['language']['python']['className'] = code_model_title + "OperationsMixin" + elif operation_group_name == 'Operations': + operation_group['language']['python']['className'] = operation_group_name else: - operation_group_name = operation_group['language']['default']['name'] - if operation_group_name == 'Operations': - operation_group['language']['python']['className'] = operation_group_name - else: - operation_group['language']['python']['className'] = operation_group_name + "Operations" + operation_group['language']['python']['className'] = operation_group_name + "Operations" for operation in operation_group['operations']: NameConverter._convert_language_default_python_case(operation, pad_string=PadType.Method) + if operation_group_name: + operation['language']['python']['operationGroupName'] = ( + operation_group['language']['python']['name'].lower() + ) + else: + operation['language']['python']['operationGroupName'] = "" for exception in operation.get('exceptions', []): NameConverter._convert_language_default_python_case(exception) for parameter in operation.get("parameters", []): + NameConverter._add_multipart_information(parameter, operation) NameConverter._convert_language_default_python_case(parameter, pad_string=PadType.Parameter) for request in operation.get("requests", []): NameConverter._convert_language_default_python_case(request) for parameter in request.get("parameters", []): + NameConverter._add_multipart_information(parameter, request) NameConverter._convert_language_default_python_case(parameter, pad_string=PadType.Parameter) + if parameter.get("origin", "") == "modelerfour:synthesized/content-type": + parameter["required"] = False + NameConverter._handle_m4_header_parameters(operation.get("requests", [])) for response in operation.get("responses", []): NameConverter._convert_language_default_python_case(response) if operation.get("extensions"): NameConverter._convert_extensions(operation) + @staticmethod + def _handle_m4_header_parameters(requests): + m4_header_params = [] + for request in requests: + m4_header_params.extend([ + p for p in request.get('parameters', []) + if NameConverter._is_schema_an_m4_header_parameter(p['language']['default']['name'], p) + ]) + m4_header_params_to_remove = [] + for m4_header in _M4_HEADER_PARAMETERS: + params_of_header = [ + p for p in m4_header_params + if p['language']['default']['name'] == m4_header + ] + if len(params_of_header) < 2: + continue + param_schema_to_param = { # if they share the same schema, we don't need to keep both of them in this case + id(param['schema']): param + for param in params_of_header + } + if len(param_schema_to_param) == 1: + # we'll remove the ones that aren't the first + m4_header_params_to_remove.extend([ + id(p) for p in params_of_header[1:] + ]) + else: + # currently there's max of 2, so assume this is 2 for now + # in this case, one of them is a constant and one is not. + # Set the client default value to the one of the constant + param_with_constant_schema = next(p for p in params_of_header if p['schema']['type'] == 'constant') + param_with_enum_schema = next( + p for p in params_of_header + if p['schema']['type'] == 'sealed-choice' or p.schema['type'] == 'choice' + ) + param_with_enum_schema['clientDefaultValue'] = param_with_constant_schema['schema']['value']['value'] + m4_header_params_to_remove.append(id(param_with_constant_schema)) + + for request in requests: + if not request.get('parameters'): + continue + request['parameters'] = [p for p in request['parameters'] if id(p) not in m4_header_params_to_remove] + + + @staticmethod + def _add_multipart_information(parameter: Dict[str, Any], request: Dict[str, Any]): + multipart = request["protocol"].get("http", {}).get("multipart", False) + if multipart: + if parameter["protocol"]["http"]["in"] == "body": + parameter["language"]["default"]["multipart"] = True + if parameter["language"]["default"]["serializedName"] == "Content-Type": + parameter['schema']['value']['value'] = None + + @staticmethod def _convert_extensions(operation: Dict[str, Any]) -> None: operation_extensions = operation["extensions"] @@ -145,9 +208,8 @@ def _convert_object_schema(schema: Dict[str, Any]) -> None: @staticmethod def _is_schema_an_m4_header_parameter(schema_name: str, schema: Dict[str, Any]) -> bool: - m4_header_parameters = ["content_type", "accept"] return ( - schema_name in m4_header_parameters and + schema_name in _M4_HEADER_PARAMETERS and schema.get('protocol', {}).get('http', {}).get('in', {}) == 'header' ) @@ -250,9 +312,16 @@ def _get_escaped_reserved_name(name: str, pad_string: Optional[PadType] = None) try: # check to see if name is reserved for the type of name we are converting pad_string = cast(PadType, pad_string) + # there are some private variables, such as grouped parameters + # that are private. We still want to escape them for LLC + name_prefix = "" + if name[0] == "_": + # i am private + name_prefix = "_" + name = name[1:] if pad_string and name.lower() in reserved_words[pad_string]: name += pad_string.value - return name + return name_prefix + name except AttributeError: raise ValueError(f"The name {name} is a reserved word and you have not specified a pad string for it.") diff --git a/docs/client/initializing.md b/docs/client/initializing.md index 02bb6e3f06e..82c65aee4e3 100644 --- a/docs/client/initializing.md +++ b/docs/client/initializing.md @@ -22,7 +22,7 @@ The following are core libraries your generated code depend on, and the minimum | Library | Description | Min Version | | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| [`azure-core`][azure_core_library] | The most important library to have installed. It provides shared exceptions and modules for all the Python SDK client libraries. | 1.8.2 | +| [`azure-core`][azure_core_library] | The most important library to have installed. It provides shared exceptions and modules for all the Python SDK client libraries. | 1.16.0 | | [`msrest`][msrest_library] | Library mainly used for serializing and deserializing objects | 0.6.21 | | [`azure-mgmt-core`][azure_mgmt_core_library] | Required if you're generating mgmt plane code (see `--azure-arm` flag in our [flag index][flag_index]. Provides mgmt plane specific shared exceptions and modules. | 1.2.1 | diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py index 5c8f941459a..b2afe9d8b26 100644 --- a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py @@ -6,21 +6,21 @@ # 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 AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Dict, Optional from azure.core.credentials import AzureKeyCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - + from azure.core.rest import HttpRequest, HttpResponse class AutoRestHeadTestService(object): """Test Infrastructure for AutoRest. @@ -29,7 +29,8 @@ class AutoRestHeadTestService(object): :vartype http_success: azure.key.credential.sample.operations.HttpSuccessOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -46,26 +47,43 @@ def __init__( client_models = {} # type: Dict[str, Any] self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.key.credential.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.key.credential.sample._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/__init__.py new file mode 100644 index 00000000000..8e6cf7ef943 --- /dev/null +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_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. +# -------------------------------------------------------------------------- \ No newline at end of file diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/__init__.py new file mode 100644 index 00000000000..5592646f4af --- /dev/null +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + 'build_head200_request', + 'build_head204_request', + 'build_head404_request', +] diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/_request_builders.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/_request_builders.py new file mode 100644 index 00000000000..a337746d426 --- /dev/null +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/_request_builders.py @@ -0,0 +1,94 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/_request_builders_py3.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..cd3ad63b980 --- /dev/null +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_rest/http_success/_request_builders_py3.py @@ -0,0 +1,86 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request( + **kwargs: Any +) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs: Any +) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs: Any +) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py index 6f3022e3ca8..db46412b019 100644 --- a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py @@ -6,29 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - from ._configuration import AutoRestHeadTestServiceConfiguration from .operations import HttpSuccessOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict -class AutoRestHeadTestService(object): +class AutoRestHeadTestService: """Test Infrastructure for AutoRest. :ivar http_success: HttpSuccessOperations operations :vartype http_success: azure.key.credential.sample.aio.operations.HttpSuccessOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -44,25 +45,42 @@ def __init__( client_models = {} # type: Dict[str, Any] self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.key.credential.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.key.credential.sample._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py index 5127a856100..4375908ad21 100644 --- a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py @@ -5,12 +5,16 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest + +from ..._rest import http_success as rest_http_success T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,18 +53,13 @@ async def head200( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head200.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -72,6 +71,7 @@ async def head200( head200.metadata = {'url': '/http/success/200'} # type: ignore + async def head204( self, **kwargs: Any @@ -88,18 +88,13 @@ async def head204( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head204.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -111,6 +106,7 @@ async def head204( head204.metadata = {'url': '/http/success/204'} # type: ignore + async def head404( self, **kwargs: Any @@ -127,18 +123,13 @@ async def head404( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head404.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -149,3 +140,4 @@ async def head404( return cls(pipeline_response, None, {}) head404.metadata = {'url': '/http/success/404'} # type: ignore + diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py index 389b8e00ddf..6e8de8b92e1 100644 --- a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py +++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py @@ -5,12 +5,16 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest + +from .._rest import http_success as rest_http_success if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,18 +58,13 @@ def head200( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head200.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -77,6 +76,7 @@ def head200( head200.metadata = {'url': '/http/success/200'} # type: ignore + def head204( self, **kwargs # type: Any @@ -94,18 +94,13 @@ def head204( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head204.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -117,6 +112,7 @@ def head204( head204.metadata = {'url': '/http/success/204'} # type: ignore + def head404( self, **kwargs # type: Any @@ -134,18 +130,13 @@ def head404( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head404.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -156,3 +147,4 @@ def head404( return cls(pipeline_response, None, {}) head404.metadata = {'url': '/http/success/404'} # type: ignore + diff --git a/docs/samples/specification/azure_key_credential/generated/setup.py b/docs/samples/specification/azure_key_credential/generated/setup.py index 89127a7c061..9c7f9d08c98 100644 --- a/docs/samples/specification/azure_key_credential/generated/setup.py +++ b/docs/samples/specification/azure_key_credential/generated/setup.py @@ -19,7 +19,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.8.2"] +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.16.0"] setup( name=NAME, diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/_auto_rest_head_test_service.py b/docs/samples/specification/basic/generated/azure/basic/sample/_auto_rest_head_test_service.py index 5d87694343c..dbc9e75b2ee 100644 --- a/docs/samples/specification/basic/generated/azure/basic/sample/_auto_rest_head_test_service.py +++ b/docs/samples/specification/basic/generated/azure/basic/sample/_auto_rest_head_test_service.py @@ -6,27 +6,28 @@ # 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 AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Dict, Optional - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - + from azure.core.rest import HttpRequest, HttpResponse class AutoRestHeadTestService(object): """Test Infrastructure for AutoRest. :ivar http_success: HttpSuccessOperations operations :vartype http_success: azure.basic.sample.operations.HttpSuccessOperations - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -42,26 +43,43 @@ def __init__( client_models = {} # type: Dict[str, Any] self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.basic.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.basic.sample._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/_rest/__init__.py b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/__init__.py new file mode 100644 index 00000000000..8e6cf7ef943 --- /dev/null +++ b/docs/samples/specification/basic/generated/azure/basic/sample/_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. +# -------------------------------------------------------------------------- \ No newline at end of file diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/__init__.py b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/__init__.py new file mode 100644 index 00000000000..5592646f4af --- /dev/null +++ b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + 'build_head200_request', + 'build_head204_request', + 'build_head404_request', +] diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/_request_builders.py b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/_request_builders.py new file mode 100644 index 00000000000..a337746d426 --- /dev/null +++ b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/_request_builders.py @@ -0,0 +1,94 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/_request_builders_py3.py b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..cd3ad63b980 --- /dev/null +++ b/docs/samples/specification/basic/generated/azure/basic/sample/_rest/http_success/_request_builders_py3.py @@ -0,0 +1,86 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request( + **kwargs: Any +) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs: Any +) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs: Any +) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py index 4192db00c16..7a3d738e879 100644 --- a/docs/samples/specification/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py +++ b/docs/samples/specification/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py @@ -6,26 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - from ._configuration import AutoRestHeadTestServiceConfiguration from .operations import HttpSuccessOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict -class AutoRestHeadTestService(object): +class AutoRestHeadTestService: """Test Infrastructure for AutoRest. :ivar http_success: HttpSuccessOperations operations :vartype http_success: azure.basic.sample.aio.operations.HttpSuccessOperations - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -40,25 +41,42 @@ def __init__( client_models = {} # type: Dict[str, Any] self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.basic.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.basic.sample._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/aio/operations/_http_success_operations.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/operations/_http_success_operations.py index 5127a856100..4375908ad21 100644 --- a/docs/samples/specification/basic/generated/azure/basic/sample/aio/operations/_http_success_operations.py +++ b/docs/samples/specification/basic/generated/azure/basic/sample/aio/operations/_http_success_operations.py @@ -5,12 +5,16 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest + +from ..._rest import http_success as rest_http_success T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,18 +53,13 @@ async def head200( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head200.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -72,6 +71,7 @@ async def head200( head200.metadata = {'url': '/http/success/200'} # type: ignore + async def head204( self, **kwargs: Any @@ -88,18 +88,13 @@ async def head204( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head204.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -111,6 +106,7 @@ async def head204( head204.metadata = {'url': '/http/success/204'} # type: ignore + async def head404( self, **kwargs: Any @@ -127,18 +123,13 @@ async def head404( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head404.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -149,3 +140,4 @@ async def head404( return cls(pipeline_response, None, {}) head404.metadata = {'url': '/http/success/404'} # type: ignore + diff --git a/docs/samples/specification/basic/generated/azure/basic/sample/operations/_http_success_operations.py b/docs/samples/specification/basic/generated/azure/basic/sample/operations/_http_success_operations.py index 389b8e00ddf..6e8de8b92e1 100644 --- a/docs/samples/specification/basic/generated/azure/basic/sample/operations/_http_success_operations.py +++ b/docs/samples/specification/basic/generated/azure/basic/sample/operations/_http_success_operations.py @@ -5,12 +5,16 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest + +from .._rest import http_success as rest_http_success if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,18 +58,13 @@ def head200( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head200.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -77,6 +76,7 @@ def head200( head200.metadata = {'url': '/http/success/200'} # type: ignore + def head204( self, **kwargs # type: Any @@ -94,18 +94,13 @@ def head204( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head204.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -117,6 +112,7 @@ def head204( head204.metadata = {'url': '/http/success/204'} # type: ignore + def head404( self, **kwargs # type: Any @@ -134,18 +130,13 @@ def head404( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head404.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -156,3 +147,4 @@ def head404( return cls(pipeline_response, None, {}) head404.metadata = {'url': '/http/success/404'} # type: ignore + diff --git a/docs/samples/specification/basic/generated/setup.py b/docs/samples/specification/basic/generated/setup.py index 252310d94f9..369a4202815 100644 --- a/docs/samples/specification/basic/generated/setup.py +++ b/docs/samples/specification/basic/generated/setup.py @@ -19,7 +19,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.8.2"] +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.16.0"] setup( name=NAME, diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py b/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py index b42c5b536c9..04aae5a1e5e 100644 --- a/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py +++ b/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py @@ -6,27 +6,29 @@ # 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 PollingPagingExampleConfiguration +from .operations import PollingPagingExampleOperationsMixin + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PollingPagingExampleConfiguration -from .operations import PollingPagingExampleOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PollingPagingExample(PollingPagingExampleOperationsMixin): """Show polling and paging generation. - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -42,24 +44,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.directives.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.directives.sample._rest import build_basic_polling_request_initial + >>> request = build_basic_polling_request_initial(json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/_rest/__init__.py b/docs/samples/specification/directives/generated/azure/directives/sample/_rest/__init__.py new file mode 100644 index 00000000000..a66951346be --- /dev/null +++ b/docs/samples/specification/directives/generated/azure/directives/sample/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_basic_polling_request_initial + from ._request_builders_py3 import build_basic_paging_request +except (SyntaxError, ImportError): + from ._request_builders import build_basic_polling_request_initial # type: ignore + from ._request_builders import build_basic_paging_request # type: ignore + +__all__ = [ + 'build_basic_polling_request_initial', + 'build_basic_paging_request', +] diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/_rest/_request_builders.py b/docs/samples/specification/directives/generated/azure/directives/sample/_rest/_request_builders.py new file mode 100644 index 00000000000..b3108b4c7d9 --- /dev/null +++ b/docs/samples/specification/directives/generated/azure/directives/sample/_rest/_request_builders.py @@ -0,0 +1,91 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_basic_polling_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A simple polling operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/basic/polling') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_basic_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A simple paging operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/basic/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/_rest/_request_builders_py3.py b/docs/samples/specification/directives/generated/azure/directives/sample/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..da08fd8632e --- /dev/null +++ b/docs/samples/specification/directives/generated/azure/directives/sample/_rest/_request_builders_py3.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 typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_basic_polling_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """A simple polling operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/basic/polling') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_basic_paging_request( + **kwargs: Any +) -> HttpRequest: + """A simple paging operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/basic/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py index b193abf1f58..806476466d8 100644 --- a/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py +++ b/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py @@ -6,22 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from copy import deepcopy +from typing import Any, Awaitable, Optional from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer +from .. import models from ._configuration import PollingPagingExampleConfiguration from .operations import PollingPagingExampleOperationsMixin -from .. import models - class PollingPagingExample(PollingPagingExampleOperationsMixin): """Show polling and paging generation. - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -36,23 +38,41 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.directives.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.directives.sample._rest import build_basic_polling_request_initial + >>> request = build_basic_polling_request_initial(json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py index 0ae5da1c4e1..133358aeb8b 100644 --- a/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py +++ b/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py @@ -5,17 +5,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest from my.library.aio import AsyncCustomDefaultPollingMethod, AsyncCustomPager, AsyncCustomPoller -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -32,34 +34,26 @@ async def _basic_polling_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self._basic_polling_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_basic_polling_request_initial( + content_type=content_type, + json=json, + template_url=self._basic_polling_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) deserialized = None if response.status_code == 200: @@ -69,8 +63,10 @@ async def _basic_polling_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _basic_polling_initial.metadata = {'url': '/basic/polling'} # type: ignore + async def begin_basic_polling( self, product: Optional["_models.Product"] = None, @@ -82,13 +78,16 @@ async def begin_basic_polling( :type product: ~azure.directives.sample.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncCustomDefaultPollingMethod. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncCustomDefaultPollingMethod. Pass + in False for this operation to not poll, or pass in your own initialized polling object for a + personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncCustomPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncCustomPoller that returns either Product or the result of + cls(response) :rtype: ~my.library.aio.AsyncCustomPoller[~azure.directives.sample.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -106,8 +105,10 @@ async def begin_basic_polling( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -128,6 +129,7 @@ def get_long_running_output(pipeline_response): return AsyncCustomPoller(self._client, raw_result, get_long_running_output, polling_method) begin_basic_polling.metadata = {'url': '/basic/polling'} # type: ignore + def basic_paging( self, **kwargs: Any @@ -144,24 +146,22 @@ def basic_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.basic_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_basic_paging_request( + template_url=self.basic_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_basic_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -178,8 +178,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py b/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py index 6816d2adf0d..2ca69a1abc8 100644 --- a/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py +++ b/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py @@ -5,16 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import NoPolling, PollingMethod +from azure.core.rest import HttpRequest from my.library import CustomDefaultPollingMethod, CustomPager, CustomPoller -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -36,34 +38,26 @@ def _basic_polling_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self._basic_polling_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_basic_polling_request_initial( + content_type=content_type, + json=json, + template_url=self._basic_polling_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) deserialized = None if response.status_code == 200: @@ -73,8 +67,10 @@ def _basic_polling_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _basic_polling_initial.metadata = {'url': '/basic/polling'} # type: ignore + def begin_basic_polling( self, product=None, # type: Optional["_models.Product"] @@ -87,13 +83,15 @@ def begin_basic_polling( :type product: ~azure.directives.sample.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be CustomDefaultPollingMethod. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be CustomDefaultPollingMethod. Pass in + False for this operation to not poll, or pass in your own initialized polling object for a + personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of CustomPoller that returns either Product or the result of cls(response) :rtype: ~my.library.CustomPoller[~azure.directives.sample.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -111,8 +109,10 @@ def begin_basic_polling( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -133,6 +133,7 @@ def get_long_running_output(pipeline_response): return CustomPoller(self._client, raw_result, get_long_running_output, polling_method) begin_basic_polling.metadata = {'url': '/basic/polling'} # type: ignore + def basic_paging( self, **kwargs # type: Any @@ -150,24 +151,22 @@ def basic_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.basic_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_basic_paging_request( + template_url=self.basic_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_basic_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -184,8 +183,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response diff --git a/docs/samples/specification/directives/generated/setup.py b/docs/samples/specification/directives/generated/setup.py index ca368ccbca8..13fbb2a5faa 100644 --- a/docs/samples/specification/directives/generated/setup.py +++ b/docs/samples/specification/directives/generated/setup.py @@ -19,7 +19,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.8.2"] +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.16.0"] setup( name=NAME, diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py index e92564ce244..4f3cb9dbb8d 100644 --- a/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py @@ -6,21 +6,21 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from ._configuration import AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Dict, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - + from azure.core.rest import HttpRequest, HttpResponse class AutoRestHeadTestService(object): """Test Infrastructure for AutoRest. @@ -29,7 +29,8 @@ class AutoRestHeadTestService(object): :vartype http_success: azure.mgmt.sample.operations.HttpSuccessOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -46,26 +47,43 @@ def __init__( client_models = {} # type: Dict[str, Any] self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.mgmt.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.mgmt.sample._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/__init__.py new file mode 100644 index 00000000000..8e6cf7ef943 --- /dev/null +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_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. +# -------------------------------------------------------------------------- \ No newline at end of file diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/__init__.py new file mode 100644 index 00000000000..5592646f4af --- /dev/null +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + 'build_head200_request', + 'build_head204_request', + 'build_head404_request', +] diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/_request_builders.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/_request_builders.py new file mode 100644 index 00000000000..a337746d426 --- /dev/null +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/_request_builders.py @@ -0,0 +1,94 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/_request_builders_py3.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..cd3ad63b980 --- /dev/null +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_rest/http_success/_request_builders_py3.py @@ -0,0 +1,86 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request( + **kwargs: Any +) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs: Any +) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs: Any +) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py index 4d6e7d0bf25..94372c2c94c 100644 --- a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py @@ -6,30 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from ._configuration import AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Dict from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - - -class AutoRestHeadTestService(object): +class AutoRestHeadTestService: """Test Infrastructure for AutoRest. :ivar http_success: HttpSuccessOperations operations :vartype http_success: azure.mgmt.sample.aio.operations.HttpSuccessOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -45,25 +46,42 @@ def __init__( client_models = {} # type: Dict[str, Any] self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.mgmt.sample.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.mgmt.sample._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py index 23a3754979e..fb04ea2c2a0 100644 --- a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py @@ -5,14 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat +from ..._rest import http_success as rest_http_success + T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,12 +41,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def head200( self, **kwargs: Any - ) -> bool: + ) -> None: """Return 200 status code if successful. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] @@ -50,18 +54,13 @@ async def head200( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head200.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -70,19 +69,20 @@ async def head200( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + head200.metadata = {'url': '/http/success/200'} # type: ignore + async def head204( self, **kwargs: Any - ) -> bool: + ) -> None: """Return 204 status code if successful. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] @@ -90,18 +90,13 @@ async def head204( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head204.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -110,19 +105,20 @@ async def head204( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + head204.metadata = {'url': '/http/success/204'} # type: ignore + async def head404( self, **kwargs: Any - ) -> bool: + ) -> None: """Return 404 status code if successful. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] @@ -130,18 +126,13 @@ async def head404( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head404.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -150,6 +141,7 @@ async def head404( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + head404.metadata = {'url': '/http/success/404'} # type: ignore + diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py b/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py index 0cbc538c44d..203a30036de 100644 --- a/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py +++ b/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py @@ -5,14 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat +from .._rest import http_success as rest_http_success + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar @@ -42,12 +46,12 @@ def head200( self, **kwargs # type: Any ): - # type: (...) -> bool + # type: (...) -> None """Return 200 status code if successful. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] @@ -55,18 +59,13 @@ def head200( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head200.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -75,20 +74,21 @@ def head200( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + head200.metadata = {'url': '/http/success/200'} # type: ignore + def head204( self, **kwargs # type: Any ): - # type: (...) -> bool + # type: (...) -> None """Return 204 status code if successful. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] @@ -96,18 +96,13 @@ def head204( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head204.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -116,20 +111,21 @@ def head204( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + head204.metadata = {'url': '/http/success/204'} # type: ignore + def head404( self, **kwargs # type: Any ): - # type: (...) -> bool + # type: (...) -> None """Return 404 status code if successful. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] @@ -137,18 +133,13 @@ def head404( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.head404.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -157,6 +148,7 @@ def head404( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + head404.metadata = {'url': '/http/success/404'} # type: ignore + diff --git a/docs/samples/specification/management/generated/setup.py b/docs/samples/specification/management/generated/setup.py index 841f7d16a88..3f86260d3d9 100644 --- a/docs/samples/specification/management/generated/setup.py +++ b/docs/samples/specification/management/generated/setup.py @@ -19,7 +19,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] setup( name=NAME, diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py index 89204254a84..64c0e839758 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py index 416cdb39cdf..f8ab051cab5 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py @@ -10,19 +10,13 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Iterable, Optional + + from azure.core.paging import ItemPaged + from azure.core.polling import LROPoller class MultiapiServiceClientOperationsMixin(object): @@ -32,19 +26,22 @@ def begin_test_lro( product=None, # type: Optional["_models.Product"] **kwargs # type: Any ): + # type: (...) -> LROPoller["_models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. :type product: ~azure.multiapi.sample.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -65,6 +62,7 @@ def begin_test_lro_and_paging( test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"] **kwargs # type: Any ): + # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: @@ -73,13 +71,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -101,6 +103,7 @@ def test_different_calls( greeting_in_french=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """Has added parameters across the API versions. :param greeting_in_english: pass in 'hello' to pass test. @@ -137,6 +140,7 @@ def test_one( message=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """TestOne should be in an FirstVersionOperationsMixin. :param id: An int parameter. @@ -167,6 +171,7 @@ def test_paging( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.PagingResult"] """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py index 9977707d621..6004cc17c32 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py index 6c762f32a2a..ab45b217bdf 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py @@ -9,16 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Optional -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling +from azure.core.async_paging import AsyncItemPaged +from azure.core.polling import AsyncLROPoller class MultiapiServiceClientOperationsMixin(object): @@ -34,13 +28,16 @@ async def begin_test_lro( :type product: ~azure.multiapi.sample.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -55,7 +52,7 @@ async def begin_test_lro( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.begin_test_lro(product, **kwargs) - def begin_test_lro_and_paging( + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None, @@ -69,13 +66,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -88,7 +89,7 @@ def begin_test_lro_and_paging( mixin_instance._serialize = Serializer(self._models_dict(api_version)) mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) - return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + return await mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) async def test_different_calls( self, @@ -162,7 +163,7 @@ async def test_one( def test_paging( self, **kwargs: Any - ) -> AsyncItemPaged["_models.PagingResult"]: + ) -> AsyncIterable["_models.PagingResult"]: """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json index ac880a00894..3a63ecbda44 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -88,12 +88,12 @@ "operation_group_one": "OperationGroupOneOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.mgmt.core.polling.arm_polling\": [\"ARMPolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.mgmt.core.polling.async_arm_polling\": [\"AsyncARMPolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -105,55 +105,55 @@ }, "_test_lro_initial" : { "sync": { - "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.Product\"]\n", + "doc": "\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e Optional[\"_models.Product\"]:\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "begin_test_lro" : { "sync": { - "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.Product\"]\n", + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of\n cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "_test_lro_and_paging_initial" : { "sync": { - "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.PagingResult\"\n", + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e \"_models.PagingResult\":\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "begin_test_lro_and_paging" : { "sync": { - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[ItemPaged[\"_models.PagingResult\"]]\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { - "coroutine": false, - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "coroutine": true, + "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either\n PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py index d98268d3d5e..1e780821973 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py @@ -6,23 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -31,8 +30,10 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_one: azure.multiapi.sample.v1.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -49,26 +50,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.multiapi.sample.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.multiapi.sample.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/__init__.py new file mode 100644 index 00000000000..f9044715939 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/__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 ._request_builders_py3 import build_test_one_request + from ._request_builders_py3 import build_test_lro_request_initial + from ._request_builders_py3 import build_test_lro_and_paging_request_initial + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_lro_request_initial # type: ignore + from ._request_builders import build_test_lro_and_paging_request_initial # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_lro_request_initial', + 'build_test_lro_and_paging_request_initial', + 'build_test_different_calls_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..0212b812ffd --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/_request_builders.py @@ -0,0 +1,197 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..b9131d21981 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/_request_builders_py3.py @@ -0,0 +1,193 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..f984bfab1ee --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..7a4821c0604 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_client.py index 6386dc1f1fa..fcee5978f9d 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_client.py @@ -6,31 +6,33 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: azure.multiapi.sample.v1.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + azure.multiapi.sample.v1.aio.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -46,25 +48,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.multiapi.sample.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.multiapi.sample.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py index 6fc644d04ac..b8ff23bf7a5 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,25 +47,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -76,6 +68,7 @@ async def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def _test_lro_initial( self, product: Optional["_models.Product"] = None, @@ -86,34 +79,26 @@ async def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -123,8 +108,10 @@ async def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + async def begin_test_lro( self, product: Optional["_models.Product"] = None, @@ -136,13 +123,16 @@ async def begin_test_lro( :type product: ~azure.multiapi.sample.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -160,8 +150,10 @@ async def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -182,6 +174,7 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + async def _test_lro_and_paging_initial( self, client_request_id: Optional[str] = None, @@ -193,32 +186,21 @@ async def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,8 +213,10 @@ async def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, @@ -247,49 +231,55 @@ async def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -306,8 +296,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -352,6 +342,7 @@ async def internal_get_next(next_link=None): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -371,23 +362,14 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,3 +381,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py index c4b59bbbb8f..59f1446410b 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,22 +59,13 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -83,3 +77,4 @@ async def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py index 6f0a6604049..f83bcfe83b5 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -50,25 +52,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -81,6 +73,7 @@ def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def _test_lro_initial( self, product=None, # type: Optional["_models.Product"] @@ -92,34 +85,26 @@ def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -129,8 +114,10 @@ def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + def begin_test_lro( self, product=None, # type: Optional["_models.Product"] @@ -143,13 +130,15 @@ def begin_test_lro( :type product: ~azure.multiapi.sample.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -167,8 +156,10 @@ def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -189,6 +180,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + def _test_lro_and_paging_initial( self, client_request_id=None, # type: Optional[str] @@ -201,32 +193,21 @@ def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,8 +220,10 @@ def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def begin_test_lro_and_paging( self, client_request_id=None, # type: Optional[str] @@ -256,49 +239,55 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -315,8 +304,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -361,6 +350,7 @@ def internal_get_next(next_link=None): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -381,23 +371,14 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,3 +390,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py index c1a9fcadf31..cccf91d0c4e 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -61,22 +64,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,3 +82,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json index a294ef44b8c..10101c8f73a 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,12 +89,12 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.ModelTwo\"\n", "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -106,7 +106,7 @@ }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_client.py index 4710fdcef89..10d5081cee9 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: azure.multiapi.sample.v2.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.multiapi.sample.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.multiapi.sample.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/__init__.py new file mode 100644 index 00000000000..47d95873c6d --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_one_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_different_calls_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..248aec13bdf --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/_request_builders.py @@ -0,0 +1,113 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4cda774bfa7 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/_request_builders_py3.py @@ -0,0 +1,106 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..a1c3ce0967d --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/__init__.py @@ -0,0 +1,19 @@ +# 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_test_two_request + from ._request_builders_py3 import build_test_three_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + from ._request_builders import build_test_three_request # type: ignore + +__all__ = [ + 'build_test_two_request', + 'build_test_three_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..aceec5b3a50 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,103 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_three_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..dc51f344320 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,101 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_three_request( + **kwargs: Any +) -> HttpRequest: + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..40936059a53 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/__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_test_four_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + +__all__ = [ + 'build_test_four_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..beab509ad89 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + parameter_one = kwargs.pop('parameter_one') # type: bool + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..ad79a8caadf --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + parameter_one: bool, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py index 5625b32d593..b30ceedd9ea 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py @@ -6,33 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: azure.multiapi.sample.v2.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + azure.multiapi.sample.v2.aio.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: azure.multiapi.sample.v2.aio.operations.OperationGroupTwoOperations + :vartype operation_group_two: + azure.multiapi.sample.v2.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +49,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.multiapi.sample.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.multiapi.sample.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py index 92c0be213f1..9cd19b4f664 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,25 +44,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -74,8 +66,10 @@ async def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -98,25 +92,15 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,3 +112,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py index ac309aba25d..361198c73bb 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +90,10 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + async def test_three( self, **kwargs: Any @@ -114,22 +110,13 @@ async def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,3 +128,4 @@ async def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py index 588d96c2f2a..b110bf602e4 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,23 +62,14 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,3 +81,4 @@ async def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py index 7f8353dd3bb..082641f2a2a 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -47,25 +49,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -79,8 +71,10 @@ def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -104,25 +98,15 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,3 +118,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py index ea946bfdadf..3d8c58dbd34 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,8 +95,10 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + def test_three( self, **kwargs # type: Any @@ -120,22 +116,13 @@ def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,3 +134,4 @@ def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py index 909d0b3cc1b..325e02e3907 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,23 +67,14 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,3 +86,4 @@ def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json index 94514ba9d42..0ad7dbc154e 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,24 +89,24 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_paging" : { "sync": { - "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.PagingResult\"]\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.multiapi.sample.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n", + "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.PagingResult\"]:\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_client.py index 9e5176315f2..76b2e443dfb 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: azure.multiapi.sample.v3.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.multiapi.sample.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.multiapi.sample.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/__init__.py new file mode 100644 index 00000000000..ac71d77c963 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_paging_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_paging_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_paging_request', + 'build_test_different_calls_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/_request_builders.py new file mode 100644 index 00000000000..51330488a14 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/_request_builders.py @@ -0,0 +1,102 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + greeting_in_french = kwargs.pop('greeting_in_french', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..ddae7737619 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/_request_builders_py3.py @@ -0,0 +1,95 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_paging_request( + **kwargs: Any +) -> HttpRequest: + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..689e60edb0d --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..ffa8d8ef82c --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..c9663b12265 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/__init__.py @@ -0,0 +1,19 @@ +# 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_test_four_request + from ._request_builders_py3 import build_test_five_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + from ._request_builders import build_test_five_request # type: ignore + +__all__ = [ + 'build_test_four_request', + 'build_test_five_request', +] diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/_request_builders.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..bca245b1aff --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,106 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_five_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/_request_builders_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..1dc882231b0 --- /dev/null +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_five_request( + **kwargs: Any +) -> HttpRequest: + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py index ba530a307ba..318089eac42 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py @@ -6,33 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: azure.multiapi.sample.v3.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + azure.multiapi.sample.v3.aio.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: azure.multiapi.sample.v3.aio.operations.OperationGroupTwoOperations + :vartype operation_group_two: + azure.multiapi.sample.v3.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +49,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `azure.multiapi.sample.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azure.multiapi.sample.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py index ddad8a8c7c6..6693c498621 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,24 +39,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -71,8 +71,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -106,27 +106,16 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,3 +127,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py index 5dccdfda219..11f21c8a286 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,4 +90,6 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py index 22ef21827fd..955f681cf2d 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, IO, 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,8 +52,9 @@ async def test_four( :param input: Input parameter. :type input: IO or ~azure.multiapi.sample.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -61,38 +65,30 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,6 +101,7 @@ async def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + async def test_five( self, **kwargs: Any @@ -121,22 +118,13 @@ async def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,3 +136,4 @@ async def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py index 5912a92f724..86c858b9fc0 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -42,24 +44,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -76,8 +76,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -112,27 +112,16 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,3 +133,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py index b7683c1a32f..8ae17bbae65 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,4 +95,6 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py index 087d7676a48..0dce8dbbb1d 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,8 +57,9 @@ def test_four( :param input: Input parameter. :type input: IO or ~azure.multiapi.sample.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -66,38 +70,30 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,6 +106,7 @@ def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + def test_five( self, **kwargs # type: Any @@ -127,22 +124,13 @@ def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,3 +142,4 @@ def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/eng/pipelines/ci.yml b/eng/pipelines/ci.yml index fcb5f20bccc..90e11544af1 100644 --- a/eng/pipelines/ci.yml +++ b/eng/pipelines/ci.yml @@ -23,10 +23,10 @@ jobs: OSName: 'Linux' OSVmImage: 'ubuntu-16.04' PythonVersion: '2.7' - Linux_Python35: + Linux_Python36: OSName: 'Linux' OSVmImage: 'ubuntu-16.04' - PythonVersion: '3.5' + PythonVersion: '3.6' CoverageArg: '' Linux_Python38: OSName: 'Linux' @@ -85,28 +85,54 @@ jobs: displayName: 'Install Env Specific Reqs in Target PyVersion $(PythonVersion)' - script: | - cd $(TestFolder)/azure + cd $(TestFolder)/azure/legacy tox -e ci - displayName: 'Execute "azure" Tests - Python $(PythonVersion)' + displayName: 'Execute legacy "azure" Tests - Python $(PythonVersion)' - task: PublishTestResults@2 condition: always() - displayName: 'Publish "azure" Test Results' + displayName: 'Publish legacy "azure" Test Results' inputs: testResultsFiles: 'test-junit-azure-ci.xml' - testRunTitle: '$(OSName) Python $(PythonVersion) - azure' - searchFolder: '$(TestFolder)/azure' + testRunTitle: '$(OSName) Python $(PythonVersion) - legacy azure' + searchFolder: '$(TestFolder)/azure/legacy' - script: | - cd $(TestFolder)/vanilla + cd $(TestFolder)/azure/low-level tox -e ci - displayName: 'Execute "vanilla" Tests - Python $(PythonVersion)' + displayName: 'Execute low-level "azure" Tests - Python $(PythonVersion)' - task: PublishTestResults@2 - displayName: 'Publish "vanilla" Test Results' + condition: always() + displayName: 'Publish low-level "azure" Test Results' + inputs: + testResultsFiles: 'test-junit-azure-ci.xml' + testRunTitle: '$(OSName) Python $(PythonVersion) - low-level azure' + searchFolder: '$(TestFolder)/azure/low-level' + + - script: | + cd $(TestFolder)/vanilla/legacy + tox -e ci + displayName: 'Execute legacy "vanilla" Tests - Python $(PythonVersion)' + - task: PublishTestResults@2 + displayName: 'Publish legacy "vanilla" Test Results' + condition: always() + inputs: + testResultsFiles: 'test-junit-vanilla-ci.xml' + testRunTitle: '$(OSName) Python $(PythonVersion) - legacy vanilla' + searchFolder: '$(TestFolder)/vanilla/legacy' + + - script: | + cd $(TestFolder)/vanilla/low-level + tox -e ci + tox -e initial-ci + tox -e update-ci + displayName: 'Execute low level "vanilla" Tests - Python $(PythonVersion)' + - task: PublishTestResults@2 + displayName: 'Publish low level "vanilla" Test Results' condition: always() inputs: testResultsFiles: 'test-junit-vanilla-ci.xml' - testRunTitle: '$(OSName) Python $(PythonVersion) - vanilla' - searchFolder: '$(TestFolder)/vanilla' + testRunTitle: '$(OSName) Python $(PythonVersion) - low level vanilla' + searchFolder: '$(TestFolder)/vanilla/low-level' - script: | cd $(TestFolder)/multiapi diff --git a/package.json b/package.json index ed78217c246..b00c4b3aa19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/python", - "version": "5.8.4", + "version": "5.9.0", "description": "The Python extension for generators in AutoRest.", "scripts": { "prepare": "node run-python3.js prepare.py", @@ -24,7 +24,8 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/autorestv3/README.md", "dependencies": { - "@azure-tools/extension": "~3.2.1" + "@azure-tools/extension": "~3.2.1", + "autorest": "^3.2.0" }, "devDependencies": { "@autorest/autorest": "^3.0.0", diff --git a/tasks.py b/tasks.py index bd0c72a9a4e..dff82f4c18f 100644 --- a/tasks.py +++ b/tasks.py @@ -71,6 +71,11 @@ class _SwaggerGroup(Enum): 'NoOperations': 'no-operations.json', } +_UPDATE_SWAGGER_MAPPINGS = { + 'LLCInitial': 'llc_initial.json', + 'LLCUpdateOne': 'llc_update1.json' +} + _AZURE_SWAGGER_MAPPINGS = { 'AzureBodyDuration': 'body-duration.json', 'AzureReport': 'azure-report.json', @@ -106,6 +111,8 @@ class _SwaggerGroup(Enum): 'AzureSpecials': 'azurespecialproperties', 'StorageManagementClient': 'storage', 'CustomUrlPaging': 'custombaseurlpaging', + 'LLCInitial': 'llcpackage', + 'LLCUpdateOne': 'llcpackage' } _PACKAGES_WITH_CLIENT_SIDE_VALIDATION = [ @@ -124,6 +131,7 @@ def _build_flags( debug: bool, swagger_group: _SwaggerGroup, override_flags: Optional[Dict[str, Any]] = None, + **kwargs ) -> Dict[str, Any]: autorest_dir = os.path.dirname(__file__) testserver_dir = "node_modules/@microsoft.azure/autorest.testserver/swagger" @@ -132,6 +140,16 @@ def _build_flags( generation_section = "vanilla" else: generation_section = "azure" + namespace = _OVERWRITE_DEFAULT_NAMESPACE.get(package_name, package_name.lower()) + low_level_client = kwargs.pop("low_level_client", False) + if low_level_client: + package_name += "LowLevel" + generation_section += "/low-level" + override_flags = override_flags or {} + override_flags["low-level-client"] = True + namespace += "lowlevel" + else: + generation_section += "/legacy" flags = { "use": autorest_dir, @@ -149,7 +167,7 @@ def _build_flags( "azure-arm": swagger_group == _SwaggerGroup.AZURE_ARM, "payload-flattening-threshold": 1, "keep-version-file": True, - "namespace": _OVERWRITE_DEFAULT_NAMESPACE.get(package_name, package_name.lower()), + "namespace": namespace, "client-side-validation": package_name in _PACKAGES_WITH_CLIENT_SIDE_VALIDATION, "black": True, } @@ -163,8 +181,9 @@ def _build_command_line( debug: bool, swagger_group: _SwaggerGroup, override_flags: Optional[Dict[str, Any]] = None, + **kwargs, ) -> str: - flags = _build_flags(package_name, swagger_name, debug, swagger_group, override_flags) + flags = _build_flags(package_name, swagger_name, debug, swagger_group, override_flags, **kwargs) flag_strings = [ f"--{flag}={value}" for flag, value in flags.items() ] @@ -198,38 +217,56 @@ def _regenerate( debug: bool, swagger_group: _SwaggerGroup, override_flags: Optional[Dict[str, Any]] = None, + **kwargs ) -> None: cmds = [] for package_name, swagger_name in mapping.items(): - command_line = _build_command_line(package_name, swagger_name, debug, swagger_group, override_flags) + command_line = _build_command_line(package_name, swagger_name, debug, swagger_group, override_flags, **kwargs) print(Fore.YELLOW + f'Queuing up: {command_line}') cmds.append(command_line) _run_autorest(cmds, debug=debug) -@task -def regenerate_vanilla(c, swagger_name=None, debug=False): +def _prepare_mapping_and_regenerate(c, mapping, swagger_group, swagger_name=None, debug=False, **kwargs): if swagger_name: - mapping = {k: v for k, v in _VANILLA_SWAGGER_MAPPINGS.items() if swagger_name.lower() in k.lower()} + prepared_mapping = {k: v for k, v in mapping.items() if swagger_name.lower() in k.lower()} else: - mapping = _VANILLA_SWAGGER_MAPPINGS - _regenerate(mapping, debug, swagger_group=_SwaggerGroup.VANILLA) + prepared_mapping = mapping + _regenerate(prepared_mapping, debug, swagger_group=swagger_group, **kwargs) @task -def regenerate_azure(c, swagger_name=None, debug=False): - if swagger_name: - mapping = {k: v for k, v in _AZURE_SWAGGER_MAPPINGS.items() if swagger_name.lower() in k.lower()} - else: - mapping = _AZURE_SWAGGER_MAPPINGS - _regenerate(mapping, debug, swagger_group=_SwaggerGroup.AZURE) +def regenerate_vanilla_legacy(c, swagger_name=None, debug=False, **kwargs): + return _prepare_mapping_and_regenerate(c, _VANILLA_SWAGGER_MAPPINGS, _SwaggerGroup.VANILLA, swagger_name, debug, **kwargs) @task -def regenerate_azure_arm(c, swagger_name=None, debug=False): - if swagger_name: - mapping = {k: v for k, v in _AZURE_ARM_SWAGGER_MAPPINGS.items() if swagger_name.lower() in k.lower()} - else: - mapping = _AZURE_ARM_SWAGGER_MAPPINGS - _regenerate(mapping, debug, swagger_group=_SwaggerGroup.AZURE_ARM) +def regenerate_vanilla_llc(c, swagger_name=None, debug=False, **kwargs): + mapping = _VANILLA_SWAGGER_MAPPINGS + mapping.update(_UPDATE_SWAGGER_MAPPINGS) + return _prepare_mapping_and_regenerate( + c, + mapping, + _SwaggerGroup.VANILLA, + swagger_name, + debug, + low_level_client=True, + **kwargs + ) + +@task +def regenerate_azure_legacy(c, swagger_name=None, debug=False, **kwargs): + return _prepare_mapping_and_regenerate(c, _AZURE_SWAGGER_MAPPINGS, _SwaggerGroup.AZURE, swagger_name, debug, **kwargs) + +@task +def regenerate_azure_llc(c, swagger_name=None, debug=False, **kwargs): + return _prepare_mapping_and_regenerate(c, _AZURE_SWAGGER_MAPPINGS, _SwaggerGroup.AZURE, swagger_name, debug, low_level_client=True, **kwargs) + +@task +def regenerate_azure_arm_legacy(c, swagger_name=None, debug=False, **kwargs): + return _prepare_mapping_and_regenerate(c, _AZURE_ARM_SWAGGER_MAPPINGS, _SwaggerGroup.AZURE_ARM, swagger_name, debug, **kwargs) + +@task +def regenerate_azure_arm_llc(c, swagger_name=None, debug=False, **kwargs): + return _prepare_mapping_and_regenerate(c, _AZURE_ARM_SWAGGER_MAPPINGS, _SwaggerGroup.AZURE_ARM, swagger_name, debug, low_level_client=True, **kwargs) @task def regenerate_namespace_folders_test(c, debug=False): @@ -257,13 +294,12 @@ def regenerate_package_name_setup_py(c, debug=False): } _regenerate(mapping, debug, swagger_group=_SwaggerGroup.VANILLA, override_flags=override_flags) - @task -def regenerate(c, swagger_name=None, debug=False): +def regenerate_legacy(c, swagger_name=None, debug=False): # regenerate expected code for tests - regenerate_vanilla(c, swagger_name, debug) - regenerate_azure(c, swagger_name, debug) - regenerate_azure_arm(c, swagger_name, debug) + regenerate_vanilla_legacy(c, swagger_name, debug) + regenerate_azure_legacy(c, swagger_name, debug) + regenerate_azure_arm_legacy(c, swagger_name, debug) if not swagger_name: regenerate_namespace_folders_test(c, debug) regenerate_multiapi(c, debug) @@ -273,6 +309,17 @@ def regenerate(c, swagger_name=None, debug=False): regenerate_samples(c, debug) +@task +def regenerate(c, swagger_name=None, debug=False): + regenerate_legacy(c, swagger_name, debug) + regenerate_llc(c, swagger_name, debug) + +@task +def regenerate_llc(c, swagger_name=None, debug=False): + regenerate_vanilla_llc(c, swagger_name, debug) + regenerate_azure_llc(c, swagger_name, debug) + regenerate_azure_arm_llc(c, swagger_name, debug) + @task def test(c, env=None): # run language-specific tests @@ -283,34 +330,15 @@ def test(c, env=None): os.chdir(f"{base_dir}/test/azure/") c.run(cmd) - -@task -def regenerate_services(c, swagger_name=None, debug=False): - # regenerate service from swagger - if swagger_name: - service_mapping = {k: v for k, v in _SERVICE_TO_README_PATH.items() if swagger_name.lower() in k.lower()} - else: - service_mapping = _SERVICE_TO_README_PATH - - cmds = [] - for service in service_mapping: - readme_path = _SERVICE_TO_README_PATH[service] - service = service.strip() - cmd_line = f'autorest {readme_path} --use=. --output-artifact=code-model-v4-no-tags' - if debug: - cmd_line += " --debug" - print(Fore.YELLOW + f'Queuing up: {cmd_line}') - cmds.append(cmd_line) - - _run_autorest(cmds[0], debug) - - -def _multiapi_command_line(location): +def _multiapi_command_line(location, debug): cwd = os.getcwd() - return ( + cmd = ( f'autorest {location} --use=. --multiapi --output-artifact=code-model-v4-no-tags ' + f'--python-sdks-folder={cwd}/test/' ) + if debug: + cmd += " --python.debugger" + return cmd @task def regenerate_multiapi(c, debug=False, swagger_name="test"): @@ -330,7 +358,7 @@ def regenerate_multiapi(c, debug=False, swagger_name="test"): "test/multiapi/specification/multiapicustombaseurl/README.md", ] - cmds = [_multiapi_command_line(spec) for spec in available_specifications if swagger_name.lower() in spec] + cmds = [_multiapi_command_line(spec, debug) for spec in available_specifications if swagger_name.lower() in spec] _run_autorest(cmds, debug) @@ -338,7 +366,7 @@ def regenerate_multiapi(c, debug=False, swagger_name="test"): def regenerate_custom_poller_pager(c, debug=False): cwd = os.getcwd() cmd = ( - f'autorest test/azure/specification/custompollerpager/README.md --use=. --python-sdks-folder={cwd}/test/' + f'autorest test/azure/legacy/specification/custompollerpager/README.md --use=. --python-sdks-folder={cwd}/test/' ) _run_autorest([cmd], debug=debug) diff --git a/test/azure/AcceptanceTests.cs b/test/azure/AcceptanceTests.cs deleted file mode 100644 index 3ba4b752aaa..00000000000 --- a/test/azure/AcceptanceTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System.IO; -using AutoRest.Swagger.Tests; -using Xunit; - -namespace AutoRest.Python.Azure.Tests -{ - [Collection("AutoRest Azure Python Tests")] - public static class AcceptanceTests - { - private static string ExpectedPath(string file) - { - return Path.Combine("Expected", "AcceptanceTests", file); - } - - private static string SwaggerPath(string file) - { - return Path.Combine("Swagger", file); - } - - [Fact] - public static void SampleTestForGeneratingPython() - { - SwaggerSpecHelper.RunTests( - SwaggerPath("storage.json"), - ExpectedPath("StorageManagementClient"), - plugin:"Azure.Python", - nameSpace: "fixtures.acceptancetestsstoragemanagementclient"); - } - } -} diff --git a/test/azure/AcceptanceTests/conftest.py b/test/azure/AcceptanceTests/conftest.py deleted file mode 100644 index cc563b5bb32..00000000000 --- a/test/azure/AcceptanceTests/conftest.py +++ /dev/null @@ -1,107 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 glob -import sys -import subprocess -import os -import signal -from os.path import dirname, realpath -from unittest import TestLoader, TextTestRunner - -from os.path import dirname, pardir, join, realpath - -from azure.core.pipeline.policies import SansIOHTTPPolicy - -import pytest - - -cwd = dirname(realpath(__file__)) - -#Ideally this would be in a common helper library shared between the tests -def start_server_process(): - cmd = "node {}/../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) - if os.name == 'nt': #On windows, subprocess creation works without being in the shell - return subprocess.Popen(cmd) - - return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True - -#Ideally this would be in a common helper library shared between the tests -def terminate_server_process(process): - if os.name == 'nt': - process.kill() - else: - os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups - -@pytest.fixture(scope="session") -def testserver(): - """Start the Autorest testserver.""" - server = start_server_process() - yield - terminate_server_process(server) - -# Ignore collection of async tests for Python 2 -collect_ignore = [] -if sys.version_info < (3,5): - collect_ignore.append("asynctests") - - -class CookiePolicy(SansIOHTTPPolicy): - def __init__(self, *args, **kwargs): - self._current_cookie = None - - def on_request(self, request, **kwargs): - # type: (PipelineRequest, Any) -> None - http_request = request.http_request - if self._current_cookie: - http_request.headers["Cookie"] = self._current_cookie - self._current_cookie = None - - def on_response(self, request, response, **kwargs): - # type: (PipelineRequest, PipelineResponse, Any) -> None - http_response = response.http_response - - if "Set-Cookie" in http_response.headers: - self._current_cookie = http_response.headers["Set-Cookie"] - -@pytest.fixture() -def cookie_policy(): - return CookiePolicy() - - -@pytest.fixture() -def credential(): - """I actually don't need anything, since the authentication policy - will bypass it. - """ - class FakeCredential: - pass - return FakeCredential() - -@pytest.fixture() -def authentication_policy(): - from azure.core.pipeline.policies import SansIOHTTPPolicy - return SansIOHTTPPolicy() \ No newline at end of file diff --git a/test/azure/Expected/AcceptanceTests/.gitattributes b/test/azure/Expected/AcceptanceTests/.gitattributes deleted file mode 100644 index aa9962141fb..00000000000 --- a/test/azure/Expected/AcceptanceTests/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.py eol=lf \ No newline at end of file diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_auto_rest_duration_test_service.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_auto_rest_duration_test_service.py deleted file mode 100644 index 644e71de070..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_auto_rest_duration_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestDurationTestServiceConfiguration -from .operations import DurationOperations -from . import models - - -class AutoRestDurationTestService(object): - """Test Infrastructure for AutoRest. - - :ivar duration: DurationOperations operations - :vartype duration: bodyduration.operations.DurationOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDurationTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.duration = DurationOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestDurationTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py deleted file mode 100644 index 1f956fba577..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestDurationTestServiceConfiguration -from .operations import DurationOperations -from .. import models - - -class AutoRestDurationTestService(object): - """Test Infrastructure for AutoRest. - - :ivar duration: DurationOperations operations - :vartype duration: bodyduration.aio.operations.DurationOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDurationTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.duration = DurationOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestDurationTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py deleted file mode 100644 index cf8abe6538b..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py +++ /dev/null @@ -1,220 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DurationOperations: - """DurationOperations 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: ~bodyduration.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 get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: - """Get null duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta or None, or the result of cls(response) - :rtype: ~datetime.timedelta or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/duration/null"} # type: ignore - - @distributed_trace_async - async def put_positive_duration(self, duration_body: datetime.timedelta, **kwargs: Any) -> None: - """Put a positive duration value. - - :param duration_body: duration body. - :type duration_body: ~datetime.timedelta - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(duration_body, "duration") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace_async - async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: - """Get a positive duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: - """Get an invalid duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py deleted file mode 100644 index 72de7e128df..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py +++ /dev/null @@ -1,238 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class DurationOperations(object): - """DurationOperations 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: ~bodyduration.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[datetime.timedelta] - """Get null duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta or None, or the result of cls(response) - :rtype: ~datetime.timedelta or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/duration/null"} # type: ignore - - @distributed_trace - def put_positive_duration( - self, - duration_body, # type: datetime.timedelta - **kwargs # type: Any - ): - # type: (...) -> None - """Put a positive duration value. - - :param duration_body: duration body. - :type duration_body: ~datetime.timedelta - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(duration_body, "duration") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace - def get_positive_duration( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.timedelta - """Get a positive duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.timedelta - """Get an invalid duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/setup.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/setup.py deleted file mode 100644 index 47f4913beda..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestdurationtestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestDurationTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestDurationTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_auto_rest_parameter_grouping_test_service.py b/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_auto_rest_parameter_grouping_test_service.py deleted file mode 100644 index 18df59faa0d..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_auto_rest_parameter_grouping_test_service.py +++ /dev/null @@ -1,78 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestParameterGroupingTestServiceConfiguration -from .operations import ParameterGroupingOperations -from . import models - - -class AutoRestParameterGroupingTestService(object): - """Test Infrastructure for AutoRest. - - :ivar parameter_grouping: ParameterGroupingOperations operations - :vartype parameter_grouping: azureparametergrouping.operations.ParameterGroupingOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestParameterGroupingTestServiceConfiguration(**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.parameter_grouping = ParameterGroupingOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestParameterGroupingTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_auto_rest_parameter_grouping_test_service.py b/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_auto_rest_parameter_grouping_test_service.py deleted file mode 100644 index db844015c17..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_auto_rest_parameter_grouping_test_service.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestParameterGroupingTestServiceConfiguration -from .operations import ParameterGroupingOperations -from .. import models - - -class AutoRestParameterGroupingTestService(object): - """Test Infrastructure for AutoRest. - - :ivar parameter_grouping: ParameterGroupingOperations operations - :vartype parameter_grouping: azureparametergrouping.aio.operations.ParameterGroupingOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestParameterGroupingTestServiceConfiguration(**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.parameter_grouping = ParameterGroupingOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestParameterGroupingTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py b/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py deleted file mode 100644 index 4440aa99b7f..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py +++ /dev/null @@ -1,345 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ParameterGroupingOperations: - """ParameterGroupingOperations 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: ~azureparametergrouping.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 post_required( - self, - parameter_grouping_post_required_parameters: "_models.ParameterGroupingPostRequiredParameters", - **kwargs: Any - ) -> None: - """Post a bunch of required parameters grouped. - - :param parameter_grouping_post_required_parameters: Parameter group. - :type parameter_grouping_post_required_parameters: ~azureparametergrouping.models.ParameterGroupingPostRequiredParameters - :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", {})) - - _custom_header = None - _query = None - _path = None - _body = None - if parameter_grouping_post_required_parameters is not None: - _custom_header = parameter_grouping_post_required_parameters.custom_header - _query = parameter_grouping_post_required_parameters.query - _path = parameter_grouping_post_required_parameters.path - _body = parameter_grouping_post_required_parameters.body - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required.metadata["url"] # type: ignore - path_format_arguments = { - "path": self._serialize.url("path", _path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query is not None: - query_parameters["query"] = self._serialize.query("query", _query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _custom_header is not None: - header_parameters["customHeader"] = self._serialize.header("custom_header", _custom_header, "str") - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, "int") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required.metadata = {"url": "/parameterGrouping/postRequired/{path}"} # type: ignore - - @distributed_trace_async - async def post_optional( - self, - parameter_grouping_post_optional_parameters: Optional["_models.ParameterGroupingPostOptionalParameters"] = None, - **kwargs: Any - ) -> None: - """Post a bunch of optional parameters grouped. - - :param parameter_grouping_post_optional_parameters: Parameter group. - :type parameter_grouping_post_optional_parameters: ~azureparametergrouping.models.ParameterGroupingPostOptionalParameters - :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", {})) - - _custom_header = None - _query = None - if parameter_grouping_post_optional_parameters is not None: - _custom_header = parameter_grouping_post_optional_parameters.custom_header - _query = parameter_grouping_post_optional_parameters.query - accept = "application/json" - - # Construct URL - url = self.post_optional.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query is not None: - query_parameters["query"] = self._serialize.query("query", _query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _custom_header is not None: - header_parameters["customHeader"] = self._serialize.header("custom_header", _custom_header, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional.metadata = {"url": "/parameterGrouping/postOptional"} # type: ignore - - @distributed_trace_async - async def post_reserved_words( - self, - parameter_grouping_post_reserved_words_parameters: Optional[ - "_models.ParameterGroupingPostReservedWordsParameters" - ] = None, - **kwargs: Any - ) -> None: - """Post a grouped parameters with reserved words. - - :param parameter_grouping_post_reserved_words_parameters: Parameter group. - :type parameter_grouping_post_reserved_words_parameters: ~azureparametergrouping.models.ParameterGroupingPostReservedWordsParameters - :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", {})) - - _from = None - _accept = None - if parameter_grouping_post_reserved_words_parameters is not None: - _from = parameter_grouping_post_reserved_words_parameters.from_property - _accept = parameter_grouping_post_reserved_words_parameters.accept - accept = "application/json" - - # Construct URL - url = self.post_reserved_words.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _from is not None: - query_parameters["from"] = self._serialize.query("from", _from, "str") - if _accept is not None: - query_parameters["accept"] = self._serialize.query("accept", _accept, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_reserved_words.metadata = {"url": "/parameterGrouping/postReservedWords"} # type: ignore - - @distributed_trace_async - async def post_multi_param_groups( - self, - first_parameter_group: Optional["_models.FirstParameterGroup"] = None, - parameter_grouping_post_multi_param_groups_second_param_group: Optional[ - "_models.ParameterGroupingPostMultiParamGroupsSecondParamGroup" - ] = None, - **kwargs: Any - ) -> None: - """Post parameters from multiple different parameter groups. - - :param first_parameter_group: Parameter group. - :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup - :param parameter_grouping_post_multi_param_groups_second_param_group: Parameter group. - :type parameter_grouping_post_multi_param_groups_second_param_group: ~azureparametergrouping.models.ParameterGroupingPostMultiParamGroupsSecondParamGroup - :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", {})) - - _header_one = None - _query_one = None - _header_two = None - _query_two = None - if first_parameter_group is not None: - _header_one = first_parameter_group.header_one - _query_one = first_parameter_group.query_one - if parameter_grouping_post_multi_param_groups_second_param_group is not None: - _header_two = parameter_grouping_post_multi_param_groups_second_param_group.header_two - _query_two = parameter_grouping_post_multi_param_groups_second_param_group.query_two - accept = "application/json" - - # Construct URL - url = self.post_multi_param_groups.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query_one is not None: - query_parameters["query-one"] = self._serialize.query("query_one", _query_one, "int") - if _query_two is not None: - query_parameters["query-two"] = self._serialize.query("query_two", _query_two, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _header_one is not None: - header_parameters["header-one"] = self._serialize.header("header_one", _header_one, "str") - if _header_two is not None: - header_parameters["header-two"] = self._serialize.header("header_two", _header_two, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_multi_param_groups.metadata = {"url": "/parameterGrouping/postMultipleParameterGroups"} # type: ignore - - @distributed_trace_async - async def post_shared_parameter_group_object( - self, first_parameter_group: Optional["_models.FirstParameterGroup"] = None, **kwargs: Any - ) -> None: - """Post parameters with a shared parameter group object. - - :param first_parameter_group: Parameter group. - :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup - :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", {})) - - _header_one = None - _query_one = None - if first_parameter_group is not None: - _header_one = first_parameter_group.header_one - _query_one = first_parameter_group.query_one - accept = "application/json" - - # Construct URL - url = self.post_shared_parameter_group_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query_one is not None: - query_parameters["query-one"] = self._serialize.query("query_one", _query_one, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _header_one is not None: - header_parameters["header-one"] = self._serialize.header("header_one", _header_one, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_shared_parameter_group_object.metadata = {"url": "/parameterGrouping/sharedParameterGroupObject"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py b/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py deleted file mode 100644 index de8312488ff..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py +++ /dev/null @@ -1,352 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class ParameterGroupingOperations(object): - """ParameterGroupingOperations 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: ~azureparametergrouping.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 post_required( - self, - parameter_grouping_post_required_parameters, # type: "_models.ParameterGroupingPostRequiredParameters" - **kwargs # type: Any - ): - # type: (...) -> None - """Post a bunch of required parameters grouped. - - :param parameter_grouping_post_required_parameters: Parameter group. - :type parameter_grouping_post_required_parameters: ~azureparametergrouping.models.ParameterGroupingPostRequiredParameters - :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", {})) - - _custom_header = None - _query = None - _path = None - _body = None - if parameter_grouping_post_required_parameters is not None: - _custom_header = parameter_grouping_post_required_parameters.custom_header - _query = parameter_grouping_post_required_parameters.query - _path = parameter_grouping_post_required_parameters.path - _body = parameter_grouping_post_required_parameters.body - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required.metadata["url"] # type: ignore - path_format_arguments = { - "path": self._serialize.url("path", _path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query is not None: - query_parameters["query"] = self._serialize.query("query", _query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _custom_header is not None: - header_parameters["customHeader"] = self._serialize.header("custom_header", _custom_header, "str") - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, "int") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required.metadata = {"url": "/parameterGrouping/postRequired/{path}"} # type: ignore - - @distributed_trace - def post_optional( - self, - parameter_grouping_post_optional_parameters=None, # type: Optional["_models.ParameterGroupingPostOptionalParameters"] - **kwargs # type: Any - ): - # type: (...) -> None - """Post a bunch of optional parameters grouped. - - :param parameter_grouping_post_optional_parameters: Parameter group. - :type parameter_grouping_post_optional_parameters: ~azureparametergrouping.models.ParameterGroupingPostOptionalParameters - :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", {})) - - _custom_header = None - _query = None - if parameter_grouping_post_optional_parameters is not None: - _custom_header = parameter_grouping_post_optional_parameters.custom_header - _query = parameter_grouping_post_optional_parameters.query - accept = "application/json" - - # Construct URL - url = self.post_optional.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query is not None: - query_parameters["query"] = self._serialize.query("query", _query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _custom_header is not None: - header_parameters["customHeader"] = self._serialize.header("custom_header", _custom_header, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional.metadata = {"url": "/parameterGrouping/postOptional"} # type: ignore - - @distributed_trace - def post_reserved_words( - self, - parameter_grouping_post_reserved_words_parameters=None, # type: Optional["_models.ParameterGroupingPostReservedWordsParameters"] - **kwargs # type: Any - ): - # type: (...) -> None - """Post a grouped parameters with reserved words. - - :param parameter_grouping_post_reserved_words_parameters: Parameter group. - :type parameter_grouping_post_reserved_words_parameters: ~azureparametergrouping.models.ParameterGroupingPostReservedWordsParameters - :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", {})) - - _from = None - _accept = None - if parameter_grouping_post_reserved_words_parameters is not None: - _from = parameter_grouping_post_reserved_words_parameters.from_property - _accept = parameter_grouping_post_reserved_words_parameters.accept - accept = "application/json" - - # Construct URL - url = self.post_reserved_words.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _from is not None: - query_parameters["from"] = self._serialize.query("from", _from, "str") - if _accept is not None: - query_parameters["accept"] = self._serialize.query("accept", _accept, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_reserved_words.metadata = {"url": "/parameterGrouping/postReservedWords"} # type: ignore - - @distributed_trace - def post_multi_param_groups( - self, - first_parameter_group=None, # type: Optional["_models.FirstParameterGroup"] - parameter_grouping_post_multi_param_groups_second_param_group=None, # type: Optional["_models.ParameterGroupingPostMultiParamGroupsSecondParamGroup"] - **kwargs # type: Any - ): - # type: (...) -> None - """Post parameters from multiple different parameter groups. - - :param first_parameter_group: Parameter group. - :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup - :param parameter_grouping_post_multi_param_groups_second_param_group: Parameter group. - :type parameter_grouping_post_multi_param_groups_second_param_group: ~azureparametergrouping.models.ParameterGroupingPostMultiParamGroupsSecondParamGroup - :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", {})) - - _header_one = None - _query_one = None - _header_two = None - _query_two = None - if first_parameter_group is not None: - _header_one = first_parameter_group.header_one - _query_one = first_parameter_group.query_one - if parameter_grouping_post_multi_param_groups_second_param_group is not None: - _header_two = parameter_grouping_post_multi_param_groups_second_param_group.header_two - _query_two = parameter_grouping_post_multi_param_groups_second_param_group.query_two - accept = "application/json" - - # Construct URL - url = self.post_multi_param_groups.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query_one is not None: - query_parameters["query-one"] = self._serialize.query("query_one", _query_one, "int") - if _query_two is not None: - query_parameters["query-two"] = self._serialize.query("query_two", _query_two, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _header_one is not None: - header_parameters["header-one"] = self._serialize.header("header_one", _header_one, "str") - if _header_two is not None: - header_parameters["header-two"] = self._serialize.header("header_two", _header_two, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_multi_param_groups.metadata = {"url": "/parameterGrouping/postMultipleParameterGroups"} # type: ignore - - @distributed_trace - def post_shared_parameter_group_object( - self, - first_parameter_group=None, # type: Optional["_models.FirstParameterGroup"] - **kwargs # type: Any - ): - # type: (...) -> None - """Post parameters with a shared parameter group object. - - :param first_parameter_group: Parameter group. - :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup - :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", {})) - - _header_one = None - _query_one = None - if first_parameter_group is not None: - _header_one = first_parameter_group.header_one - _query_one = first_parameter_group.query_one - accept = "application/json" - - # Construct URL - url = self.post_shared_parameter_group_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if _query_one is not None: - query_parameters["query-one"] = self._serialize.query("query_one", _query_one, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _header_one is not None: - header_parameters["header-one"] = self._serialize.header("header_one", _header_one, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_shared_parameter_group_object.metadata = {"url": "/parameterGrouping/sharedParameterGroupObject"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/setup.py b/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/setup.py deleted file mode 100644 index c6a072189df..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestparametergroupingtestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestParameterGroupingTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestParameterGroupingTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_auto_rest_report_service_for_azure.py b/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_auto_rest_report_service_for_azure.py deleted file mode 100644 index f4a55ac2089..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_auto_rest_report_service_for_azure.py +++ /dev/null @@ -1,73 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestReportServiceForAzureConfiguration -from .operations import AutoRestReportServiceForAzureOperationsMixin -from . import models - - -class AutoRestReportServiceForAzure(AutoRestReportServiceForAzureOperationsMixin): - """Test Infrastructure for AutoRest. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestReportServiceForAzureConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestReportServiceForAzure - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/_auto_rest_report_service_for_azure.py b/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/_auto_rest_report_service_for_azure.py deleted file mode 100644 index 97765345818..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/_auto_rest_report_service_for_azure.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestReportServiceForAzureConfiguration -from .operations import AutoRestReportServiceForAzureOperationsMixin -from .. import models - - -class AutoRestReportServiceForAzure(AutoRestReportServiceForAzureOperationsMixin): - """Test Infrastructure for AutoRest. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestReportServiceForAzureConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestReportServiceForAzure": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py b/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py deleted file mode 100644 index 9c6580827ab..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py +++ /dev/null @@ -1,75 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoRestReportServiceForAzureOperationsMixin: - @distributed_trace_async - async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str, int]: - """Get test coverage report. - - :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in - for Python). The only effect is, that generators that run all tests several times, can - distinguish the generated reports. - :type qualifier: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_report.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if qualifier is not None: - query_parameters["qualifier"] = self._serialize.query("qualifier", qualifier, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_report.metadata = {"url": "/report/azure"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py b/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py deleted file mode 100644 index 35215d0ba1f..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py +++ /dev/null @@ -1,84 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class AutoRestReportServiceForAzureOperationsMixin(object): - @distributed_trace - def get_report( - self, - qualifier=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get test coverage report. - - :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in - for Python). The only effect is, that generators that run all tests several times, can - distinguish the generated reports. - :type qualifier: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_report.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if qualifier is not None: - query_parameters["qualifier"] = self._serialize.query("qualifier", qualifier, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_report.metadata = {"url": "/report/azure"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/setup.py b/test/azure/Expected/AcceptanceTests/AzureReport/setup.py deleted file mode 100644 index 0e5691390f5..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureReport/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestreportserviceforazure" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestReportServiceForAzure", - author_email="", - url="", - keywords=["Swagger", "AutoRestReportServiceForAzure"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_auto_rest_azure_special_parameters_test_client.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_auto_rest_azure_special_parameters_test_client.py deleted file mode 100644 index 29509344df1..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_auto_rest_azure_special_parameters_test_client.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration -from .operations import XMsClientRequestIdOperations -from .operations import SubscriptionInCredentialsOperations -from .operations import SubscriptionInMethodOperations -from .operations import ApiVersionDefaultOperations -from .operations import ApiVersionLocalOperations -from .operations import SkipUrlEncodingOperations -from .operations import OdataOperations -from .operations import HeaderOperations -from . import models - - -class AutoRestAzureSpecialParametersTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar xms_client_request_id: XMsClientRequestIdOperations operations - :vartype xms_client_request_id: azurespecialproperties.operations.XMsClientRequestIdOperations - :ivar subscription_in_credentials: SubscriptionInCredentialsOperations operations - :vartype subscription_in_credentials: azurespecialproperties.operations.SubscriptionInCredentialsOperations - :ivar subscription_in_method: SubscriptionInMethodOperations operations - :vartype subscription_in_method: azurespecialproperties.operations.SubscriptionInMethodOperations - :ivar api_version_default: ApiVersionDefaultOperations operations - :vartype api_version_default: azurespecialproperties.operations.ApiVersionDefaultOperations - :ivar api_version_local: ApiVersionLocalOperations operations - :vartype api_version_local: azurespecialproperties.operations.ApiVersionLocalOperations - :ivar skip_url_encoding: SkipUrlEncodingOperations operations - :vartype skip_url_encoding: azurespecialproperties.operations.SkipUrlEncodingOperations - :ivar odata: OdataOperations operations - :vartype odata: azurespecialproperties.operations.OdataOperations - :ivar header: HeaderOperations operations - :vartype header: azurespecialproperties.operations.HeaderOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription id, which appears in the path, always modeled in credentials. The value is always '1234-5678-9012-3456'. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestAzureSpecialParametersTestClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(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.xms_client_request_id = XMsClientRequestIdOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscription_in_credentials = SubscriptionInCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscription_in_method = SubscriptionInMethodOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.api_version_default = ApiVersionDefaultOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.api_version_local = ApiVersionLocalOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skip_url_encoding = SkipUrlEncodingOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.odata = OdataOperations(self._client, self._config, self._serialize, self._deserialize) - self.header = HeaderOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestAzureSpecialParametersTestClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_auto_rest_azure_special_parameters_test_client.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_auto_rest_azure_special_parameters_test_client.py deleted file mode 100644 index fac9d7d28b4..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_auto_rest_azure_special_parameters_test_client.py +++ /dev/null @@ -1,115 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration -from .operations import XMsClientRequestIdOperations -from .operations import SubscriptionInCredentialsOperations -from .operations import SubscriptionInMethodOperations -from .operations import ApiVersionDefaultOperations -from .operations import ApiVersionLocalOperations -from .operations import SkipUrlEncodingOperations -from .operations import OdataOperations -from .operations import HeaderOperations -from .. import models - - -class AutoRestAzureSpecialParametersTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar xms_client_request_id: XMsClientRequestIdOperations operations - :vartype xms_client_request_id: azurespecialproperties.aio.operations.XMsClientRequestIdOperations - :ivar subscription_in_credentials: SubscriptionInCredentialsOperations operations - :vartype subscription_in_credentials: azurespecialproperties.aio.operations.SubscriptionInCredentialsOperations - :ivar subscription_in_method: SubscriptionInMethodOperations operations - :vartype subscription_in_method: azurespecialproperties.aio.operations.SubscriptionInMethodOperations - :ivar api_version_default: ApiVersionDefaultOperations operations - :vartype api_version_default: azurespecialproperties.aio.operations.ApiVersionDefaultOperations - :ivar api_version_local: ApiVersionLocalOperations operations - :vartype api_version_local: azurespecialproperties.aio.operations.ApiVersionLocalOperations - :ivar skip_url_encoding: SkipUrlEncodingOperations operations - :vartype skip_url_encoding: azurespecialproperties.aio.operations.SkipUrlEncodingOperations - :ivar odata: OdataOperations operations - :vartype odata: azurespecialproperties.aio.operations.OdataOperations - :ivar header: HeaderOperations operations - :vartype header: azurespecialproperties.aio.operations.HeaderOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription id, which appears in the path, always modeled in credentials. The value is always '1234-5678-9012-3456'. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestAzureSpecialParametersTestClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(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.xms_client_request_id = XMsClientRequestIdOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscription_in_credentials = SubscriptionInCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscription_in_method = SubscriptionInMethodOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.api_version_default = ApiVersionDefaultOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.api_version_local = ApiVersionLocalOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skip_url_encoding = SkipUrlEncodingOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.odata = OdataOperations(self._client, self._config, self._serialize, self._deserialize) - self.header = HeaderOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestAzureSpecialParametersTestClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py deleted file mode 100644 index e2833056353..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py +++ /dev/null @@ -1,209 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiVersionDefaultOperations: - """ApiVersionDefaultOperations 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: ~azurespecialproperties.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 get_method_global_valid(self, **kwargs: Any) -> None: - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_method_global_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_global_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview"} # type: ignore - - @distributed_trace_async - async def get_method_global_not_provided_valid(self, **kwargs: Any) -> None: - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_method_global_not_provided_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_global_not_provided_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview"} # type: ignore - - @distributed_trace_async - async def get_path_global_valid(self, **kwargs: Any) -> None: - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_path_global_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_global_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview"} # type: ignore - - @distributed_trace_async - async def get_swagger_global_valid(self, **kwargs: Any) -> None: - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_swagger_global_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_global_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py deleted file mode 100644 index 8f31f8315a7..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py +++ /dev/null @@ -1,212 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiVersionLocalOperations: - """ApiVersionLocalOperations 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: ~azurespecialproperties.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 get_method_local_valid(self, **kwargs: Any) -> None: - """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. - - :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", {})) - api_version = "2.0" - accept = "application/json" - - # Construct URL - url = self.get_method_local_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_local_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/2.0"} # type: ignore - - @distributed_trace_async - async def get_method_local_null(self, api_version: Optional[str] = None, **kwargs: Any) -> None: - """Get method with api-version modeled in the method. pass in api-version = null to succeed. - - :param api_version: This should appear as a method parameter, use value null, this should - result in no serialized parameter. - :type api_version: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_local_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if api_version is not None: - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_local_null.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/null"} # type: ignore - - @distributed_trace_async - async def get_path_local_valid(self, **kwargs: Any) -> None: - """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. - - :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", {})) - api_version = "2.0" - accept = "application/json" - - # Construct URL - url = self.get_path_local_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_local_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/local/2.0"} # type: ignore - - @distributed_trace_async - async def get_swagger_local_valid(self, **kwargs: Any) -> None: - """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. - - :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", {})) - api_version = "2.0" - accept = "application/json" - - # Construct URL - url = self.get_swagger_local_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_local_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/local/2.0"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py deleted file mode 100644 index 479a862fc57..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py +++ /dev/null @@ -1,199 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HeaderOperations: - """HeaderOperations 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: ~azurespecialproperties.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 custom_named_request_id(self, foo_client_request_id: str, **kwargs: Any) -> None: - """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. - - :param foo_client_request_id: The fooRequestId. - :type foo_client_request_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.custom_named_request_id.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["foo-client-request-id"] = self._serialize.header( - "foo_client_request_id", foo_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) - - if cls: - return cls(pipeline_response, None, response_headers) - - custom_named_request_id.metadata = {"url": "/azurespecials/customNamedRequestId"} # type: ignore - - @distributed_trace_async - async def custom_named_request_id_param_grouping( - self, - header_custom_named_request_id_param_grouping_parameters: "_models.HeaderCustomNamedRequestIdParamGroupingParameters", - **kwargs: Any - ) -> None: - """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, - via a parameter group. - - :param header_custom_named_request_id_param_grouping_parameters: Parameter group. - :type header_custom_named_request_id_param_grouping_parameters: ~azurespecialproperties.models.HeaderCustomNamedRequestIdParamGroupingParameters - :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", {})) - - _foo_client_request_id = None - if header_custom_named_request_id_param_grouping_parameters is not None: - _foo_client_request_id = header_custom_named_request_id_param_grouping_parameters.foo_client_request_id - accept = "application/json" - - # Construct URL - url = self.custom_named_request_id_param_grouping.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["foo-client-request-id"] = self._serialize.header( - "foo_client_request_id", _foo_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) - - if cls: - return cls(pipeline_response, None, response_headers) - - custom_named_request_id_param_grouping.metadata = {"url": "/azurespecials/customNamedRequestIdParamGrouping"} # type: ignore - - @distributed_trace_async - async def custom_named_request_id_head(self, foo_client_request_id: str, **kwargs: Any) -> bool: - """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. - - :param foo_client_request_id: The fooRequestId. - :type foo_client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - accept = "application/json" - - # Construct URL - url = self.custom_named_request_id_head.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["foo-client-request-id"] = self._serialize.header( - "foo_client_request_id", foo_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) - - if cls: - return cls(pipeline_response, None, response_headers) - - return 200 <= response.status_code <= 299 - - custom_named_request_id_head.metadata = {"url": "/azurespecials/customNamedRequestIdHead"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py deleted file mode 100644 index cfb418eb430..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py +++ /dev/null @@ -1,101 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class OdataOperations: - """OdataOperations 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: ~azurespecialproperties.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 get_with_filter( - self, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> None: - """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. - - :param filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. - :type filter: str - :param top: The top parameter with value 10. - :type top: int - :param orderby: The orderby parameter with value id. - :type orderby: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_with_filter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters["$filter"] = self._serialize.query("filter", filter, "str") - if top is not None: - query_parameters["$top"] = self._serialize.query("top", top, "int") - if orderby is not None: - query_parameters["$orderby"] = self._serialize.query("orderby", orderby, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_with_filter.metadata = {"url": "/azurespecials/odata/filter"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py deleted file mode 100644 index 9eb4efc2742..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py +++ /dev/null @@ -1,350 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SkipUrlEncodingOperations: - """SkipUrlEncodingOperations 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: ~azurespecialproperties.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 get_method_path_valid(self, unencoded_path_param: str, **kwargs: Any) -> None: - """Get method with unencoded path parameter with value 'path1/path2/path3'. - - :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. - :type unencoded_path_param: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_path_valid.metadata["url"] # type: ignore - path_format_arguments = { - "unencodedPathParam": self._serialize.url( - "unencoded_path_param", unencoded_path_param, "str", skip_quote=True - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}"} # type: ignore - - @distributed_trace_async - async def get_path_valid(self, unencoded_path_param: str, **kwargs: Any) -> None: - """Get method with unencoded path parameter with value 'path1/path2/path3'. - - :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. - :type unencoded_path_param: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_path_valid.metadata["url"] # type: ignore - path_format_arguments = { - "unencodedPathParam": self._serialize.url( - "unencoded_path_param", unencoded_path_param, "str", skip_quote=True - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}"} # type: ignore - - @distributed_trace_async - async def get_swagger_path_valid(self, **kwargs: Any) -> None: - """Get method with unencoded path parameter with value 'path1/path2/path3'. - - :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", {})) - unencoded_path_param = "path1/path2/path3" - accept = "application/json" - - # Construct URL - url = self.get_swagger_path_valid.metadata["url"] # type: ignore - path_format_arguments = { - "unencodedPathParam": self._serialize.url( - "unencoded_path_param", unencoded_path_param, "str", skip_quote=True - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}"} # type: ignore - - @distributed_trace_async - async def get_method_query_valid(self, q1: str, **kwargs: Any) -> None: - """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. - - :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. - :type q1: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_query_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/valid"} # type: ignore - - @distributed_trace_async - async def get_method_query_null(self, q1: Optional[str] = None, **kwargs: Any) -> None: - """Get method with unencoded query parameter with value null. - - :param q1: Unencoded query parameter with value null. - :type q1: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_query_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if q1 is not None: - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_query_null.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/null"} # type: ignore - - @distributed_trace_async - async def get_path_query_valid(self, q1: str, **kwargs: Any) -> None: - """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. - - :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. - :type q1: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_path_query_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/query/valid"} # type: ignore - - @distributed_trace_async - async def get_swagger_query_valid(self, **kwargs: Any) -> None: - """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. - - :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", {})) - q1 = "value1&q2=value2&q3=value3" - accept = "application/json" - - # Construct URL - url = self.get_swagger_query_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/query/valid"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py deleted file mode 100644 index b7c3dcab16b..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py +++ /dev/null @@ -1,266 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SubscriptionInCredentialsOperations: - """SubscriptionInCredentialsOperations 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: ~azurespecialproperties.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 post_method_global_valid(self, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_global_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_global_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_method_global_null(self, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - null, and client-side validation should prevent you from making this call. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_global_null.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_global_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_method_global_not_provided_valid(self, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.post_method_global_not_provided_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_global_not_provided_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_path_global_valid(self, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_path_global_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_path_global_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_swagger_global_valid(self, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_swagger_global_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_swagger_global_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py deleted file mode 100644 index f357df9225d..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py +++ /dev/null @@ -1,232 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SubscriptionInMethodOperations: - """SubscriptionInMethodOperations 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: ~azurespecialproperties.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 post_method_local_valid(self, subscription_id: str, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in the method. pass in subscription id = - '1234-5678-9012-3456' to succeed. - - :param subscription_id: This should appear as a method parameter, use value - '1234-5678-9012-3456'. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_local_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_local_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_method_local_null(self, subscription_id: str, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in the method. pass in subscription id = null, - client-side validation should prevent you from making this call. - - :param subscription_id: This should appear as a method parameter, use value null, client-side - validation should prvenet the call. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_local_null.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_local_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_path_local_valid(self, subscription_id: str, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in the method. pass in subscription id = - '1234-5678-9012-3456' to succeed. - - :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_path_local_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_path_local_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace_async - async def post_swagger_local_valid(self, subscription_id: str, **kwargs: Any) -> None: - """POST method with subscriptionId modeled in the method. pass in subscription id = - '1234-5678-9012-3456' to succeed. - - :param subscription_id: The subscriptionId, which appears in the path, the value is always - '1234-5678-9012-3456'. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_swagger_local_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_swagger_local_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py deleted file mode 100644 index fed0b6efe3c..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class XMsClientRequestIdOperations: - """XMsClientRequestIdOperations 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: ~azurespecialproperties.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 get(self, **kwargs: Any) -> None: - """Get method that overwrites x-ms-client-request header with value - 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. - - :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", {})) - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/method/"} # type: ignore - - @distributed_trace_async - async def param_get(self, x_ms_client_request_id: str, **kwargs: Any) -> None: - """Get method that overwrites x-ms-client-request header with value - 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. - - :param x_ms_client_request_id: This should appear as a method parameter, use value - '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. - :type x_ms_client_request_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["x-ms-client-request-id"] = self._serialize.header( - "x_ms_client_request_id", x_ms_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - param_get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/via-param/method/"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py deleted file mode 100644 index a0ce511a094..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class ApiVersionDefaultOperations(object): - """ApiVersionDefaultOperations 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: ~azurespecialproperties.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 get_method_global_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_method_global_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_global_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview"} # type: ignore - - @distributed_trace - def get_method_global_not_provided_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_method_global_not_provided_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_global_not_provided_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview"} # type: ignore - - @distributed_trace - def get_path_global_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_path_global_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_global_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview"} # type: ignore - - @distributed_trace - def get_swagger_global_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """GET method with api-version modeled in global settings. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_swagger_global_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_global_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py deleted file mode 100644 index 1d9bf1ad111..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py +++ /dev/null @@ -1,230 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class ApiVersionLocalOperations(object): - """ApiVersionLocalOperations 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: ~azurespecialproperties.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 get_method_local_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. - - :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", {})) - api_version = "2.0" - accept = "application/json" - - # Construct URL - url = self.get_method_local_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_local_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/2.0"} # type: ignore - - @distributed_trace - def get_method_local_null( - self, - api_version=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Get method with api-version modeled in the method. pass in api-version = null to succeed. - - :param api_version: This should appear as a method parameter, use value null, this should - result in no serialized parameter. - :type api_version: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_local_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if api_version is not None: - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_local_null.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/null"} # type: ignore - - @distributed_trace - def get_path_local_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. - - :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", {})) - api_version = "2.0" - accept = "application/json" - - # Construct URL - url = self.get_path_local_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_local_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/local/2.0"} # type: ignore - - @distributed_trace - def get_swagger_local_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. - - :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", {})) - api_version = "2.0" - accept = "application/json" - - # Construct URL - url = self.get_swagger_local_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_local_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/local/2.0"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py deleted file mode 100644 index 307de10663d..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py +++ /dev/null @@ -1,214 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class HeaderOperations(object): - """HeaderOperations 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: ~azurespecialproperties.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 custom_named_request_id( - self, - foo_client_request_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. - - :param foo_client_request_id: The fooRequestId. - :type foo_client_request_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.custom_named_request_id.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["foo-client-request-id"] = self._serialize.header( - "foo_client_request_id", foo_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) - - if cls: - return cls(pipeline_response, None, response_headers) - - custom_named_request_id.metadata = {"url": "/azurespecials/customNamedRequestId"} # type: ignore - - @distributed_trace - def custom_named_request_id_param_grouping( - self, - header_custom_named_request_id_param_grouping_parameters, # type: "_models.HeaderCustomNamedRequestIdParamGroupingParameters" - **kwargs # type: Any - ): - # type: (...) -> None - """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, - via a parameter group. - - :param header_custom_named_request_id_param_grouping_parameters: Parameter group. - :type header_custom_named_request_id_param_grouping_parameters: ~azurespecialproperties.models.HeaderCustomNamedRequestIdParamGroupingParameters - :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", {})) - - _foo_client_request_id = None - if header_custom_named_request_id_param_grouping_parameters is not None: - _foo_client_request_id = header_custom_named_request_id_param_grouping_parameters.foo_client_request_id - accept = "application/json" - - # Construct URL - url = self.custom_named_request_id_param_grouping.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["foo-client-request-id"] = self._serialize.header( - "foo_client_request_id", _foo_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) - - if cls: - return cls(pipeline_response, None, response_headers) - - custom_named_request_id_param_grouping.metadata = {"url": "/azurespecials/customNamedRequestIdParamGrouping"} # type: ignore - - @distributed_trace - def custom_named_request_id_head( - self, - foo_client_request_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool - """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. - - :param foo_client_request_id: The fooRequestId. - :type foo_client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - accept = "application/json" - - # Construct URL - url = self.custom_named_request_id_head.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["foo-client-request-id"] = self._serialize.header( - "foo_client_request_id", foo_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) - - if cls: - return cls(pipeline_response, None, response_headers) - - return 200 <= response.status_code <= 299 - - custom_named_request_id_head.metadata = {"url": "/azurespecials/customNamedRequestIdHead"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py deleted file mode 100644 index ab9b86525c9..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py +++ /dev/null @@ -1,110 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class OdataOperations(object): - """OdataOperations 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: ~azurespecialproperties.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 get_with_filter( - self, - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. - - :param filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. - :type filter: str - :param top: The top parameter with value 10. - :type top: int - :param orderby: The orderby parameter with value id. - :type orderby: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_with_filter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters["$filter"] = self._serialize.query("filter", filter, "str") - if top is not None: - query_parameters["$top"] = self._serialize.query("top", top, "int") - if orderby is not None: - query_parameters["$orderby"] = self._serialize.query("orderby", orderby, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_with_filter.metadata = {"url": "/azurespecials/odata/filter"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py deleted file mode 100644 index b316f75100e..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py +++ /dev/null @@ -1,385 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class SkipUrlEncodingOperations(object): - """SkipUrlEncodingOperations 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: ~azurespecialproperties.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 get_method_path_valid( - self, - unencoded_path_param, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded path parameter with value 'path1/path2/path3'. - - :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. - :type unencoded_path_param: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_path_valid.metadata["url"] # type: ignore - path_format_arguments = { - "unencodedPathParam": self._serialize.url( - "unencoded_path_param", unencoded_path_param, "str", skip_quote=True - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}"} # type: ignore - - @distributed_trace - def get_path_valid( - self, - unencoded_path_param, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded path parameter with value 'path1/path2/path3'. - - :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. - :type unencoded_path_param: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_path_valid.metadata["url"] # type: ignore - path_format_arguments = { - "unencodedPathParam": self._serialize.url( - "unencoded_path_param", unencoded_path_param, "str", skip_quote=True - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}"} # type: ignore - - @distributed_trace - def get_swagger_path_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded path parameter with value 'path1/path2/path3'. - - :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", {})) - unencoded_path_param = "path1/path2/path3" - accept = "application/json" - - # Construct URL - url = self.get_swagger_path_valid.metadata["url"] # type: ignore - path_format_arguments = { - "unencodedPathParam": self._serialize.url( - "unencoded_path_param", unencoded_path_param, "str", skip_quote=True - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}"} # type: ignore - - @distributed_trace - def get_method_query_valid( - self, - q1, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. - - :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. - :type q1: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_query_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/valid"} # type: ignore - - @distributed_trace - def get_method_query_null( - self, - q1=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded query parameter with value null. - - :param q1: Unencoded query parameter with value null. - :type q1: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_method_query_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if q1 is not None: - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_method_query_null.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/null"} # type: ignore - - @distributed_trace - def get_path_query_valid( - self, - q1, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. - - :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. - :type q1: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_path_query_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_path_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/query/valid"} # type: ignore - - @distributed_trace - def get_swagger_query_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. - - :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", {})) - q1 = "value1&q2=value2&q3=value3" - accept = "application/json" - - # Construct URL - url = self.get_swagger_query_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["q1"] = self._serialize.query("q1", q1, "str", skip_quote=True) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get_swagger_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/query/valid"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py deleted file mode 100644 index 49fd7c1b342..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py +++ /dev/null @@ -1,285 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class SubscriptionInCredentialsOperations(object): - """SubscriptionInCredentialsOperations 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: ~azurespecialproperties.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 post_method_global_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_global_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_global_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_method_global_null( - self, **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - null, and client-side validation should prevent you from making this call. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_global_null.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_global_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_method_global_not_provided_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - api_version = "2015-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.post_method_global_not_provided_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_global_not_provided_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_path_global_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_path_global_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_path_global_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_swagger_global_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to - '1234-5678-9012-3456' to succeed. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_swagger_global_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_swagger_global_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py deleted file mode 100644 index 1cbb4e3bcb0..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py +++ /dev/null @@ -1,256 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class SubscriptionInMethodOperations(object): - """SubscriptionInMethodOperations 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: ~azurespecialproperties.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 post_method_local_valid( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in the method. pass in subscription id = - '1234-5678-9012-3456' to succeed. - - :param subscription_id: This should appear as a method parameter, use value - '1234-5678-9012-3456'. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_local_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_local_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_method_local_null( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in the method. pass in subscription id = null, - client-side validation should prevent you from making this call. - - :param subscription_id: This should appear as a method parameter, use value null, client-side - validation should prvenet the call. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_method_local_null.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_method_local_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_path_local_valid( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in the method. pass in subscription id = - '1234-5678-9012-3456' to succeed. - - :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_path_local_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_path_local_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore - - @distributed_trace - def post_swagger_local_valid( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """POST method with subscriptionId modeled in the method. pass in subscription id = - '1234-5678-9012-3456' to succeed. - - :param subscription_id: The subscriptionId, which appears in the path, the value is always - '1234-5678-9012-3456'. - :type subscription_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_swagger_local_valid.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("subscription_id", subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - post_swagger_local_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py deleted file mode 100644 index 87874386680..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py +++ /dev/null @@ -1,142 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class XMsClientRequestIdOperations(object): - """XMsClientRequestIdOperations 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: ~azurespecialproperties.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 get( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get method that overwrites x-ms-client-request header with value - 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. - - :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", {})) - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/method/"} # type: ignore - - @distributed_trace - def param_get( - self, - x_ms_client_request_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get method that overwrites x-ms-client-request header with value - 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. - - :param x_ms_client_request_id: This should appear as a method parameter, use value - '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. - :type x_ms_client_request_id: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["x-ms-client-request-id"] = self._serialize.header( - "x_ms_client_request_id", x_ms_client_request_id, "str" - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - param_get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/via-param/method/"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/setup.py b/test/azure/Expected/AcceptanceTests/AzureSpecials/setup.py deleted file mode 100644 index ce5fe349719..00000000000 --- a/test/azure/Expected/AcceptanceTests/AzureSpecials/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestazurespecialparameterstestclient" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestAzureSpecialParametersTestClient", - author_email="", - url="", - keywords=["Swagger", "AutoRestAzureSpecialParametersTestClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py b/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py deleted file mode 100644 index 8a3070ec02e..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py +++ /dev/null @@ -1,79 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestParameterizedHostTestClientConfiguration -from .operations import PathsOperations -from . import models - - -class AutoRestParameterizedHostTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: custombaseurl.operations.PathsOperations - :param host: A string value that is used as a global part of the parameterized host. - :type host: str - """ - - def __init__( - self, - host="host", # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = "http://{accountName}{host}" - self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestParameterizedHostTestClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py b/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py deleted file mode 100644 index b0badaad24f..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py +++ /dev/null @@ -1,65 +0,0 @@ -# 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 import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestParameterizedHostTestClientConfiguration -from .operations import PathsOperations -from .. import models - - -class AutoRestParameterizedHostTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: custombaseurl.aio.operations.PathsOperations - :param host: A string value that is used as a global part of the parameterized host. - :type host: str - """ - - def __init__(self, host: str = "host", **kwargs: Any) -> None: - base_url = "http://{accountName}{host}" - self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestParameterizedHostTestClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py b/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py deleted file mode 100644 index 8d9a7bf9f65..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py +++ /dev/null @@ -1,93 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PathsOperations: - """PathsOperations 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: ~custombaseurl.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 get_empty(self, account_name: str, **kwargs: Any) -> None: - """Get a 200 to test a valid base uri. - - :param account_name: Account Name. - :type account_name: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py b/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py deleted file mode 100644 index 227cbbdefcc..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py +++ /dev/null @@ -1,102 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PathsOperations(object): - """PathsOperations 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: ~custombaseurl.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 get_empty( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a 200 to test a valid base uri. - - :param account_name: Account Name. - :type account_name: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/setup.py b/test/azure/Expected/AcceptanceTests/CustomBaseUri/setup.py deleted file mode 100644 index b41dddbf059..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomBaseUri/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestparameterizedhosttestclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestParameterizedHostTestClient", - author_email="", - url="", - keywords=["Swagger", "AutoRestParameterizedHostTestClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_auto_rest_paging_test_service.py b/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_auto_rest_paging_test_service.py deleted file mode 100644 index 86cf693d50a..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_auto_rest_paging_test_service.py +++ /dev/null @@ -1,83 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestPagingTestServiceConfiguration -from .operations import PagingOperations -from . import models - - -class AutoRestPagingTestService(object): - """Long-running Operation for AutoRest. - - :ivar paging: PagingOperations operations - :vartype paging: custompollerpager.operations.PagingOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'http://localhost:3000' - self._config = AutoRestPagingTestServiceConfiguration(credential, **kwargs) - self._client = ARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paging = PagingOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestPagingTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_auto_rest_paging_test_service.py b/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_auto_rest_paging_test_service.py deleted file mode 100644 index 3137a9bf3ee..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_auto_rest_paging_test_service.py +++ /dev/null @@ -1,76 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import AutoRestPagingTestServiceConfiguration -from .operations import PagingOperations -from .. import models - - -class AutoRestPagingTestService(object): - """Long-running Operation for AutoRest. - - :ivar paging: PagingOperations operations - :vartype paging: custompollerpager.aio.operations.PagingOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - base_url: Optional[str] = None, - **kwargs: Any - ) -> None: - if not base_url: - base_url = 'http://localhost:3000' - self._config = AutoRestPagingTestServiceConfiguration(credential, **kwargs) - self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paging = PagingOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestPagingTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py deleted file mode 100644 index 7846894163d..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py +++ /dev/null @@ -1,1291 +0,0 @@ -# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from custompollerpagerdefinitions.aio import AsyncCustomPager, AsyncCustomPoller - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PagingOperations: - """PagingOperations 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: ~custompollerpager.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 - - def get_no_item_name_pages( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResultValue"]: - """A paging operation that must return result of the default 'value' node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_no_item_name_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResultValue', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_no_item_name_pages.metadata = {'url': '/paging/noitemname'} # type: ignore - - def get_null_next_link_name_pages( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that must ignore any kind of nextLink, and stop after page 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_null_next_link_name_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_null_next_link_name_pages.metadata = {'url': '/paging/nullnextlink'} # type: ignore - - def get_single_pages( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that finishes on the first call without a nextlink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~custompollerpagerdefinitions.aio.AsyncCustomPager[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_single_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncCustomPager( - get_next, extract_data - ) - get_single_pages.metadata = {'url': '/paging/single'} # type: ignore - - def first_response_empty( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResultValue"]: - """A paging operation whose first response's items list is empty, but still returns a next link. - Second (and final) call, will give you an items list of 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.first_response_empty.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResultValue', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - first_response_empty.metadata = {'url': '/paging/firstResponseEmpty/1'} # type: ignore - - def get_multiple_pages( - self, - client_request_id: Optional[str] = None, - paging_get_multiple_pages_options: Optional["_models.PagingGetMultiplePagesOptions"] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_options: Parameter group. - :type paging_get_multiple_pages_options: ~custompollerpager.models.PagingGetMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_options is not None: - _maxresults = paging_get_multiple_pages_options.maxresults - _timeout = paging_get_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages.metadata = {'url': '/paging/multiple'} # type: ignore - - def get_with_query_params( - self, - required_query_parameter: int, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a next operation. It has a different query parameter from it's - next operation nextOperationWithQueryParams. Returns a ProductResult. - - :param required_query_parameter: A required integer query parameter. Put in value '100' to pass - test. - :type required_query_parameter: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - query_constant = True - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_with_query_params.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['requiredQueryParameter'] = self._serialize.query("required_query_parameter", required_query_parameter, 'int') - query_parameters['queryConstant'] = self._serialize.query("query_constant", query_constant, 'bool') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = '/paging/multiple/nextOperationWithQueryParams' - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['queryConstant'] = self._serialize.query("query_constant", query_constant, 'bool') - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_with_query_params.metadata = {'url': '/paging/multiple/getWithQueryParams'} # type: ignore - - def get_odata_multiple_pages( - self, - client_request_id: Optional[str] = None, - paging_get_odata_multiple_pages_options: Optional["_models.PagingGetOdataMultiplePagesOptions"] = None, - **kwargs: Any - ) -> AsyncIterable["_models.OdataProductResult"]: - """A paging operation that includes a nextLink in odata format that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_odata_multiple_pages_options: Parameter group. - :type paging_get_odata_multiple_pages_options: ~custompollerpager.models.PagingGetOdataMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_odata_multiple_pages_options is not None: - _maxresults = paging_get_odata_multiple_pages_options.maxresults - _timeout = paging_get_odata_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_odata_multiple_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OdataProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_odata_multiple_pages.metadata = {'url': '/paging/multiple/odata'} # type: ignore - - def get_multiple_pages_with_offset( - self, - paging_get_multiple_pages_with_offset_options: "_models.PagingGetMultiplePagesWithOffsetOptions", - client_request_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a nextLink that has 10 pages. - - :param paging_get_multiple_pages_with_offset_options: Parameter group. - :type paging_get_multiple_pages_with_offset_options: ~custompollerpager.models.PagingGetMultiplePagesWithOffsetOptions - :param client_request_id: - :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _offset = None - _timeout = None - if paging_get_multiple_pages_with_offset_options is not None: - _maxresults = paging_get_multiple_pages_with_offset_options.maxresults - _offset = paging_get_multiple_pages_with_offset_options.offset - _timeout = paging_get_multiple_pages_with_offset_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_with_offset.metadata['url'] # type: ignore - path_format_arguments = { - 'offset': self._serialize.url("offset", _offset, 'int'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_with_offset.metadata = {'url': '/paging/multiple/withpath/{offset}'} # type: ignore - - def get_multiple_pages_retry_first( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that fails on the first call with 500 and then retries and then get a - response including a nextLink that has 10 pages. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_first.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_retry_first.metadata = {'url': '/paging/multiple/retryfirst'} # type: ignore - - def get_multiple_pages_retry_second( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails - first with 500. The client should retry and finish all 10 pages eventually. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_second.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_retry_second.metadata = {'url': '/paging/multiple/retrysecond'} # type: ignore - - def get_single_pages_failure( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that receives a 400 on the first call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_single_pages_failure.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_single_pages_failure.metadata = {'url': '/paging/single/failure'} # type: ignore - - def get_multiple_pages_failure( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that receives a 400 on the second call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_failure.metadata = {'url': '/paging/multiple/failure'} # type: ignore - - def get_multiple_pages_failure_uri( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that receives an invalid nextLink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure_uri.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_failure_uri.metadata = {'url': '/paging/multiple/failureuri'} # type: ignore - - def get_multiple_pages_fragment_next_link( - self, - api_version: str, - tenant: str, - **kwargs: Any - ) -> AsyncIterable["_models.OdataProductResult"]: - """A paging operation that doesn't return a full URL, just a fragment. - - :param api_version: Sets the api version to use. - :type api_version: str - :param tenant: Sets the tenant to use. - :type tenant: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_next_link.metadata['url'] # type: ignore - path_format_arguments = { - 'tenant': self._serialize.url("tenant", tenant, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = '/paging/multiple/fragment/{tenant}/{nextLink}' - path_format_arguments = { - 'tenant': self._serialize.url("tenant", tenant, 'str'), - 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OdataProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_fragment_next_link.metadata = {'url': '/paging/multiple/fragment/{tenant}'} # type: ignore - - def get_multiple_pages_fragment_with_grouping_next_link( - self, - custom_parameter_group: "_models.CustomParameterGroup", - **kwargs: Any - ) -> AsyncIterable["_models.OdataProductResult"]: - """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. - - :param custom_parameter_group: Parameter group. - :type custom_parameter_group: ~custompollerpager.models.CustomParameterGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _api_version = None - _tenant = None - if custom_parameter_group is not None: - _api_version = custom_parameter_group.api_version - _tenant = custom_parameter_group.tenant - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_with_grouping_next_link.metadata['url'] # type: ignore - path_format_arguments = { - 'tenant': self._serialize.url("tenant", _tenant, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", _api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = '/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}' - path_format_arguments = { - 'tenant': self._serialize.url("tenant", _tenant, 'str'), - 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", _api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OdataProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_multiple_pages_fragment_with_grouping_next_link.metadata = {'url': '/paging/multiple/fragmentwithgrouping/{tenant}'} # type: ignore - - async def _get_multiple_pages_lro_initial( - self, - client_request_id: Optional[str] = None, - paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, - **kwargs: Any - ) -> "_models.ProductResult": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - # Construct URL - url = self._get_multiple_pages_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ProductResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _get_multiple_pages_lro_initial.metadata = {'url': '/paging/multiple/lro'} # type: ignore - - async def begin_get_multiple_pages_lro( - self, - client_request_id: Optional[str] = None, - paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, - **kwargs: Any - ) -> AsyncCustomPoller[AsyncItemPaged["_models.ProductResult"]]: - """A long-running paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_lro_options: Parameter group. - :type paging_get_multiple_pages_lro_options: ~custompollerpager.models.PagingGetMultiplePagesLroOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncCustomPoller that returns an iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~custompollerpagerdefinitions.aio.AsyncCustomPoller[~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_lro.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.post(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._get_multiple_pages_lro_initial( - client_request_id=client_request_id, - paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - def get_long_running_output(pipeline_response): - async def internal_get_next(next_link=None): - if next_link is None: - return pipeline_response - else: - return await get_next(next_link) - - return AsyncItemPaged( - internal_get_next, extract_data - ) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncCustomPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncCustomPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_get_multiple_pages_lro.metadata = {'url': '/paging/multiple/lro'} # type: ignore - - def get_paging_model_with_item_name_with_xms_client_name( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResultValueWithXMSClientName"]: - """A paging operation that returns a paging model whose item name is is overriden by - x-ms-client-name 'indexes'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResultValueWithXMSClientName] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_paging_model_with_item_name_with_xms_client_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResultValueWithXMSClientName', pipeline_response) - list_of_elem = deserialized.indexes - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_paging_model_with_item_name_with_xms_client_name.metadata = {'url': '/paging/itemNameWithXMSClientName'} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py deleted file mode 100644 index 901e9d15ab4..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py +++ /dev/null @@ -1,1313 +0,0 @@ -# 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 -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling -from custompollerpagerdefinitions import CustomPager, CustomPoller - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class PagingOperations(object): - """PagingOperations 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: ~custompollerpager.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 - - def get_no_item_name_pages( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResultValue"] - """A paging operation that must return result of the default 'value' node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_no_item_name_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResultValue', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_no_item_name_pages.metadata = {'url': '/paging/noitemname'} # type: ignore - - def get_null_next_link_name_pages( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that must ignore any kind of nextLink, and stop after page 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_null_next_link_name_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_null_next_link_name_pages.metadata = {'url': '/paging/nullnextlink'} # type: ignore - - def get_single_pages( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that finishes on the first call without a nextlink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~custompollerpagerdefinitions.CustomPager[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_single_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return CustomPager( - get_next, extract_data - ) - get_single_pages.metadata = {'url': '/paging/single'} # type: ignore - - def first_response_empty( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResultValue"] - """A paging operation whose first response's items list is empty, but still returns a next link. - Second (and final) call, will give you an items list of 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.first_response_empty.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResultValue', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - first_response_empty.metadata = {'url': '/paging/firstResponseEmpty/1'} # type: ignore - - def get_multiple_pages( - self, - client_request_id=None, # type: Optional[str] - paging_get_multiple_pages_options=None, # type: Optional["_models.PagingGetMultiplePagesOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_options: Parameter group. - :type paging_get_multiple_pages_options: ~custompollerpager.models.PagingGetMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_options is not None: - _maxresults = paging_get_multiple_pages_options.maxresults - _timeout = paging_get_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages.metadata = {'url': '/paging/multiple'} # type: ignore - - def get_with_query_params( - self, - required_query_parameter, # type: int - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a next operation. It has a different query parameter from it's - next operation nextOperationWithQueryParams. Returns a ProductResult. - - :param required_query_parameter: A required integer query parameter. Put in value '100' to pass - test. - :type required_query_parameter: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - query_constant = True - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_with_query_params.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['requiredQueryParameter'] = self._serialize.query("required_query_parameter", required_query_parameter, 'int') - query_parameters['queryConstant'] = self._serialize.query("query_constant", query_constant, 'bool') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = '/paging/multiple/nextOperationWithQueryParams' - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['queryConstant'] = self._serialize.query("query_constant", query_constant, 'bool') - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_with_query_params.metadata = {'url': '/paging/multiple/getWithQueryParams'} # type: ignore - - def get_odata_multiple_pages( - self, - client_request_id=None, # type: Optional[str] - paging_get_odata_multiple_pages_options=None, # type: Optional["_models.PagingGetOdataMultiplePagesOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OdataProductResult"] - """A paging operation that includes a nextLink in odata format that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_odata_multiple_pages_options: Parameter group. - :type paging_get_odata_multiple_pages_options: ~custompollerpager.models.PagingGetOdataMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_odata_multiple_pages_options is not None: - _maxresults = paging_get_odata_multiple_pages_options.maxresults - _timeout = paging_get_odata_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_odata_multiple_pages.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('OdataProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_odata_multiple_pages.metadata = {'url': '/paging/multiple/odata'} # type: ignore - - def get_multiple_pages_with_offset( - self, - paging_get_multiple_pages_with_offset_options, # type: "_models.PagingGetMultiplePagesWithOffsetOptions" - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a nextLink that has 10 pages. - - :param paging_get_multiple_pages_with_offset_options: Parameter group. - :type paging_get_multiple_pages_with_offset_options: ~custompollerpager.models.PagingGetMultiplePagesWithOffsetOptions - :param client_request_id: - :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _offset = None - _timeout = None - if paging_get_multiple_pages_with_offset_options is not None: - _maxresults = paging_get_multiple_pages_with_offset_options.maxresults - _offset = paging_get_multiple_pages_with_offset_options.offset - _timeout = paging_get_multiple_pages_with_offset_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_with_offset.metadata['url'] # type: ignore - path_format_arguments = { - 'offset': self._serialize.url("offset", _offset, 'int'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_with_offset.metadata = {'url': '/paging/multiple/withpath/{offset}'} # type: ignore - - def get_multiple_pages_retry_first( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that fails on the first call with 500 and then retries and then get a - response including a nextLink that has 10 pages. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_first.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_retry_first.metadata = {'url': '/paging/multiple/retryfirst'} # type: ignore - - def get_multiple_pages_retry_second( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails - first with 500. The client should retry and finish all 10 pages eventually. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_second.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_retry_second.metadata = {'url': '/paging/multiple/retrysecond'} # type: ignore - - def get_single_pages_failure( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that receives a 400 on the first call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_single_pages_failure.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_single_pages_failure.metadata = {'url': '/paging/single/failure'} # type: ignore - - def get_multiple_pages_failure( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that receives a 400 on the second call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_failure.metadata = {'url': '/paging/multiple/failure'} # type: ignore - - def get_multiple_pages_failure_uri( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that receives an invalid nextLink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure_uri.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_failure_uri.metadata = {'url': '/paging/multiple/failureuri'} # type: ignore - - def get_multiple_pages_fragment_next_link( - self, - api_version, # type: str - tenant, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OdataProductResult"] - """A paging operation that doesn't return a full URL, just a fragment. - - :param api_version: Sets the api version to use. - :type api_version: str - :param tenant: Sets the tenant to use. - :type tenant: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_next_link.metadata['url'] # type: ignore - path_format_arguments = { - 'tenant': self._serialize.url("tenant", tenant, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = '/paging/multiple/fragment/{tenant}/{nextLink}' - path_format_arguments = { - 'tenant': self._serialize.url("tenant", tenant, 'str'), - 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('OdataProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_fragment_next_link.metadata = {'url': '/paging/multiple/fragment/{tenant}'} # type: ignore - - def get_multiple_pages_fragment_with_grouping_next_link( - self, - custom_parameter_group, # type: "_models.CustomParameterGroup" - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OdataProductResult"] - """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. - - :param custom_parameter_group: Parameter group. - :type custom_parameter_group: ~custompollerpager.models.CustomParameterGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _api_version = None - _tenant = None - if custom_parameter_group is not None: - _api_version = custom_parameter_group.api_version - _tenant = custom_parameter_group.tenant - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_with_grouping_next_link.metadata['url'] # type: ignore - path_format_arguments = { - 'tenant': self._serialize.url("tenant", _tenant, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", _api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = '/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}' - path_format_arguments = { - 'tenant': self._serialize.url("tenant", _tenant, 'str'), - 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api_version'] = self._serialize.query("api_version", _api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('OdataProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_multiple_pages_fragment_with_grouping_next_link.metadata = {'url': '/paging/multiple/fragmentwithgrouping/{tenant}'} # type: ignore - - def _get_multiple_pages_lro_initial( - self, - client_request_id=None, # type: Optional[str] - paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProductResult" - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - # Construct URL - url = self._get_multiple_pages_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ProductResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _get_multiple_pages_lro_initial.metadata = {'url': '/paging/multiple/lro'} # type: ignore - - def begin_get_multiple_pages_lro( - self, - client_request_id=None, # type: Optional[str] - paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] - **kwargs # type: Any - ): - # type: (...) -> CustomPoller[ItemPaged["_models.ProductResult"]] - """A long-running paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_lro_options: Parameter group. - :type paging_get_multiple_pages_lro_options: ~custompollerpager.models.PagingGetMultiplePagesLroOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of CustomPoller that returns an iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~custompollerpagerdefinitions.CustomPoller[~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_multiple_pages_lro.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.post(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResult', pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._get_multiple_pages_lro_initial( - client_request_id=client_request_id, - paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - def get_long_running_output(pipeline_response): - def internal_get_next(next_link=None): - if next_link is None: - return pipeline_response - else: - return get_next(next_link) - - return ItemPaged( - internal_get_next, extract_data - ) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return CustomPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return CustomPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_get_multiple_pages_lro.metadata = {'url': '/paging/multiple/lro'} # type: ignore - - def get_paging_model_with_item_name_with_xms_client_name( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResultValueWithXMSClientName"] - """A paging operation that returns a paging model whose item name is is overriden by - x-ms-client-name 'indexes'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResultValueWithXMSClientName] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_paging_model_with_item_name_with_xms_client_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProductResultValueWithXMSClientName', pipeline_response) - list_of_elem = deserialized.indexes - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_paging_model_with_item_name_with_xms_client_name.metadata = {'url': '/paging/itemNameWithXMSClientName'} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/setup.py b/test/azure/Expected/AcceptanceTests/CustomPollerPager/setup.py deleted file mode 100644 index 87e10f75be9..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomPollerPager/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "custompollerpager" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="custompollerpager", - author_email="", - url="", - keywords=["Swagger", "AutoRestPagingTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Long-running Operation for AutoRest. - """ -) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py deleted file mode 100644 index 274e8a3722c..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestParameterizedHostTestPagingClientConfiguration -from .operations import PagingOperations -from . import models - - -class AutoRestParameterizedHostTestPagingClient(object): - """Test Infrastructure for AutoRest. - - :ivar paging: PagingOperations operations - :vartype paging: custombaseurlpaging.operations.PagingOperations - :param host: A string value that is used as a global part of the parameterized host. - :type host: str - """ - - def __init__( - self, - host="host", # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = "http://{accountName}{host}" - self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paging = PagingOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestParameterizedHostTestPagingClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py deleted file mode 100644 index 055da3c7e51..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py +++ /dev/null @@ -1,66 +0,0 @@ -# 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 import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestParameterizedHostTestPagingClientConfiguration -from .operations import PagingOperations -from .. import models - - -class AutoRestParameterizedHostTestPagingClient(object): - """Test Infrastructure for AutoRest. - - :ivar paging: PagingOperations operations - :vartype paging: custombaseurlpaging.aio.operations.PagingOperations - :param host: A string value that is used as a global part of the parameterized host. - :type host: str - """ - - def __init__(self, host: str = "host", **kwargs: Any) -> None: - base_url = "http://{accountName}{host}" - self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paging = PagingOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestParameterizedHostTestPagingClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py deleted file mode 100644 index 310e50de043..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py +++ /dev/null @@ -1,190 +0,0 @@ -# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PagingOperations: - """PagingOperations 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: ~custombaseurlpaging.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 - def get_pages_partial_url(self, account_name: str, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that combines custom url, paging and partial URL and expect to concat after - host. - - :param account_name: Account Name. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custombaseurlpaging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_pages_partial_url.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_pages_partial_url.metadata = {"url": "/paging/customurl/partialnextlink"} # type: ignore - - @distributed_trace - def get_pages_partial_url_operation( - self, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that combines custom url, paging and partial URL with next operation. - - :param account_name: Account Name. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~custombaseurlpaging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_pages_partial_url_operation.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/customurl/{nextLink}" - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - "nextLink": self._serialize.url("next_link", next_link, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_pages_partial_url_operation.metadata = {"url": "/paging/customurl/partialnextlinkop"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py deleted file mode 100644 index a5ac9a878a1..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py +++ /dev/null @@ -1,201 +0,0 @@ -# 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 -import warnings - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class PagingOperations(object): - """PagingOperations 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: ~custombaseurlpaging.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 get_pages_partial_url( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that combines custom url, paging and partial URL and expect to concat after - host. - - :param account_name: Account Name. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custombaseurlpaging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_pages_partial_url.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_pages_partial_url.metadata = {"url": "/paging/customurl/partialnextlink"} # type: ignore - - @distributed_trace - def get_pages_partial_url_operation( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that combines custom url, paging and partial URL with next operation. - - :param account_name: Account Name. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~custombaseurlpaging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_pages_partial_url_operation.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/customurl/{nextLink}" - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - "nextLink": self._serialize.url("next_link", next_link, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_pages_partial_url_operation.metadata = {"url": "/paging/customurl/partialnextlinkop"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py deleted file mode 100644 index 276dac72b65..00000000000 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestparameterizedhosttestpagingclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestParameterizedHostTestPagingClient", - author_email="", - url="", - keywords=["Swagger", "AutoRestParameterizedHostTestPagingClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/_auto_rest_head_test_service.py b/test/azure/Expected/AcceptanceTests/Head/head/_auto_rest_head_test_service.py deleted file mode 100644 index a2d10ed7141..00000000000 --- a/test/azure/Expected/AcceptanceTests/Head/head/_auto_rest_head_test_service.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - - -class AutoRestHeadTestService(object): - """Test Infrastructure for AutoRest. - - :ivar http_success: HttpSuccessOperations operations - :vartype http_success: head.operations.HttpSuccessOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - """ - - def __init__( - self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestHeadTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/aio/_auto_rest_head_test_service.py b/test/azure/Expected/AcceptanceTests/Head/head/aio/_auto_rest_head_test_service.py deleted file mode 100644 index d50aeb38536..00000000000 --- a/test/azure/Expected/AcceptanceTests/Head/head/aio/_auto_rest_head_test_service.py +++ /dev/null @@ -1,70 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - - -class AutoRestHeadTestService(object): - """Test Infrastructure for AutoRest. - - :ivar http_success: HttpSuccessOperations operations - :vartype http_success: head.aio.operations.HttpSuccessOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - """ - - def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestHeadTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py b/test/azure/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py deleted file mode 100644 index e0c14e69a48..00000000000 --- a/test/azure/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpSuccessOperations: - """HttpSuccessOperations 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 head200(self, **kwargs: Any) -> bool: - """Return 200 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def head204(self, **kwargs: Any) -> bool: - """Return 204 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def head404(self, **kwargs: Any) -> bool: - """Return 404 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py b/test/azure/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py deleted file mode 100644 index 5a3c4fc130f..00000000000 --- a/test/azure/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -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]] - - -class HttpSuccessOperations(object): - """HttpSuccessOperations 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 head200( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 200 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def head204( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 204 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def head404( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 404 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Head/setup.py b/test/azure/Expected/AcceptanceTests/Head/setup.py deleted file mode 100644 index 170e4066562..00000000000 --- a/test/azure/Expected/AcceptanceTests/Head/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestheadtestservice" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestHeadTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestHeadTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_auto_rest_head_exception_test_service.py b/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_auto_rest_head_exception_test_service.py deleted file mode 100644 index 6f1a0ac7c6e..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_auto_rest_head_exception_test_service.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHeadExceptionTestServiceConfiguration -from .operations import HeadExceptionOperations - - -class AutoRestHeadExceptionTestService(object): - """Test Infrastructure for AutoRest. - - :ivar head_exception: HeadExceptionOperations operations - :vartype head_exception: headexceptions.operations.HeadExceptionOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - """ - - def __init__( - self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHeadExceptionTestServiceConfiguration(credential, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.head_exception = HeadExceptionOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestHeadExceptionTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_auto_rest_head_exception_test_service.py b/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_auto_rest_head_exception_test_service.py deleted file mode 100644 index 7cd17c77622..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_auto_rest_head_exception_test_service.py +++ /dev/null @@ -1,70 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import AutoRestHeadExceptionTestServiceConfiguration -from .operations import HeadExceptionOperations - - -class AutoRestHeadExceptionTestService(object): - """Test Infrastructure for AutoRest. - - :ivar head_exception: HeadExceptionOperations operations - :vartype head_exception: headexceptions.aio.operations.HeadExceptionOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - """ - - def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHeadExceptionTestServiceConfiguration(credential, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.head_exception = HeadExceptionOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestHeadExceptionTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py b/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py deleted file mode 100644 index d62346f6af6..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HeadExceptionOperations: - """HeadExceptionOperations 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 head200(self, **kwargs: Any) -> bool: - """Return 200 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def head204(self, **kwargs: Any) -> bool: - """Return 204 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def head404(self, **kwargs: Any) -> bool: - """Return 404 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py b/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py deleted file mode 100644 index 82e9ac18fab..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -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]] - - -class HeadExceptionOperations(object): - """HeadExceptionOperations 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 head200( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 200 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def head204( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 204 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def head404( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 404 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/setup.py b/test/azure/Expected/AcceptanceTests/HeadExceptions/setup.py deleted file mode 100644 index f7c82611e00..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadExceptions/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestheadexceptiontestservice" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestHeadExceptionTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestHeadExceptionTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_auto_rest_head_test_service.py b/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_auto_rest_head_test_service.py deleted file mode 100644 index 1f2bba8668d..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_auto_rest_head_test_service.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict, Optional - - from azure.core.credentials import AzureKeyCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - - -class AutoRestHeadTestService(object): - """Test Infrastructure for AutoRest. - - :ivar http_success: HttpSuccessOperations operations - :vartype http_success: headwithazurekeycredentialpolicy.operations.HttpSuccessOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL - """ - - def __init__( - self, - credential, # type: AzureKeyCredential - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestHeadTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_auto_rest_head_test_service.py b/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_auto_rest_head_test_service.py deleted file mode 100644 index e1ef3fa13d4..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_auto_rest_head_test_service.py +++ /dev/null @@ -1,69 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - -from ._configuration import AutoRestHeadTestServiceConfiguration -from .operations import HttpSuccessOperations - - -class AutoRestHeadTestService(object): - """Test Infrastructure for AutoRest. - - :ivar http_success: HttpSuccessOperations operations - :vartype http_success: headwithazurekeycredentialpolicy.aio.operations.HttpSuccessOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL - """ - - def __init__(self, credential: AzureKeyCredential, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestHeadTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py b/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py deleted file mode 100644 index e0c14e69a48..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpSuccessOperations: - """HttpSuccessOperations 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 head200(self, **kwargs: Any) -> bool: - """Return 200 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def head204(self, **kwargs: Any) -> bool: - """Return 204 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def head404(self, **kwargs: Any) -> bool: - """Return 404 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py b/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py deleted file mode 100644 index 5a3c4fc130f..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -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]] - - -class HttpSuccessOperations(object): - """HttpSuccessOperations 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 head200( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 200 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def head204( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 204 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def head404( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 404 status code if successful. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :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", {})) - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - return 200 <= response.status_code <= 299 - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/setup.py b/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/setup.py deleted file mode 100644 index 170e4066562..00000000000 --- a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestheadtestservice" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestHeadTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestHeadTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/_auto_rest_long_running_operation_test_service.py b/test/azure/Expected/AcceptanceTests/Lro/lro/_auto_rest_long_running_operation_test_service.py deleted file mode 100644 index 4f3c39ab9a9..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/_auto_rest_long_running_operation_test_service.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestLongRunningOperationTestServiceConfiguration -from .operations import LROsOperations -from .operations import LRORetrysOperations -from .operations import LROSADsOperations -from .operations import LROsCustomHeaderOperations -from . import models - - -class AutoRestLongRunningOperationTestService(object): - """Long-running Operation for AutoRest. - - :ivar lros: LROsOperations operations - :vartype lros: lro.operations.LROsOperations - :ivar lro_retrys: LRORetrysOperations operations - :vartype lro_retrys: lro.operations.LRORetrysOperations - :ivar lrosads: LROSADsOperations operations - :vartype lrosads: lro.operations.LROSADsOperations - :ivar lr_os_custom_header: LROsCustomHeaderOperations operations - :vartype lr_os_custom_header: lro.operations.LROsCustomHeaderOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestLongRunningOperationTestServiceConfiguration(credential, **kwargs) - self._client = ARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.lros = LROsOperations(self._client, self._config, self._serialize, self._deserialize) - self.lro_retrys = LRORetrysOperations(self._client, self._config, self._serialize, self._deserialize) - self.lrosads = LROSADsOperations(self._client, self._config, self._serialize, self._deserialize) - self.lr_os_custom_header = LROsCustomHeaderOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestLongRunningOperationTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/_auto_rest_long_running_operation_test_service.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/_auto_rest_long_running_operation_test_service.py deleted file mode 100644 index 5f8611ef959..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/_auto_rest_long_running_operation_test_service.py +++ /dev/null @@ -1,84 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import AutoRestLongRunningOperationTestServiceConfiguration -from .operations import LROsOperations -from .operations import LRORetrysOperations -from .operations import LROSADsOperations -from .operations import LROsCustomHeaderOperations -from .. import models - - -class AutoRestLongRunningOperationTestService(object): - """Long-running Operation for AutoRest. - - :ivar lros: LROsOperations operations - :vartype lros: lro.aio.operations.LROsOperations - :ivar lro_retrys: LRORetrysOperations operations - :vartype lro_retrys: lro.aio.operations.LRORetrysOperations - :ivar lrosads: LROSADsOperations operations - :vartype lrosads: lro.aio.operations.LROSADsOperations - :ivar lr_os_custom_header: LROsCustomHeaderOperations operations - :vartype lr_os_custom_header: lro.aio.operations.LROsCustomHeaderOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestLongRunningOperationTestServiceConfiguration(credential, **kwargs) - self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.lros = LROsOperations(self._client, self._config, self._serialize, self._deserialize) - self.lro_retrys = LRORetrysOperations(self._client, self._config, self._serialize, self._deserialize) - self.lrosads = LROSADsOperations(self._client, self._config, self._serialize, self._deserialize) - self.lr_os_custom_header = LROsCustomHeaderOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestLongRunningOperationTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py deleted file mode 100644 index 6b71ee784f1..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py +++ /dev/null @@ -1,462 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LROsCustomHeaderOperations: - """LROsCustomHeaderOperations 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: ~lro.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 - - async def _put_async_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_put_async_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running put request, service returns a 200 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_retry_succeeded.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore - - async def _put201_creating_succeeded200_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_succeeded200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_succeeded200_initial.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore - - @distributed_trace_async - async def begin_put201_creating_succeeded200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running put request, service returns a 201 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll - returns a ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put201_creating_succeeded200_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_succeeded200.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore - - async def _post202_retry200_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry200_initial.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore - - @distributed_trace_async - async def begin_post202_retry200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running post request, service returns a 202 to the initial request, with - 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry200.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore - - async def _post_async_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_post_async_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running post request, service returns a 202 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retry_succeeded.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py deleted file mode 100644 index dea230bc6c3..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py +++ /dev/null @@ -1,718 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LRORetrysOperations: - """LRORetrysOperations 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: ~lro.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 - - async def _put201_creating_succeeded200_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_succeeded200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_succeeded200_initial.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore - - @distributed_trace_async - async def begin_put201_creating_succeeded200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 500, then a 201 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll - returns a ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put201_creating_succeeded200_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_succeeded200.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore - - async def _put_async_relative_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_put_async_relative_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 500, then a 200 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_relative_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore - - async def _delete_provisioning202_accepted200_succeeded_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_delete_provisioning202_accepted200_succeeded( - self, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running delete request, service returns a 500, then a 202 to the initial request, with an - entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll - returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_provisioning202_accepted200_succeeded_initial( - cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - async def _delete202_retry200_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete202_retry200_initial.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore - - @distributed_trace_async - async def begin_delete202_retry200(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 500, then a 202 to the initial request. Polls - return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_retry200.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore - - async def _delete_async_relative_retry_succeeded_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_relative_retry_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the - endpoint indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_relative_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore - - async def _post202_retry200_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry200_initial.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore - - @distributed_trace_async - async def begin_post202_retry200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 500, then a 202 to the initial request, with - 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry200.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore - - async def _post_async_relative_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_post_async_relative_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 500, then a 202 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_relative_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py deleted file mode 100644 index f1e8a4c7afb..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py +++ /dev/null @@ -1,3970 +0,0 @@ -# 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, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LROsOperations: - """LROsOperations 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: ~lro.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 - - async def _put200_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> Optional["_models.Product"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_succeeded_initial.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_put200_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put200_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_succeeded.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore - - async def _put201_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_succeeded_initial.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_put201_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put201_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_succeeded.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore - - async def _post202_list_initial(self, **kwargs: Any) -> Optional[List["_models.Product"]]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional[List["_models.Product"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post202_list_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("[Product]", pipeline_response) - - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post202_list_initial.metadata = {"url": "/lro/list"} # type: ignore - - @distributed_trace_async - async def begin_post202_list(self, **kwargs: Any) -> AsyncLROPoller[List["_models.Product"]]: - """Long running put request, service returns a 202 with empty body to first request, returns a 200 - with body [{ 'id': '100', 'name': 'foo' }]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either list of Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[list[~lro.models.Product]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_list_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_list.metadata = {"url": "/lro/list"} # type: ignore - - async def _put200_succeeded_no_state_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_succeeded_no_state_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_succeeded_no_state_initial.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore - - @distributed_trace_async - async def begin_put200_succeeded_no_state( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - does not contain ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put200_succeeded_no_state_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_succeeded_no_state.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore - - async def _put202_retry200_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put202_retry200_initial.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore - - @distributed_trace_async - async def begin_put202_retry200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 202 to the initial request, with a location header - that points to a polling URL that returns a 200 and an entity that doesn't contains - ProvisioningState. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put202_retry200.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore - - async def _put201_creating_succeeded200_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_succeeded200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_succeeded200_initial.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore - - @distributed_trace_async - async def begin_put201_creating_succeeded200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put201_creating_succeeded200_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_succeeded200.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore - - async def _put200_updating_succeeded204_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_updating_succeeded204_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_updating_succeeded204_initial.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore - - @distributed_trace_async - async def begin_put200_updating_succeeded204( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put200_updating_succeeded204_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_updating_succeeded204.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore - - async def _put201_creating_failed200_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_failed200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_failed200_initial.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore - - @distributed_trace_async - async def begin_put201_creating_failed200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Created’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Failed’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put201_creating_failed200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_failed200.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore - - async def _put200_acceptedcanceled200_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_acceptedcanceled200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_acceptedcanceled200_initial.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore - - @distributed_trace_async - async def begin_put200_acceptedcanceled200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Canceled’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put200_acceptedcanceled200_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_acceptedcanceled200.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore - - async def _put_no_header_in_retry_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_no_header_in_retry_initial.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore - - @distributed_trace_async - async def begin_put_no_header_in_retry( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 202 to the initial request with location header. - Subsequent calls to operation status do not contain location header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_no_header_in_retry_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_no_header_in_retry.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore - - async def _put_async_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_retry_succeeded_initial.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_put_async_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_retry_succeeded.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore - - async def _put_async_no_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_no_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_no_retry_succeeded_initial.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_put_async_no_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_no_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_no_retry_succeeded.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore - - async def _put_async_retry_failed_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_retry_failed_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_retry_failed_initial.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore - - @distributed_trace_async - async def begin_put_async_retry_failed( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_retry_failed.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore - - async def _put_async_no_retrycanceled_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_no_retrycanceled_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_no_retrycanceled_initial.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore - - @distributed_trace_async - async def begin_put_async_no_retrycanceled( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_no_retrycanceled_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_no_retrycanceled.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore - - async def _put_async_no_header_in_retry_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_no_header_in_retry_initial.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore - - @distributed_trace_async - async def begin_put_async_no_header_in_retry( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 202 to the initial request with - Azure-AsyncOperation header. Subsequent calls to operation status do not contain - Azure-AsyncOperation header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_no_header_in_retry_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_no_header_in_retry.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore - - async def _put_non_resource_initial(self, sku: Optional["_models.Sku"] = None, **kwargs: Any) -> "_models.Sku": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if sku is not None: - body_content = self._serialize.body(sku, "Sku") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_resource_initial.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore - - @distributed_trace_async - async def begin_put_non_resource( - self, sku: Optional["_models.Sku"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Sku"]: - """Long running put request with non resource. - - :param sku: sku to put. - :type sku: ~lro.models.Sku - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Sku or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Sku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_resource.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore - - async def _put_async_non_resource_initial( - self, sku: Optional["_models.Sku"] = None, **kwargs: Any - ) -> "_models.Sku": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_non_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if sku is not None: - body_content = self._serialize.body(sku, "Sku") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_async_non_resource_initial.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore - - @distributed_trace_async - async def begin_put_async_non_resource( - self, sku: Optional["_models.Sku"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Sku"]: - """Long running put request with non resource. - - :param sku: Sku to put. - :type sku: ~lro.models.Sku - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Sku or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Sku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_non_resource.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore - - async def _put_sub_resource_initial( - self, provisioning_state: Optional[str] = None, **kwargs: Any - ) -> "_models.SubProduct": - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _product = _models.SubProduct(provisioning_state=provisioning_state) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_sub_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _product is not None: - body_content = self._serialize.body(_product, "SubProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_sub_resource_initial.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore - - @distributed_trace_async - async def begin_put_sub_resource( - self, provisioning_state: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SubProduct"]: - """Long running put request with sub resource. - - :param provisioning_state: - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SubProduct or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.SubProduct] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_sub_resource_initial( - provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_sub_resource.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore - - async def _put_async_sub_resource_initial( - self, provisioning_state: Optional[str] = None, **kwargs: Any - ) -> "_models.SubProduct": - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _product = _models.SubProduct(provisioning_state=provisioning_state) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_sub_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _product is not None: - body_content = self._serialize.body(_product, "SubProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_async_sub_resource_initial.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore - - @distributed_trace_async - async def begin_put_async_sub_resource( - self, provisioning_state: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SubProduct"]: - """Long running put request with sub resource. - - :param provisioning_state: - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SubProduct or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.SubProduct] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_sub_resource_initial( - provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_sub_resource.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore - - async def _delete_provisioning202_accepted200_succeeded_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_delete_provisioning202_accepted200_succeeded( - self, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running delete request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_provisioning202_accepted200_succeeded_initial( - cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - async def _delete_provisioning202_deleting_failed200_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_deleting_failed200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_deleting_failed200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore - - @distributed_trace_async - async def begin_delete_provisioning202_deleting_failed200(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: - """Long running delete request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Failed’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_provisioning202_deleting_failed200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_deleting_failed200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore - - async def _delete_provisioning202_deletingcanceled200_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_deletingcanceled200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_deletingcanceled200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore - - @distributed_trace_async - async def begin_delete_provisioning202_deletingcanceled200( - self, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running delete request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Canceled’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_provisioning202_deletingcanceled200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_deletingcanceled200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore - - async def _delete204_succeeded_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete204_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete204_succeeded_initial.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_delete204_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete succeeds and returns right away. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete204_succeeded.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore - - async def _delete202_retry200_initial(self, **kwargs: Any) -> Optional["_models.Product"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete202_retry200_initial.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore - - @distributed_trace_async - async def begin_delete202_retry200(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: - """Long running delete request, service returns a 202 to the initial request. Polls return this - value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_retry200.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore - - async def _delete202_no_retry204_initial(self, **kwargs: Any) -> Optional["_models.Product"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_no_retry204_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete202_no_retry204_initial.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore - - @distributed_trace_async - async def begin_delete202_no_retry204(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: - """Long running delete request, service returns a 202 to the initial request. Polls return this - value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete202_no_retry204_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_no_retry204.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore - - async def _delete_no_header_in_retry_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_no_header_in_retry_initial.metadata = {"url": "/lro/delete/noheader"} # type: ignore - - @distributed_trace_async - async def begin_delete_no_header_in_retry(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a location header in the initial request. - Subsequent calls to operation status do not contain location header. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_no_header_in_retry.metadata = {"url": "/lro/delete/noheader"} # type: ignore - - async def _delete_async_no_header_in_retry_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_no_header_in_retry_initial.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_no_header_in_retry(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns an Azure-AsyncOperation header in the initial - request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_no_header_in_retry.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore - - async def _delete_async_retry_succeeded_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_retry_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_retry_succeeded.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore - - async def _delete_async_no_retry_succeeded_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_no_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_no_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_no_retry_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_no_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_no_retry_succeeded.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore - - async def _delete_async_retry_failed_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_retry_failed_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_retry_failed_initial.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_retry_failed(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_retry_failed_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_retry_failed.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore - - async def _delete_async_retrycanceled_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_retrycanceled_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_retrycanceled_initial.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_retrycanceled(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_retrycanceled_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_retrycanceled.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore - - async def _post200_with_payload_initial(self, **kwargs: Any) -> "_models.Sku": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post200_with_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Sku", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post200_with_payload_initial.metadata = {"url": "/lro/post/payload/200"} # type: ignore - - @distributed_trace_async - async def begin_post200_with_payload(self, **kwargs: Any) -> AsyncLROPoller["_models.Sku"]: - """Long running post request, service returns a 202 to the initial request, with 'Location' - header. Poll returns a 200 with a response body after success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Sku or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Sku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post200_with_payload_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post200_with_payload.metadata = {"url": "/lro/post/payload/200"} # type: ignore - - async def _post202_retry200_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry200_initial.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore - - @distributed_trace_async - async def begin_post202_retry200( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with 'Location' and - 'Retry-After' headers, Polls return a 200 with a response body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry200.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore - - async def _post202_no_retry204_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post202_no_retry204_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post202_no_retry204_initial.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore - - @distributed_trace_async - async def begin_post202_no_retry204( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running post request, service returns a 202 to the initial request, with 'Location' - header, 204 with noresponse body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_no_retry204_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_no_retry204.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore - - async def _post_double_headers_final_location_get_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post_double_headers_final_location_get_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post_double_headers_final_location_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore - - @distributed_trace_async - async def begin_post_double_headers_final_location_get(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: - """Long running post request, service returns a 202 to the initial request with both Location and - Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final - object. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_double_headers_final_location_get_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_double_headers_final_location_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore - - async def _post_double_headers_final_azure_header_get_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post_double_headers_final_azure_header_get_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post_double_headers_final_azure_header_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore - - @distributed_trace_async - async def begin_post_double_headers_final_azure_header_get( - self, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running post request, service returns a 202 to the initial request with both Location and - Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the - final object. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_double_headers_final_azure_header_get_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling( - lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs - ) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_double_headers_final_azure_header_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore - - async def _post_double_headers_final_azure_header_get_default_initial(self, **kwargs: Any) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post_double_headers_final_azure_header_get_default_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post_double_headers_final_azure_header_get_default_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore - - @distributed_trace_async - async def begin_post_double_headers_final_azure_header_get_default( - self, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running post request, service returns a 202 to the initial request with both Location and - Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the - final object if you support initial Autorest behavior. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_double_headers_final_azure_header_get_default_initial( - cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_double_headers_final_azure_header_get_default.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore - - async def _post_async_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> Optional["_models.Product"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_async_retry_succeeded_initial.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_post_async_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retry_succeeded.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore - - async def _post_async_no_retry_succeeded_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> Optional["_models.Product"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_async_no_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_async_no_retry_succeeded_initial.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore - - @distributed_trace_async - async def begin_post_async_no_retry_succeeded( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_no_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_no_retry_succeeded.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore - - async def _post_async_retry_failed_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retry_failed_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_retry_failed_initial.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore - - @distributed_trace_async - async def begin_post_async_retry_failed( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retry_failed.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore - - async def _post_async_retrycanceled_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retrycanceled_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_retrycanceled_initial.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore - - @distributed_trace_async - async def begin_post_async_retrycanceled( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_retrycanceled_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retrycanceled.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py deleted file mode 100644 index e2a73ea2a2c..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py +++ /dev/null @@ -1,2538 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LROSADsOperations: - """LROSADsOperations 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: ~lro.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 - - async def _put_non_retry400_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore - - @distributed_trace_async - async def begin_put_non_retry400( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 400 to the initial request. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_retry400.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore - - async def _put_non_retry201_creating400_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_retry201_creating400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_retry201_creating400_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore - - @distributed_trace_async - async def begin_put_non_retry201_creating400( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and - 201 response code. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_non_retry201_creating400_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_retry201_creating400.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore - - async def _put_non_retry201_creating400_invalid_json_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_retry201_creating400_invalid_json_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_retry201_creating400_invalid_json_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore - - @distributed_trace_async - async def begin_put_non_retry201_creating400_invalid_json( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and - 201 response code. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_non_retry201_creating400_invalid_json_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_retry201_creating400_invalid_json.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore - - async def _put_async_relative_retry400_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore - - @distributed_trace_async - async def begin_put_async_relative_retry400( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the - endpoint indicated in the Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_relative_retry400_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore - - async def _delete_non_retry400_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore - - @distributed_trace_async - async def begin_delete_non_retry400(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 400 with an error body. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore - - async def _delete202_non_retry400_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore - - @distributed_trace_async - async def begin_delete202_non_retry400(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 with a location header. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete202_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore - - async def _delete_async_relative_retry400_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_relative_retry400(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_relative_retry400_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore - - async def _post_non_retry400_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore - - @distributed_trace_async - async def begin_post_non_retry400( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 400 with no error body. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_non_retry400.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore - - async def _post202_non_retry400_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore - - @distributed_trace_async - async def begin_post202_non_retry400( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 with a location header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_non_retry400.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore - - async def _post_async_relative_retry400_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore - - @distributed_trace_async - async def begin_post_async_relative_retry400( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_relative_retry400_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore - - async def _put_error201_no_provisioning_state_payload_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_error201_no_provisioning_state_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_error201_no_provisioning_state_payload_initial.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore - - @distributed_trace_async - async def begin_put_error201_no_provisioning_state_payload( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 201 to the initial request with no payload. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_error201_no_provisioning_state_payload_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_error201_no_provisioning_state_payload.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore - - async def _put_async_relative_retry_no_status_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_no_status_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore - - @distributed_trace_async - async def begin_put_async_relative_retry_no_status( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_relative_retry_no_status_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_no_status.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore - - async def _put_async_relative_retry_no_status_payload_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_no_status_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_no_status_payload_initial.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore - - @distributed_trace_async - async def begin_put_async_relative_retry_no_status_payload( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_relative_retry_no_status_payload_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_no_status_payload.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore - - async def _delete204_succeeded_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete204_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete204_succeeded_initial.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore - - @distributed_trace_async - async def begin_delete204_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 204 to the initial request, indicating success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete204_succeeded.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore - - async def _delete_async_relative_retry_no_status_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_no_status_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_relative_retry_no_status(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_relative_retry_no_status_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_no_status.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore - - async def _post202_no_location_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_no_location_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_no_location_initial.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore - - @distributed_trace_async - async def begin_post202_no_location( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, without a location - header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_no_location_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_no_location.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore - - async def _post_async_relative_retry_no_payload_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_no_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_no_payload_initial.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore - - @distributed_trace_async - async def begin_post_async_relative_retry_no_payload( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_relative_retry_no_payload_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_no_payload.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore - - async def _put200_invalid_json_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> Optional["_models.Product"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_invalid_json_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_invalid_json_initial.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore - - @distributed_trace_async - async def begin_put200_invalid_json( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that is - not a valid json. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put200_invalid_json_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_invalid_json.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore - - async def _put_async_relative_retry_invalid_header_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore - - @distributed_trace_async - async def begin_put_async_relative_retry_invalid_header( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation - header is invalid. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_relative_retry_invalid_header_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore - - async def _put_async_relative_retry_invalid_json_polling_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_invalid_json_polling_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore - - @distributed_trace_async - async def begin_put_async_relative_retry_invalid_json_polling( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Product"]: - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._put_async_relative_retry_invalid_json_polling_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore - - async def _delete202_retry_invalid_header_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete202_retry_invalid_header_initial.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore - - @distributed_trace_async - async def begin_delete202_retry_invalid_header(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request receing a reponse - with an invalid 'Location' and 'Retry-After' headers. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete202_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_retry_invalid_header.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore - - async def _delete_async_relative_retry_invalid_header_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_relative_retry_invalid_header(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. The endpoint - indicated in the Azure-AsyncOperation header is invalid. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_relative_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore - - async def _delete_async_relative_retry_invalid_json_polling_initial(self, **kwargs: Any) -> None: - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_invalid_json_polling_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore - - @distributed_trace_async - async def begin_delete_async_relative_retry_invalid_json_polling(self, **kwargs: Any) -> AsyncLROPoller[None]: - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_async_relative_retry_invalid_json_polling_initial( - cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore - - async def _post202_retry_invalid_header_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry_invalid_header_initial.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore - - @distributed_trace_async - async def begin_post202_retry_invalid_header( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with invalid - 'Location' and 'Retry-After' headers. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post202_retry_invalid_header_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry_invalid_header.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore - - async def _post_async_relative_retry_invalid_header_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore - - @distributed_trace_async - async def begin_post_async_relative_retry_invalid_header( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation - header is invalid. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_relative_retry_invalid_header_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore - - async def _post_async_relative_retry_invalid_json_polling_initial( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_invalid_json_polling_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore - - @distributed_trace_async - async def begin_post_async_relative_retry_invalid_json_polling( - self, product: Optional["_models.Product"] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._post_async_relative_retry_invalid_json_polling_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py deleted file mode 100644 index 5127783aa51..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py +++ /dev/null @@ -1,488 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -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]] - - -class LROsCustomHeaderOperations(object): - """LROsCustomHeaderOperations 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: ~lro.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 - - def _put_async_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_put_async_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running put request, service returns a 200 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_retry_succeeded.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore - - def _put201_creating_succeeded200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_succeeded200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_succeeded200_initial.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore - - @distributed_trace - def begin_put201_creating_succeeded200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running put request, service returns a 201 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll - returns a ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put201_creating_succeeded200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_succeeded200.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore - - def _post202_retry200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry200_initial.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore - - @distributed_trace - def begin_post202_retry200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running post request, service returns a 202 to the initial request, with - 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry200.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore - - def _post_async_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_post_async_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for - all requests. Long running post request, service returns a 202 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retry_succeeded.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py deleted file mode 100644 index 0cb79923a7b..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py +++ /dev/null @@ -1,760 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -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]] - - -class LRORetrysOperations(object): - """LRORetrysOperations 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: ~lro.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 - - def _put201_creating_succeeded200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_succeeded200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_succeeded200_initial.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore - - @distributed_trace - def begin_put201_creating_succeeded200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 500, then a 201 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll - returns a ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put201_creating_succeeded200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_succeeded200.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore - - def _put_async_relative_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_put_async_relative_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 500, then a 200 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_relative_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore - - def _delete_provisioning202_accepted200_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - @distributed_trace - def begin_delete_provisioning202_accepted200_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running delete request, service returns a 500, then a 202 to the initial request, with an - entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll - returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_provisioning202_accepted200_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - def _delete202_retry200_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete202_retry200_initial.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore - - @distributed_trace - def begin_delete202_retry200( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 500, then a 202 to the initial request. Polls - return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_retry200.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore - - def _delete_async_relative_retry_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_delete_async_relative_retry_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the - endpoint indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_relative_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore - - def _post202_retry200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry200_initial.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore - - @distributed_trace - def begin_post202_retry200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 500, then a 202 to the initial request, with - 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry200.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore - - def _post_async_relative_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_post_async_relative_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 500, then a 202 to the initial request, with an - entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the - Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_relative_retry_succeeded_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py deleted file mode 100644 index a7126372229..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py +++ /dev/null @@ -1,4196 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class LROsOperations(object): - """LROsOperations 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: ~lro.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 - - def _put200_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_succeeded_initial.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore - - @distributed_trace - def begin_put200_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put200_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_succeeded.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore - - def _put201_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_succeeded_initial.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore - - @distributed_trace - def begin_put201_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put201_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_succeeded.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore - - def _post202_list_initial( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[List["_models.Product"]] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[List["_models.Product"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post202_list_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("[Product]", pipeline_response) - - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post202_list_initial.metadata = {"url": "/lro/list"} # type: ignore - - @distributed_trace - def begin_post202_list( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[List["_models.Product"]] - """Long running put request, service returns a 202 with empty body to first request, returns a 200 - with body [{ 'id': '100', 'name': 'foo' }]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either list of Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[list[~lro.models.Product]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_list_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_list.metadata = {"url": "/lro/list"} # type: ignore - - def _put200_succeeded_no_state_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_succeeded_no_state_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_succeeded_no_state_initial.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore - - @distributed_trace - def begin_put200_succeeded_no_state( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - does not contain ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put200_succeeded_no_state_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_succeeded_no_state.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore - - def _put202_retry200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put202_retry200_initial.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore - - @distributed_trace - def begin_put202_retry200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 202 to the initial request, with a location header - that points to a polling URL that returns a 200 and an entity that doesn't contains - ProvisioningState. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put202_retry200.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore - - def _put201_creating_succeeded200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_succeeded200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_succeeded200_initial.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore - - @distributed_trace - def begin_put201_creating_succeeded200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put201_creating_succeeded200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_succeeded200.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore - - def _put200_updating_succeeded204_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_updating_succeeded204_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_updating_succeeded204_initial.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore - - @distributed_trace - def begin_put200_updating_succeeded204( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Succeeded’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put200_updating_succeeded204_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_updating_succeeded204.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore - - def _put201_creating_failed200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put201_creating_failed200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put201_creating_failed200_initial.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore - - @distributed_trace - def begin_put201_creating_failed200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Created’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Failed’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put201_creating_failed200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put201_creating_failed200.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore - - def _put200_acceptedcanceled200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_acceptedcanceled200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_acceptedcanceled200_initial.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore - - @distributed_trace - def begin_put200_acceptedcanceled200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 201 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Canceled’. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put200_acceptedcanceled200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_acceptedcanceled200.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore - - def _put_no_header_in_retry_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_no_header_in_retry_initial.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore - - @distributed_trace - def begin_put_no_header_in_retry( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 202 to the initial request with location header. - Subsequent calls to operation status do not contain location header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_no_header_in_retry_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_no_header_in_retry.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore - - def _put_async_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_retry_succeeded_initial.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_put_async_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_retry_succeeded.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore - - def _put_async_no_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_no_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_no_retry_succeeded_initial.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore - - @distributed_trace - def begin_put_async_no_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_no_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_no_retry_succeeded.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore - - def _put_async_retry_failed_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_retry_failed_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_retry_failed_initial.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore - - @distributed_trace - def begin_put_async_retry_failed( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_retry_failed.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore - - def _put_async_no_retrycanceled_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_no_retrycanceled_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_no_retrycanceled_initial.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore - - @distributed_trace - def begin_put_async_no_retrycanceled( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_no_retrycanceled_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_no_retrycanceled.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore - - def _put_async_no_header_in_retry_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_no_header_in_retry_initial.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore - - @distributed_trace - def begin_put_async_no_header_in_retry( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 202 to the initial request with - Azure-AsyncOperation header. Subsequent calls to operation status do not contain - Azure-AsyncOperation header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_no_header_in_retry_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_no_header_in_retry.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore - - def _put_non_resource_initial( - self, - sku=None, # type: Optional["_models.Sku"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Sku" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if sku is not None: - body_content = self._serialize.body(sku, "Sku") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_resource_initial.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore - - @distributed_trace - def begin_put_non_resource( - self, - sku=None, # type: Optional["_models.Sku"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Sku"] - """Long running put request with non resource. - - :param sku: sku to put. - :type sku: ~lro.models.Sku - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Sku or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Sku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_resource.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore - - def _put_async_non_resource_initial( - self, - sku=None, # type: Optional["_models.Sku"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Sku" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_non_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if sku is not None: - body_content = self._serialize.body(sku, "Sku") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_async_non_resource_initial.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore - - @distributed_trace - def begin_put_async_non_resource( - self, - sku=None, # type: Optional["_models.Sku"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Sku"] - """Long running put request with non resource. - - :param sku: Sku to put. - :type sku: ~lro.models.Sku - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Sku or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Sku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_non_resource.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore - - def _put_sub_resource_initial( - self, - provisioning_state=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SubProduct" - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _product = _models.SubProduct(provisioning_state=provisioning_state) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_sub_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _product is not None: - body_content = self._serialize.body(_product, "SubProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_sub_resource_initial.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore - - @distributed_trace - def begin_put_sub_resource( - self, - provisioning_state=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SubProduct"] - """Long running put request with sub resource. - - :param provisioning_state: - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SubProduct or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.SubProduct] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_sub_resource_initial( - provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_sub_resource.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore - - def _put_async_sub_resource_initial( - self, - provisioning_state=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SubProduct" - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _product = _models.SubProduct(provisioning_state=provisioning_state) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_sub_resource_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _product is not None: - body_content = self._serialize.body(_product, "SubProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_async_sub_resource_initial.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore - - @distributed_trace - def begin_put_async_sub_resource( - self, - provisioning_state=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SubProduct"] - """Long running put request with sub resource. - - :param provisioning_state: - :type provisioning_state: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SubProduct or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.SubProduct] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_sub_resource_initial( - provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_sub_resource.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore - - def _delete_provisioning202_accepted200_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - @distributed_trace - def begin_delete_provisioning202_accepted200_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running delete request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_provisioning202_accepted200_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore - - def _delete_provisioning202_deleting_failed200_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_deleting_failed200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_deleting_failed200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore - - @distributed_trace - def begin_delete_provisioning202_deleting_failed200( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running delete request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Failed’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_provisioning202_deleting_failed200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_deleting_failed200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore - - def _delete_provisioning202_deletingcanceled200_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_provisioning202_deletingcanceled200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete_provisioning202_deletingcanceled200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore - - @distributed_trace - def begin_delete_provisioning202_deletingcanceled200( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running delete request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a - ‘200’ with ProvisioningState=’Canceled’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_provisioning202_deletingcanceled200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_provisioning202_deletingcanceled200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore - - def _delete204_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete204_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete204_succeeded_initial.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore - - @distributed_trace - def begin_delete204_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete succeeds and returns right away. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete204_succeeded.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore - - def _delete202_retry200_initial( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete202_retry200_initial.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore - - @distributed_trace - def begin_delete202_retry200( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running delete request, service returns a 202 to the initial request. Polls return this - value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_retry200.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore - - def _delete202_no_retry204_initial( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_no_retry204_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _delete202_no_retry204_initial.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore - - @distributed_trace - def begin_delete202_no_retry204( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running delete request, service returns a 202 to the initial request. Polls return this - value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete202_no_retry204_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_no_retry204.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore - - def _delete_no_header_in_retry_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_no_header_in_retry_initial.metadata = {"url": "/lro/delete/noheader"} # type: ignore - - @distributed_trace - def begin_delete_no_header_in_retry( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a location header in the initial request. - Subsequent calls to operation status do not contain location header. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_no_header_in_retry.metadata = {"url": "/lro/delete/noheader"} # type: ignore - - def _delete_async_no_header_in_retry_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_no_header_in_retry_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_no_header_in_retry_initial.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore - - @distributed_trace - def begin_delete_async_no_header_in_retry( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns an Azure-AsyncOperation header in the initial - request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_no_header_in_retry.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore - - def _delete_async_retry_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_delete_async_retry_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_retry_succeeded.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore - - def _delete_async_no_retry_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_no_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_no_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore - - @distributed_trace - def begin_delete_async_no_retry_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_no_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_no_retry_succeeded.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore - - def _delete_async_retry_failed_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_retry_failed_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_retry_failed_initial.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore - - @distributed_trace - def begin_delete_async_retry_failed( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_retry_failed_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_retry_failed.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore - - def _delete_async_retrycanceled_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_retrycanceled_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_retrycanceled_initial.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore - - @distributed_trace - def begin_delete_async_retrycanceled( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_retrycanceled_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_retrycanceled.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore - - def _post200_with_payload_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Sku" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post200_with_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Sku", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post200_with_payload_initial.metadata = {"url": "/lro/post/payload/200"} # type: ignore - - @distributed_trace - def begin_post200_with_payload( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Sku"] - """Long running post request, service returns a 202 to the initial request, with 'Location' - header. Poll returns a 200 with a response body after success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Sku or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Sku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post200_with_payload_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Sku", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post200_with_payload.metadata = {"url": "/lro/post/payload/200"} # type: ignore - - def _post202_retry200_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry200_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry200_initial.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore - - @distributed_trace - def begin_post202_retry200( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with 'Location' and - 'Retry-After' headers, Polls return a 200 with a response body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry200.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore - - def _post202_no_retry204_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post202_no_retry204_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post202_no_retry204_initial.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore - - @distributed_trace - def begin_post202_no_retry204( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running post request, service returns a 202 to the initial request, with 'Location' - header, 204 with noresponse body after success. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_no_retry204_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_no_retry204.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore - - def _post_double_headers_final_location_get_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post_double_headers_final_location_get_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post_double_headers_final_location_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore - - @distributed_trace - def begin_post_double_headers_final_location_get( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running post request, service returns a 202 to the initial request with both Location and - Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final - object. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_double_headers_final_location_get_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_double_headers_final_location_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore - - def _post_double_headers_final_azure_header_get_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post_double_headers_final_azure_header_get_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post_double_headers_final_azure_header_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore - - @distributed_trace - def begin_post_double_headers_final_azure_header_get( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running post request, service returns a 202 to the initial request with both Location and - Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the - final object. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_double_headers_final_azure_header_get_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_double_headers_final_azure_header_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore - - def _post_double_headers_final_azure_header_get_default_initial( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._post_double_headers_final_azure_header_get_default_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _post_double_headers_final_azure_header_get_default_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore - - @distributed_trace - def begin_post_double_headers_final_azure_header_get_default( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running post request, service returns a 202 to the initial request with both Location and - Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the - final object if you support initial Autorest behavior. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_double_headers_final_azure_header_get_default_initial( - cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_double_headers_final_azure_header_get_default.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore - - def _post_async_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_async_retry_succeeded_initial.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore - - @distributed_trace - def begin_post_async_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retry_succeeded.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore - - def _post_async_no_retry_succeeded_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_async_no_retry_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_async_no_retry_succeeded_initial.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore - - @distributed_trace - def begin_post_async_no_retry_succeeded( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_no_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_no_retry_succeeded.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore - - def _post_async_retry_failed_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retry_failed_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_retry_failed_initial.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore - - @distributed_trace - def begin_post_async_retry_failed( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retry_failed.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore - - def _post_async_retrycanceled_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_retrycanceled_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_retrycanceled_initial.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore - - @distributed_trace - def begin_post_async_retrycanceled( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_retrycanceled_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_retrycanceled.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py deleted file mode 100644 index 088bbf5b5fc..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py +++ /dev/null @@ -1,2694 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -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]] - - -class LROSADsOperations(object): - """LROSADsOperations 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: ~lro.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 - - def _put_non_retry400_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore - - @distributed_trace - def begin_put_non_retry400( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 400 to the initial request. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_retry400.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore - - def _put_non_retry201_creating400_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_retry201_creating400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_retry201_creating400_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore - - @distributed_trace - def begin_put_non_retry201_creating400( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and - 201 response code. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_non_retry201_creating400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_retry201_creating400.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore - - def _put_non_retry201_creating400_invalid_json_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_non_retry201_creating400_invalid_json_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_non_retry201_creating400_invalid_json_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore - - @distributed_trace - def begin_put_non_retry201_creating400_invalid_json( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and - 201 response code. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_non_retry201_creating400_invalid_json_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_non_retry201_creating400_invalid_json.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore - - def _put_async_relative_retry400_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore - - @distributed_trace - def begin_put_async_relative_retry400( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the - endpoint indicated in the Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_relative_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore - - def _delete_non_retry400_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore - - @distributed_trace - def begin_delete_non_retry400( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 400 with an error body. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore - - def _delete202_non_retry400_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore - - @distributed_trace - def begin_delete202_non_retry400( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 with a location header. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete202_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore - - def _delete_async_relative_retry400_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore - - @distributed_trace - def begin_delete_async_relative_retry400( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_relative_retry400_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore - - def _post_non_retry400_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore - - @distributed_trace - def begin_post_non_retry400( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 400 with no error body. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_non_retry400.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore - - def _post202_non_retry400_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_non_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore - - @distributed_trace - def begin_post202_non_retry400( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 with a location header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_non_retry400.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore - - def _post_async_relative_retry400_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry400_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore - - @distributed_trace - def begin_post_async_relative_retry400( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_relative_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore - - def _put_error201_no_provisioning_state_payload_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_error201_no_provisioning_state_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put_error201_no_provisioning_state_payload_initial.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore - - @distributed_trace - def begin_put_error201_no_provisioning_state_payload( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 201 to the initial request with no payload. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_error201_no_provisioning_state_payload_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_error201_no_provisioning_state_payload.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore - - def _put_async_relative_retry_no_status_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_no_status_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore - - @distributed_trace - def begin_put_async_relative_retry_no_status( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_relative_retry_no_status_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_no_status.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore - - def _put_async_relative_retry_no_status_payload_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_no_status_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_no_status_payload_initial.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore - - @distributed_trace - def begin_put_async_relative_retry_no_status_payload( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_relative_retry_no_status_payload_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_no_status_payload.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore - - def _delete204_succeeded_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete204_succeeded_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete204_succeeded_initial.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore - - @distributed_trace - def begin_delete204_succeeded( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 204 to the initial request, indicating success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete204_succeeded.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore - - def _delete_async_relative_retry_no_status_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_no_status_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore - - @distributed_trace - def begin_delete_async_relative_retry_no_status( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_relative_retry_no_status_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_no_status.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore - - def _post202_no_location_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_no_location_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_no_location_initial.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore - - @distributed_trace - def begin_post202_no_location( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, without a location - header. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_no_location_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_no_location.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore - - def _post_async_relative_retry_no_payload_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_no_payload_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_no_payload_initial.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore - - @distributed_trace - def begin_post_async_relative_retry_no_payload( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_relative_retry_no_payload_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_no_payload.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore - - def _put200_invalid_json_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put200_invalid_json_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _put200_invalid_json_initial.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore - - @distributed_trace - def begin_put200_invalid_json( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that is - not a valid json. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put200_invalid_json_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put200_invalid_json.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore - - def _put_async_relative_retry_invalid_header_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore - - @distributed_trace - def begin_put_async_relative_retry_invalid_header( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation - header is invalid. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_relative_retry_invalid_header_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore - - def _put_async_relative_retry_invalid_json_polling_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._put_async_relative_retry_invalid_json_polling_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _put_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore - - @distributed_trace - def begin_put_async_relative_retry_invalid_json_polling( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Product"] - """Long running put request, service returns a 200 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either Product or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._put_async_relative_retry_invalid_json_polling_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - return deserialized - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_put_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore - - def _delete202_retry_invalid_header_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete202_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete202_retry_invalid_header_initial.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore - - @distributed_trace - def begin_delete202_retry_invalid_header( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request receing a reponse - with an invalid 'Location' and 'Retry-After' headers. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete202_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete202_retry_invalid_header.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore - - def _delete_async_relative_retry_invalid_header_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore - - @distributed_trace - def begin_delete_async_relative_retry_invalid_header( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. The endpoint - indicated in the Azure-AsyncOperation header is invalid. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_relative_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore - - def _delete_async_relative_retry_invalid_json_polling_initial( - self, **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop("cls", None) # type: ClsType[None] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._delete_async_relative_retry_invalid_json_polling_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore - - @distributed_trace - def begin_delete_async_relative_retry_invalid_json_polling( - self, **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running delete request, service returns a 202 to the initial request. Poll the endpoint - indicated in the Azure-AsyncOperation header for operation status. - - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_async_relative_retry_invalid_json_polling_initial(cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore - - def _post202_retry_invalid_header_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post202_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post202_retry_invalid_header_initial.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore - - @distributed_trace - def begin_post202_retry_invalid_header( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with invalid - 'Location' and 'Retry-After' headers. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post202_retry_invalid_header_initial(product=product, cls=lambda x, y, z: x, **kwargs) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post202_retry_invalid_header.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore - - def _post_async_relative_retry_invalid_header_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_invalid_header_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore - - @distributed_trace - def begin_post_async_relative_retry_invalid_header( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation - header is invalid. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_relative_retry_invalid_header_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore - - def _post_async_relative_retry_invalid_json_polling_initial( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - 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/json") - accept = "application/json" - - # Construct URL - url = self._post_async_relative_retry_invalid_json_polling_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if product is not None: - body_content = self._serialize.body(product, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _post_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore - - @distributed_trace - def begin_post_async_relative_retry_invalid_json_polling( - self, - product=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Long running post request, service returns a 202 to the initial request, with an entity that - contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation - header for operation status. - - :param product: Product to put. - :type product: ~lro.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[None] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._post_async_relative_retry_invalid_json_polling_initial( - product=product, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_post_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/setup.py b/test/azure/Expected/AcceptanceTests/Lro/setup.py deleted file mode 100644 index ed6ad765f49..00000000000 --- a/test/azure/Expected/AcceptanceTests/Lro/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestlongrunningoperationtestservice" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestLongRunningOperationTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestLongRunningOperationTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Long-running Operation for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_lro_with_paramaterized_endpoints.py b/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_lro_with_paramaterized_endpoints.py deleted file mode 100644 index 391e7848a0d..00000000000 --- a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_lro_with_paramaterized_endpoints.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import LROWithParamaterizedEndpointsConfiguration -from .operations import LROWithParamaterizedEndpointsOperationsMixin -from . import models - - -class LROWithParamaterizedEndpoints(LROWithParamaterizedEndpointsOperationsMixin): - """Test Infrastructure for AutoRest. - - :param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test. - :type host: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - host="host", # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = "http://{accountName}{host}" - self._config = LROWithParamaterizedEndpointsConfiguration(host, **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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> LROWithParamaterizedEndpoints - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_lro_with_paramaterized_endpoints.py b/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_lro_with_paramaterized_endpoints.py deleted file mode 100644 index e0a0ecf18d4..00000000000 --- a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_lro_with_paramaterized_endpoints.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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 import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import LROWithParamaterizedEndpointsConfiguration -from .operations import LROWithParamaterizedEndpointsOperationsMixin -from .. import models - - -class LROWithParamaterizedEndpoints(LROWithParamaterizedEndpointsOperationsMixin): - """Test Infrastructure for AutoRest. - - :param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test. - :type host: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__(self, host: str = "host", **kwargs: Any) -> None: - base_url = "http://{accountName}{host}" - self._config = LROWithParamaterizedEndpointsConfiguration(host, **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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "LROWithParamaterizedEndpoints": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py b/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py deleted file mode 100644 index f60c42c6490..00000000000 --- a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py +++ /dev/null @@ -1,248 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LROWithParamaterizedEndpointsOperationsMixin: - async def _poll_with_parameterized_endpoints_initial(self, account_name: str, **kwargs: Any) -> Optional[str]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._poll_with_parameterized_endpoints_initial.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("str", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _poll_with_parameterized_endpoints_initial.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore - - @distributed_trace_async - async def begin_poll_with_parameterized_endpoints(self, account_name: str, **kwargs: Any) -> AsyncLROPoller[str]: - """Poll with method and client level parameters in endpoint. - - :param account_name: Account Name. Pass in 'local' to pass test. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either str or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[str] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._poll_with_parameterized_endpoints_initial( - account_name=account_name, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - - if polling is True: - polling_method = AsyncLROBasePolling( - lro_delay, - lro_options={"final-state-via": "location"}, - path_format_arguments=path_format_arguments, - **kwargs - ) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_poll_with_parameterized_endpoints.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore - - async def _poll_with_constant_parameterized_endpoints_initial( - self, account_name: str, **kwargs: Any - ) -> Optional[str]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - constant_parameter = "iAmConstant" - accept = "application/json" - - # Construct URL - url = self._poll_with_constant_parameterized_endpoints_initial.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - "constantParameter": self._serialize.url("constant_parameter", constant_parameter, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("str", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _poll_with_constant_parameterized_endpoints_initial.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore - - @distributed_trace_async - async def begin_poll_with_constant_parameterized_endpoints( - self, account_name: str, **kwargs: Any - ) -> AsyncLROPoller[str]: - """Poll with method and client level parameters in endpoint, with a constant value. - - :param account_name: Account Name. Pass in 'local' to pass test. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either str or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[str] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._poll_with_constant_parameterized_endpoints_initial( - account_name=account_name, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - constant_parameter = "iAmConstant" - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - "constantParameter": self._serialize.url("constant_parameter", constant_parameter, "str", skip_quote=True), - } - - if polling is True: - polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_poll_with_constant_parameterized_endpoints.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py b/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py deleted file mode 100644 index 5189ff99d56..00000000000 --- a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py +++ /dev/null @@ -1,268 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class LROWithParamaterizedEndpointsOperationsMixin(object): - def _poll_with_parameterized_endpoints_initial( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self._poll_with_parameterized_endpoints_initial.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("str", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _poll_with_parameterized_endpoints_initial.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore - - @distributed_trace - def begin_poll_with_parameterized_endpoints( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[str] - """Poll with method and client level parameters in endpoint. - - :param account_name: Account Name. Pass in 'local' to pass test. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either str or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[str] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._poll_with_parameterized_endpoints_initial( - account_name=account_name, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - - if polling is True: - polling_method = LROBasePolling( - lro_delay, - lro_options={"final-state-via": "location"}, - path_format_arguments=path_format_arguments, - **kwargs - ) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_poll_with_parameterized_endpoints.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore - - def _poll_with_constant_parameterized_endpoints_initial( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - constant_parameter = "iAmConstant" - accept = "application/json" - - # Construct URL - url = self._poll_with_constant_parameterized_endpoints_initial.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - "constantParameter": self._serialize.url("constant_parameter", constant_parameter, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("str", pipeline_response) - - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _poll_with_constant_parameterized_endpoints_initial.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore - - @distributed_trace - def begin_poll_with_constant_parameterized_endpoints( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[str] - """Poll with method and client level parameters in endpoint, with a constant value. - - :param account_name: Account Name. Pass in 'local' to pass test. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either str or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType[str] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._poll_with_constant_parameterized_endpoints_initial( - account_name=account_name, cls=lambda x, y, z: x, **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - constant_parameter = "iAmConstant" - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - "constantParameter": self._serialize.url("constant_parameter", constant_parameter, "str", skip_quote=True), - } - - if polling is True: - polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_poll_with_constant_parameterized_endpoints.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/setup.py b/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/setup.py deleted file mode 100644 index a6f1bd63dae..00000000000 --- a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "lrowithparamaterizedendpoints" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="LROWithParamaterizedEndpoints", - author_email="", - url="", - keywords=["Swagger", "LROWithParamaterizedEndpoints"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py b/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py deleted file mode 100644 index f9cf2af00bb..00000000000 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py +++ /dev/null @@ -1,78 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestPagingTestServiceConfiguration -from .operations import PagingOperations -from . import models - - -class AutoRestPagingTestService(object): - """Long-running Operation for AutoRest. - - :ivar paging: PagingOperations operations - :vartype paging: paging.operations.PagingOperations - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestPagingTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paging = PagingOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestPagingTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py deleted file mode 100644 index cde78f985eb..00000000000 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestPagingTestServiceConfiguration -from .operations import PagingOperations -from .. import models - - -class AutoRestPagingTestService(object): - """Long-running Operation for AutoRest. - - :ivar paging: PagingOperations operations - :vartype paging: paging.aio.operations.PagingOperations - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestPagingTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paging = PagingOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestPagingTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py deleted file mode 100644 index 99d8690b623..00000000000 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py +++ /dev/null @@ -1,1242 +0,0 @@ -# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PagingOperations: - """PagingOperations 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: ~paging.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 - def get_no_item_name_pages(self, **kwargs: Any) -> AsyncIterable["_models.ProductResultValue"]: - """A paging operation that must return result of the default 'value' node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_no_item_name_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResultValue", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_no_item_name_pages.metadata = {"url": "/paging/noitemname"} # type: ignore - - @distributed_trace - def get_null_next_link_name_pages(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that must ignore any kind of nextLink, and stop after page 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_null_next_link_name_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_null_next_link_name_pages.metadata = {"url": "/paging/nullnextlink"} # type: ignore - - @distributed_trace - def get_single_pages(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that finishes on the first call without a nextlink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_single_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_single_pages.metadata = {"url": "/paging/single"} # type: ignore - - @distributed_trace - def first_response_empty(self, **kwargs: Any) -> AsyncIterable["_models.ProductResultValue"]: - """A paging operation whose first response's items list is empty, but still returns a next link. - Second (and final) call, will give you an items list of 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.first_response_empty.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResultValue", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - first_response_empty.metadata = {"url": "/paging/firstResponseEmpty/1"} # type: ignore - - @distributed_trace - def get_multiple_pages( - self, - client_request_id: Optional[str] = None, - paging_get_multiple_pages_options: Optional["_models.PagingGetMultiplePagesOptions"] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_options: Parameter group. - :type paging_get_multiple_pages_options: ~paging.models.PagingGetMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_options is not None: - _maxresults = paging_get_multiple_pages_options.maxresults - _timeout = paging_get_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages.metadata = {"url": "/paging/multiple"} # type: ignore - - @distributed_trace - def get_with_query_params( - self, required_query_parameter: int, **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a next operation. It has a different query parameter from it's - next operation nextOperationWithQueryParams. Returns a ProductResult. - - :param required_query_parameter: A required integer query parameter. Put in value '100' to pass - test. - :type required_query_parameter: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - query_constant = True - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_with_query_params.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["requiredQueryParameter"] = self._serialize.query( - "required_query_parameter", required_query_parameter, "int" - ) - query_parameters["queryConstant"] = self._serialize.query("query_constant", query_constant, "bool") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/multiple/nextOperationWithQueryParams" - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["queryConstant"] = self._serialize.query("query_constant", query_constant, "bool") - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_with_query_params.metadata = {"url": "/paging/multiple/getWithQueryParams"} # type: ignore - - @distributed_trace - def get_odata_multiple_pages( - self, - client_request_id: Optional[str] = None, - paging_get_odata_multiple_pages_options: Optional["_models.PagingGetOdataMultiplePagesOptions"] = None, - **kwargs: Any - ) -> AsyncIterable["_models.OdataProductResult"]: - """A paging operation that includes a nextLink in odata format that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_odata_multiple_pages_options: Parameter group. - :type paging_get_odata_multiple_pages_options: ~paging.models.PagingGetOdataMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_odata_multiple_pages_options is not None: - _maxresults = paging_get_odata_multiple_pages_options.maxresults - _timeout = paging_get_odata_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_odata_multiple_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OdataProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_odata_multiple_pages.metadata = {"url": "/paging/multiple/odata"} # type: ignore - - @distributed_trace - def get_multiple_pages_with_offset( - self, - paging_get_multiple_pages_with_offset_options: "_models.PagingGetMultiplePagesWithOffsetOptions", - client_request_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a nextLink that has 10 pages. - - :param paging_get_multiple_pages_with_offset_options: Parameter group. - :type paging_get_multiple_pages_with_offset_options: ~paging.models.PagingGetMultiplePagesWithOffsetOptions - :param client_request_id: - :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _offset = None - _timeout = None - if paging_get_multiple_pages_with_offset_options is not None: - _maxresults = paging_get_multiple_pages_with_offset_options.maxresults - _offset = paging_get_multiple_pages_with_offset_options.offset - _timeout = paging_get_multiple_pages_with_offset_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_with_offset.metadata["url"] # type: ignore - path_format_arguments = { - "offset": self._serialize.url("offset", _offset, "int"), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_with_offset.metadata = {"url": "/paging/multiple/withpath/{offset}"} # type: ignore - - @distributed_trace - def get_multiple_pages_retry_first(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that fails on the first call with 500 and then retries and then get a - response including a nextLink that has 10 pages. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_first.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_retry_first.metadata = {"url": "/paging/multiple/retryfirst"} # type: ignore - - @distributed_trace - def get_multiple_pages_retry_second(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails - first with 500. The client should retry and finish all 10 pages eventually. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_second.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_retry_second.metadata = {"url": "/paging/multiple/retrysecond"} # type: ignore - - @distributed_trace - def get_single_pages_failure(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that receives a 400 on the first call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_single_pages_failure.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_single_pages_failure.metadata = {"url": "/paging/single/failure"} # type: ignore - - @distributed_trace - def get_multiple_pages_failure(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that receives a 400 on the second call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_failure.metadata = {"url": "/paging/multiple/failure"} # type: ignore - - @distributed_trace - def get_multiple_pages_failure_uri(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: - """A paging operation that receives an invalid nextLink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure_uri.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_failure_uri.metadata = {"url": "/paging/multiple/failureuri"} # type: ignore - - @distributed_trace - def get_multiple_pages_fragment_next_link( - self, api_version: str, tenant: str, **kwargs: Any - ) -> AsyncIterable["_models.OdataProductResult"]: - """A paging operation that doesn't return a full URL, just a fragment. - - :param api_version: Sets the api version to use. - :type api_version: str - :param tenant: Sets the tenant to use. - :type tenant: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_next_link.metadata["url"] # type: ignore - path_format_arguments = { - "tenant": self._serialize.url("tenant", tenant, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/multiple/fragment/{tenant}/{nextLink}" - path_format_arguments = { - "tenant": self._serialize.url("tenant", tenant, "str"), - "nextLink": self._serialize.url("next_link", next_link, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OdataProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_fragment_next_link.metadata = {"url": "/paging/multiple/fragment/{tenant}"} # type: ignore - - @distributed_trace - def get_multiple_pages_fragment_with_grouping_next_link( - self, custom_parameter_group: "_models.CustomParameterGroup", **kwargs: Any - ) -> AsyncIterable["_models.OdataProductResult"]: - """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. - - :param custom_parameter_group: Parameter group. - :type custom_parameter_group: ~paging.models.CustomParameterGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _api_version = None - _tenant = None - if custom_parameter_group is not None: - _api_version = custom_parameter_group.api_version - _tenant = custom_parameter_group.tenant - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_with_grouping_next_link.metadata["url"] # type: ignore - path_format_arguments = { - "tenant": self._serialize.url("tenant", _tenant, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", _api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}" - path_format_arguments = { - "tenant": self._serialize.url("tenant", _tenant, "str"), - "nextLink": self._serialize.url("next_link", next_link, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", _api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OdataProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_multiple_pages_fragment_with_grouping_next_link.metadata = {"url": "/paging/multiple/fragmentwithgrouping/{tenant}"} # type: ignore - - async def _get_multiple_pages_lro_initial( - self, - client_request_id: Optional[str] = None, - paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, - **kwargs: Any - ) -> "_models.ProductResult": - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - # Construct URL - url = self._get_multiple_pages_lro_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ProductResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _get_multiple_pages_lro_initial.metadata = {"url": "/paging/multiple/lro"} # type: ignore - - @distributed_trace_async - async def begin_get_multiple_pages_lro( - self, - client_request_id: Optional[str] = None, - paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, - **kwargs: Any - ) -> AsyncLROPoller[AsyncItemPaged["_models.ProductResult"]]: - """A long-running paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_lro_options: Parameter group. - :type paging_get_multiple_pages_lro_options: ~paging.models.PagingGetMultiplePagesLroOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_lro.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.post(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._get_multiple_pages_lro_initial( - client_request_id=client_request_id, - paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, - cls=lambda x, y, z: x, - **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - async def internal_get_next(next_link=None): - if next_link is None: - return pipeline_response - else: - return await get_next(next_link) - - return AsyncItemPaged(internal_get_next, extract_data) - - if polling is True: - polling_method = AsyncLROBasePolling(lro_delay, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_get_multiple_pages_lro.metadata = {"url": "/paging/multiple/lro"} # type: ignore - - @distributed_trace - def get_paging_model_with_item_name_with_xms_client_name( - self, **kwargs: Any - ) -> AsyncIterable["_models.ProductResultValueWithXMSClientName"]: - """A paging operation that returns a paging model whose item name is is overriden by - x-ms-client-name 'indexes'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValueWithXMSClientName] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_paging_model_with_item_name_with_xms_client_name.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResultValueWithXMSClientName", pipeline_response) - list_of_elem = deserialized.indexes - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get_paging_model_with_item_name_with_xms_client_name.metadata = {"url": "/paging/itemNameWithXMSClientName"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py deleted file mode 100644 index 6ab6dac8ee2..00000000000 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py +++ /dev/null @@ -1,1288 +0,0 @@ -# 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 -import warnings - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class PagingOperations(object): - """PagingOperations 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: ~paging.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 get_no_item_name_pages( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResultValue"] - """A paging operation that must return result of the default 'value' node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_no_item_name_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResultValue", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_no_item_name_pages.metadata = {"url": "/paging/noitemname"} # type: ignore - - @distributed_trace - def get_null_next_link_name_pages( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that must ignore any kind of nextLink, and stop after page 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_null_next_link_name_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_null_next_link_name_pages.metadata = {"url": "/paging/nullnextlink"} # type: ignore - - @distributed_trace - def get_single_pages( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that finishes on the first call without a nextlink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_single_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_single_pages.metadata = {"url": "/paging/single"} # type: ignore - - @distributed_trace - def first_response_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResultValue"] - """A paging operation whose first response's items list is empty, but still returns a next link. - Second (and final) call, will give you an items list of 1. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValue or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValue] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.first_response_empty.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResultValue", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - first_response_empty.metadata = {"url": "/paging/firstResponseEmpty/1"} # type: ignore - - @distributed_trace - def get_multiple_pages( - self, - client_request_id=None, # type: Optional[str] - paging_get_multiple_pages_options=None, # type: Optional["_models.PagingGetMultiplePagesOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_options: Parameter group. - :type paging_get_multiple_pages_options: ~paging.models.PagingGetMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_options is not None: - _maxresults = paging_get_multiple_pages_options.maxresults - _timeout = paging_get_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages.metadata = {"url": "/paging/multiple"} # type: ignore - - @distributed_trace - def get_with_query_params( - self, - required_query_parameter, # type: int - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a next operation. It has a different query parameter from it's - next operation nextOperationWithQueryParams. Returns a ProductResult. - - :param required_query_parameter: A required integer query parameter. Put in value '100' to pass - test. - :type required_query_parameter: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - query_constant = True - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_with_query_params.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["requiredQueryParameter"] = self._serialize.query( - "required_query_parameter", required_query_parameter, "int" - ) - query_parameters["queryConstant"] = self._serialize.query("query_constant", query_constant, "bool") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/multiple/nextOperationWithQueryParams" - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["queryConstant"] = self._serialize.query("query_constant", query_constant, "bool") - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_with_query_params.metadata = {"url": "/paging/multiple/getWithQueryParams"} # type: ignore - - @distributed_trace - def get_odata_multiple_pages( - self, - client_request_id=None, # type: Optional[str] - paging_get_odata_multiple_pages_options=None, # type: Optional["_models.PagingGetOdataMultiplePagesOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OdataProductResult"] - """A paging operation that includes a nextLink in odata format that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_odata_multiple_pages_options: Parameter group. - :type paging_get_odata_multiple_pages_options: ~paging.models.PagingGetOdataMultiplePagesOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_odata_multiple_pages_options is not None: - _maxresults = paging_get_odata_multiple_pages_options.maxresults - _timeout = paging_get_odata_multiple_pages_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_odata_multiple_pages.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OdataProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_odata_multiple_pages.metadata = {"url": "/paging/multiple/odata"} # type: ignore - - @distributed_trace - def get_multiple_pages_with_offset( - self, - paging_get_multiple_pages_with_offset_options, # type: "_models.PagingGetMultiplePagesWithOffsetOptions" - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a nextLink that has 10 pages. - - :param paging_get_multiple_pages_with_offset_options: Parameter group. - :type paging_get_multiple_pages_with_offset_options: ~paging.models.PagingGetMultiplePagesWithOffsetOptions - :param client_request_id: - :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _offset = None - _timeout = None - if paging_get_multiple_pages_with_offset_options is not None: - _maxresults = paging_get_multiple_pages_with_offset_options.maxresults - _offset = paging_get_multiple_pages_with_offset_options.offset - _timeout = paging_get_multiple_pages_with_offset_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_with_offset.metadata["url"] # type: ignore - path_format_arguments = { - "offset": self._serialize.url("offset", _offset, "int"), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_with_offset.metadata = {"url": "/paging/multiple/withpath/{offset}"} # type: ignore - - @distributed_trace - def get_multiple_pages_retry_first( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that fails on the first call with 500 and then retries and then get a - response including a nextLink that has 10 pages. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_first.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_retry_first.metadata = {"url": "/paging/multiple/retryfirst"} # type: ignore - - @distributed_trace - def get_multiple_pages_retry_second( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails - first with 500. The client should retry and finish all 10 pages eventually. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_retry_second.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_retry_second.metadata = {"url": "/paging/multiple/retrysecond"} # type: ignore - - @distributed_trace - def get_single_pages_failure( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that receives a 400 on the first call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_single_pages_failure.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_single_pages_failure.metadata = {"url": "/paging/single/failure"} # type: ignore - - @distributed_trace - def get_multiple_pages_failure( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that receives a 400 on the second call. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_failure.metadata = {"url": "/paging/multiple/failure"} # type: ignore - - @distributed_trace - def get_multiple_pages_failure_uri( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResult"] - """A paging operation that receives an invalid nextLink. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_failure_uri.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_failure_uri.metadata = {"url": "/paging/multiple/failureuri"} # type: ignore - - @distributed_trace - def get_multiple_pages_fragment_next_link( - self, - api_version, # type: str - tenant, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OdataProductResult"] - """A paging operation that doesn't return a full URL, just a fragment. - - :param api_version: Sets the api version to use. - :type api_version: str - :param tenant: Sets the tenant to use. - :type tenant: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_next_link.metadata["url"] # type: ignore - path_format_arguments = { - "tenant": self._serialize.url("tenant", tenant, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/multiple/fragment/{tenant}/{nextLink}" - path_format_arguments = { - "tenant": self._serialize.url("tenant", tenant, "str"), - "nextLink": self._serialize.url("next_link", next_link, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OdataProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_fragment_next_link.metadata = {"url": "/paging/multiple/fragment/{tenant}"} # type: ignore - - @distributed_trace - def get_multiple_pages_fragment_with_grouping_next_link( - self, - custom_parameter_group, # type: "_models.CustomParameterGroup" - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OdataProductResult"] - """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. - - :param custom_parameter_group: Parameter group. - :type custom_parameter_group: ~paging.models.CustomParameterGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OdataProductResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.OdataProductResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _api_version = None - _tenant = None - if custom_parameter_group is not None: - _api_version = custom_parameter_group.api_version - _tenant = custom_parameter_group.tenant - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_fragment_with_grouping_next_link.metadata["url"] # type: ignore - path_format_arguments = { - "tenant": self._serialize.url("tenant", _tenant, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", _api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = "/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}" - path_format_arguments = { - "tenant": self._serialize.url("tenant", _tenant, "str"), - "nextLink": self._serialize.url("next_link", next_link, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api_version"] = self._serialize.query("api_version", _api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OdataProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.odata_next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_multiple_pages_fragment_with_grouping_next_link.metadata = {"url": "/paging/multiple/fragmentwithgrouping/{tenant}"} # type: ignore - - def _get_multiple_pages_lro_initial( - self, - client_request_id=None, # type: Optional[str] - paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProductResult" - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - # Construct URL - url = self._get_multiple_pages_lro_initial.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ProductResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _get_multiple_pages_lro_initial.metadata = {"url": "/paging/multiple/lro"} # type: ignore - - @distributed_trace - def begin_get_multiple_pages_lro( - self, - client_request_id=None, # type: Optional[str] - paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[ItemPaged["_models.ProductResult"]] - """A long-running paging operation that includes a nextLink that has 10 pages. - - :param client_request_id: - :type client_request_id: str - :param paging_get_multiple_pages_lro_options: Parameter group. - :type paging_get_multiple_pages_lro_options: ~paging.models.PagingGetMultiplePagesLroOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either ProductResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~paging.models.ProductResult]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _maxresults = None - _timeout = None - if paging_get_multiple_pages_lro_options is not None: - _maxresults = paging_get_multiple_pages_lro_options.maxresults - _timeout = paging_get_multiple_pages_lro_options.timeout - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters["client-request-id"] = self._serialize.header( - "client_request_id", client_request_id, "str" - ) - if _maxresults is not None: - header_parameters["maxresults"] = self._serialize.header("maxresults", _maxresults, "int") - if _timeout is not None: - header_parameters["timeout"] = self._serialize.header("timeout", _timeout, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_multiple_pages_lro.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.post(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResult", pipeline_response) - list_of_elem = deserialized.values - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._get_multiple_pages_lro_initial( - client_request_id=client_request_id, - paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, - cls=lambda x, y, z: x, - **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - def internal_get_next(next_link=None): - if next_link is None: - return pipeline_response - else: - return get_next(next_link) - - return ItemPaged(internal_get_next, extract_data) - - if polling is True: - polling_method = LROBasePolling(lro_delay, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_get_multiple_pages_lro.metadata = {"url": "/paging/multiple/lro"} # type: ignore - - @distributed_trace - def get_paging_model_with_item_name_with_xms_client_name( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductResultValueWithXMSClientName"] - """A paging operation that returns a paging model whose item name is is overriden by - x-ms-client-name 'indexes'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValueWithXMSClientName] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.get_paging_model_with_item_name_with_xms_client_name.metadata["url"] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProductResultValueWithXMSClientName", pipeline_response) - list_of_elem = deserialized.indexes - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get_paging_model_with_item_name_with_xms_client_name.metadata = {"url": "/paging/itemNameWithXMSClientName"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Paging/setup.py b/test/azure/Expected/AcceptanceTests/Paging/setup.py deleted file mode 100644 index 419a7bdb043..00000000000 --- a/test/azure/Expected/AcceptanceTests/Paging/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestpagingtestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestPagingTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestPagingTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Long-running Operation for AutoRest. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/setup.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/setup.py deleted file mode 100644 index cb512b84aff..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "storagemanagementclient" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="StorageManagementClient", - author_email="", - url="", - keywords=["Swagger", "StorageManagementClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - StorageManagementClient. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_storage_management_client.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_storage_management_client.py deleted file mode 100644 index f3cf8d5a40d..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_storage_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import StorageManagementClientConfiguration -from .operations import StorageAccountsOperations -from .operations import UsageOperations -from . import models - - -class StorageManagementClient(object): - """StorageManagementClient. - - :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: storage.operations.StorageAccountsOperations - :ivar usage: UsageOperations operations - :vartype usage: storage.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "https://management.azure.com" - self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> StorageManagementClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_storage_management_client.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_storage_management_client.py deleted file mode 100644 index 2794ac853a9..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_storage_management_client.py +++ /dev/null @@ -1,83 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import StorageManagementClientConfiguration -from .operations import StorageAccountsOperations -from .operations import UsageOperations -from .. import models - - -class StorageManagementClient(object): - """StorageManagementClient. - - :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: storage.aio.operations.StorageAccountsOperations - :ivar usage: UsageOperations operations - :vartype usage: storage.aio.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - if not base_url: - base_url = "https://management.azure.com" - self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "StorageManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py deleted file mode 100644 index 6d673573a9a..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py +++ /dev/null @@ -1,684 +0,0 @@ -# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class StorageAccountsOperations: - """StorageAccountsOperations 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: ~storage.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 check_name_availability( - self, account_name: "_models.StorageAccountCheckNameAvailabilityParameters", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": - """Checks that account name is valid and is not in use. - - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: ~storage.models.StorageAccountCheckNameAvailabilityParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~storage.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.CheckNameAvailabilityResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.check_name_availability.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - account_name: str, - parameters: "_models.StorageAccountCreateParameters", - **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.StorageAccount"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self._create_initial.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, "StorageAccountCreateParameters") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - account_name: str, - parameters: "_models.StorageAccountCreateParameters", - **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: - """Asynchronously creates a new storage account with the specified parameters. Existing accounts - cannot be updated with this API and should instead use the Update Storage Account API. If an - account is already created and subsequent PUT request is issued with exact same set of - properties, then HTTP 200 would be returned. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :param parameters: The parameters to provide for the created account. - :type parameters: ~storage.models.StorageAccountCreateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~storage.models.StorageAccount] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - account_name=account_name, - parameters=parameters, - cls=lambda x, y, z: x, - **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - - if polling is True: - polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: - polling_method = AsyncNoPolling() - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> None: - """Deletes a storage account in Microsoft Azure. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: 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", {})) - api_version = "2015-05-01-preview" - - # Construct URL - url = self.delete.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async - async def get_properties( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": - """Returns the properties for the specified storage account including but not limited to name, - account type, location, and account status. The ListKeys operation should be used to retrieve - storage keys. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) - :rtype: ~storage.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get_properties.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - account_name: str, - parameters: "_models.StorageAccountUpdateParameters", - **kwargs: Any - ) -> "_models.StorageAccount": - """Updates the account type or tags for a storage account. It can also be used to add a custom - domain (note that custom domains cannot be added via the Create operation). Only one custom - domain is supported per storage account. This API can only be used to update one of tags, - accountType, or customDomain per call. To update multiple of these properties, call the API - multiple times with one change per call. This call does not change the storage keys for the - account. If you want to change storage account keys, use the RegenerateKey operation. The - location and name of the storage account cannot be changed after creation. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :param parameters: The parameters to update on the account. Note that only one property can be - changed at a time using this API. - :type parameters: ~storage.models.StorageAccountUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) - :rtype: ~storage.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.update.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, "StorageAccountUpdateParameters") - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async - async def list_keys( - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountKeys": - """Lists the access keys for the specified storage account. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountKeys, or the result of cls(response) - :rtype: ~storage.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.list_keys.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccountKeys", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccountListResult"]: - """Lists all the storage accounts available under the subscription. Note that storage keys are not - returned; use the ListKeys operation for this. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.list.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url( - "self._config.subscription_id", self._config.subscription_id, "str" - ), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StorageAccountListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: - """Lists all the storage accounts available under the given resource group. Note that storage keys - are not returned; use the ListKeys operation for this. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": self._serialize.url( - "self._config.subscription_id", self._config.subscription_id, "str" - ), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StorageAccountListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore - - @distributed_trace_async - async def regenerate_key( - self, - resource_group_name: str, - account_name: str, - key_name: Optional[Union[str, "_models.KeyName"]] = None, - **kwargs: Any - ) -> "_models.StorageAccountKeys": - """Regenerates the access keys for the specified storage account. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :param key_name: - :type key_name: str or ~storage.models.KeyName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountKeys, or the result of cls(response) - :rtype: ~storage.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _regenerate_key = _models.StorageAccountRegenerateKeyParameters(key_name=key_name) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.regenerate_key.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_regenerate_key, "StorageAccountRegenerateKeyParameters") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccountKeys", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py deleted file mode 100644 index b67941728a1..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UsageOperations: - """UsageOperations 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: ~storage.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 list(self, **kwargs: Any) -> "_models.UsageListResult": - """Gets the current usage count and the limit for the resources under the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UsageListResult, or the result of cls(response) - :rtype: ~storage.models.UsageListResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.UsageListResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.list.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("UsageListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py deleted file mode 100644 index 92c4da797c3..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py +++ /dev/null @@ -1,714 +0,0 @@ -# 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 -import warnings - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class StorageAccountsOperations(object): - """StorageAccountsOperations 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: ~storage.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 check_name_availability( - self, - account_name, # type: "_models.StorageAccountCheckNameAvailabilityParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" - """Checks that account name is valid and is not in use. - - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: ~storage.models.StorageAccountCheckNameAvailabilityParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~storage.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.CheckNameAvailabilityResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.check_name_availability.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - - def _create_initial( - self, - resource_group_name, # type: str - account_name, # type: str - parameters, # type: "_models.StorageAccountCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.StorageAccount"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self._create_initial.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, "StorageAccountCreateParameters") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace - def begin_create( - self, - resource_group_name, # type: str - account_name, # type: str - parameters, # type: "_models.StorageAccountCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] - """Asynchronously creates a new storage account with the specified parameters. Existing accounts - cannot be updated with this API and should instead use the Update Storage Account API. If an - account is already created and subsequent PUT request is issued with exact same set of - properties, then HTTP 200 would be returned. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :param parameters: The parameters to provide for the created account. - :type parameters: ~storage.models.StorageAccountCreateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~storage.models.StorageAccount] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - account_name=account_name, - parameters=parameters, - cls=lambda x, y, z: x, - **kwargs - ) - - kwargs.pop("error_map", None) - kwargs.pop("content_type", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - - if polling is True: - polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: - polling_method = NoPolling() - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace - def delete( - self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes a storage account in Microsoft Azure. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: 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", {})) - api_version = "2015-05-01-preview" - - # Construct URL - url = self.delete.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace - def get_properties( - self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" - """Returns the properties for the specified storage account including but not limited to name, - account type, location, and account status. The ListKeys operation should be used to retrieve - storage keys. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) - :rtype: ~storage.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get_properties.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace - def update( - self, - resource_group_name, # type: str - account_name, # type: str - parameters, # type: "_models.StorageAccountUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" - """Updates the account type or tags for a storage account. It can also be used to add a custom - domain (note that custom domains cannot be added via the Create operation). Only one custom - domain is supported per storage account. This API can only be used to update one of tags, - accountType, or customDomain per call. To update multiple of these properties, call the API - multiple times with one change per call. This call does not change the storage keys for the - account. If you want to change storage account keys, use the RegenerateKey operation. The - location and name of the storage account cannot be changed after creation. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :param parameters: The parameters to update on the account. Note that only one property can be - changed at a time using this API. - :type parameters: ~storage.models.StorageAccountUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) - :rtype: ~storage.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.update.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, "StorageAccountUpdateParameters") - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccount", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace - def list_keys( - self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountKeys" - """Lists the access keys for the specified storage account. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountKeys, or the result of cls(response) - :rtype: ~storage.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.list_keys.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccountKeys", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace - def list( - self, **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountListResult"] - """Lists all the storage accounts available under the subscription. Note that storage keys are not - returned; use the ListKeys operation for this. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~storage.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.list.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url( - "self._config.subscription_id", self._config.subscription_id, "str" - ), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("StorageAccountListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountListResult"] - """Lists all the storage accounts available under the given resource group. Note that storage keys - are not returned; use the ListKeys operation for this. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~storage.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": self._serialize.url( - "self._config.subscription_id", self._config.subscription_id, "str" - ), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("StorageAccountListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore - - @distributed_trace - def regenerate_key( - self, - resource_group_name, # type: str - account_name, # type: str - key_name=None, # type: Optional[Union[str, "_models.KeyName"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountKeys" - """Regenerates the access keys for the specified storage account. - - :param resource_group_name: The name of the resource group within the user’s subscription. - :type resource_group_name: str - :param account_name: The name of the storage account within the specified resource group. - Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. - :type account_name: str - :param key_name: - :type key_name: str or ~storage.models.KeyName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountKeys, or the result of cls(response) - :rtype: ~storage.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _regenerate_key = _models.StorageAccountRegenerateKeyParameters(key_name=key_name) - api_version = "2015-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.regenerate_key.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "accountName": self._serialize.url("account_name", account_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_regenerate_key, "StorageAccountRegenerateKeyParameters") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StorageAccountKeys", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py deleted file mode 100644 index a30a5b9105a..00000000000 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py +++ /dev/null @@ -1,103 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class UsageOperations(object): - """UsageOperations 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: ~storage.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 list( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.UsageListResult" - """Gets the current usage count and the limit for the resources under the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UsageListResult, or the result of cls(response) - :rtype: ~storage.models.UsageListResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.UsageListResult"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2015-05-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.list.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("UsageListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py b/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py deleted file mode 100644 index 1d5db6b9372..00000000000 --- a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "microsoftazuretesturl" -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.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] - -setup( - name=NAME, - version=VERSION, - description="MicrosoftAzureTestUrl", - author_email="", - url="", - keywords=["Swagger", "MicrosoftAzureTestUrl"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Some cool documentation. - """, -) diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_microsoft_azure_test_url.py b/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_microsoft_azure_test_url.py deleted file mode 100644 index 4e8816d48c3..00000000000 --- a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_microsoft_azure_test_url.py +++ /dev/null @@ -1,87 +0,0 @@ -# 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.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MicrosoftAzureTestUrlConfiguration -from .operations import GroupOperations -from . import models - - -class MicrosoftAzureTestUrl(object): - """Some cool documentation. - - :ivar group: GroupOperations operations - :vartype group: subscriptionidapiversion.operations.GroupOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription Id. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = MicrosoftAzureTestUrlConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> MicrosoftAzureTestUrl - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_microsoft_azure_test_url.py b/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_microsoft_azure_test_url.py deleted file mode 100644 index f1c360e92a7..00000000000 --- a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_microsoft_azure_test_url.py +++ /dev/null @@ -1,76 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import MicrosoftAzureTestUrlConfiguration -from .operations import GroupOperations -from .. import models - - -class MicrosoftAzureTestUrl(object): - """Some cool documentation. - - :ivar group: GroupOperations operations - :vartype group: subscriptionidapiversion.aio.operations.GroupOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription Id. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = MicrosoftAzureTestUrlConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MicrosoftAzureTestUrl": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py b/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py deleted file mode 100644 index c47f2a3369d..00000000000 --- a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py +++ /dev/null @@ -1,100 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GroupOperations: - """GroupOperations 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: ~subscriptionidapiversion.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 get_sample_resource_group(self, resource_group_name: str, **kwargs: Any) -> "_models.SampleResourceGroup": - """Provides a resouce group with name 'testgroup101' and location 'West US'. - - :param resource_group_name: Resource Group name 'testgroup101'. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SampleResourceGroup, or the result of cls(response) - :rtype: ~subscriptionidapiversion.models.SampleResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SampleResourceGroup"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2014-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_sample_resource_group.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SampleResourceGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_sample_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py b/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py deleted file mode 100644 index 5de2366938a..00000000000 --- a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -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]] - - -class GroupOperations(object): - """GroupOperations 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: ~subscriptionidapiversion.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 get_sample_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SampleResourceGroup" - """Provides a resouce group with name 'testgroup101' and location 'West US'. - - :param resource_group_name: Resource Group name 'testgroup101'. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SampleResourceGroup, or the result of cls(response) - :rtype: ~subscriptionidapiversion.models.SampleResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SampleResourceGroup"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "2014-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_sample_resource_group.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SampleResourceGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_sample_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore diff --git a/test/azure/Python.Tests.Azure.pyproj b/test/azure/Python.Tests.Azure.pyproj deleted file mode 100644 index 81070217341..00000000000 --- a/test/azure/Python.Tests.Azure.pyproj +++ /dev/null @@ -1,341 +0,0 @@ - - - - Debug - 2.0 - 74be0601-ff65-4b46-8a8b-e670056061c4 - - - AcceptanceTests\__init__.py - - - . - . - Python.Tests.Azure - Azure.Python.Tests - - - - - - - true - false - - - true - false - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets - - - - - - - - - - \ No newline at end of file diff --git a/test/azure/app.config b/test/azure/app.config deleted file mode 100644 index 3e39b50f08a..00000000000 --- a/test/azure/app.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/azure/AcceptanceTests/asynctests/__init__.py b/test/azure/legacy/AcceptanceTests/asynctests/__init__.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/__init__.py rename to test/azure/legacy/AcceptanceTests/asynctests/__init__.py diff --git a/test/azure/AcceptanceTests/asynctests/test_azure_custom_base_uri.py b/test/azure/legacy/AcceptanceTests/asynctests/test_azure_custom_base_uri.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_azure_custom_base_uri.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_azure_custom_base_uri.py diff --git a/test/azure/AcceptanceTests/asynctests/test_azure_url.py b/test/azure/legacy/AcceptanceTests/asynctests/test_azure_url.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_azure_url.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_azure_url.py diff --git a/test/azure/AcceptanceTests/asynctests/test_config.py b/test/azure/legacy/AcceptanceTests/asynctests/test_config.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_config.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_config.py diff --git a/test/azure/AcceptanceTests/asynctests/test_custom_poller_pager.py b/test/azure/legacy/AcceptanceTests/asynctests/test_custom_poller_pager.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_custom_poller_pager.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_custom_poller_pager.py diff --git a/test/azure/AcceptanceTests/asynctests/test_duration.py b/test/azure/legacy/AcceptanceTests/asynctests/test_duration.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_duration.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_duration.py diff --git a/test/azure/AcceptanceTests/asynctests/test_head.py b/test/azure/legacy/AcceptanceTests/asynctests/test_head.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_head.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_head.py diff --git a/test/azure/AcceptanceTests/asynctests/test_lro.py b/test/azure/legacy/AcceptanceTests/asynctests/test_lro.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_lro.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_lro.py diff --git a/test/azure/AcceptanceTests/asynctests/test_lro_parameterized_endpoints.py b/test/azure/legacy/AcceptanceTests/asynctests/test_lro_parameterized_endpoints.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_lro_parameterized_endpoints.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_lro_parameterized_endpoints.py diff --git a/test/azure/AcceptanceTests/asynctests/test_paging.py b/test/azure/legacy/AcceptanceTests/asynctests/test_paging.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_paging.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_paging.py diff --git a/test/azure/AcceptanceTests/asynctests/test_parameter.py b/test/azure/legacy/AcceptanceTests/asynctests/test_parameter.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_parameter.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_parameter.py diff --git a/test/azure/AcceptanceTests/asynctests/test_tracing.py b/test/azure/legacy/AcceptanceTests/asynctests/test_tracing.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_tracing.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_tracing.py diff --git a/test/azure/AcceptanceTests/asynctests/test_xms.py b/test/azure/legacy/AcceptanceTests/asynctests/test_xms.py similarity index 100% rename from test/azure/AcceptanceTests/asynctests/test_xms.py rename to test/azure/legacy/AcceptanceTests/asynctests/test_xms.py diff --git a/test/azure/legacy/AcceptanceTests/conftest.py b/test/azure/legacy/AcceptanceTests/conftest.py new file mode 100644 index 00000000000..49e217dae92 --- /dev/null +++ b/test/azure/legacy/AcceptanceTests/conftest.py @@ -0,0 +1,107 @@ +# -------------------------------------------------------------------------- +# +# 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 glob +import sys +import subprocess +import os +import signal +from os.path import dirname, realpath +from unittest import TestLoader, TextTestRunner + +from os.path import dirname, pardir, join, realpath + +from azure.core.pipeline.policies import SansIOHTTPPolicy + +import pytest + + +cwd = dirname(realpath(__file__)) + +#Ideally this would be in a common helper library shared between the tests +def start_server_process(): + cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) + if os.name == 'nt': #On windows, subprocess creation works without being in the shell + return subprocess.Popen(cmd) + + return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True + +#Ideally this would be in a common helper library shared between the tests +def terminate_server_process(process): + if os.name == 'nt': + process.kill() + else: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups + +@pytest.fixture(scope="session") +def testserver(): + """Start the Autorest testserver.""" + server = start_server_process() + yield + terminate_server_process(server) + +# Ignore collection of async tests for Python 2 +collect_ignore = [] +if sys.version_info < (3,5): + collect_ignore.append("asynctests") + + +class CookiePolicy(SansIOHTTPPolicy): + def __init__(self, *args, **kwargs): + self._current_cookie = None + + def on_request(self, request, **kwargs): + # type: (PipelineRequest, Any) -> None + http_request = request.http_request + if self._current_cookie: + http_request.headers["Cookie"] = self._current_cookie + self._current_cookie = None + + def on_response(self, request, response, **kwargs): + # type: (PipelineRequest, PipelineResponse, Any) -> None + http_response = response.http_response + + if "Set-Cookie" in http_response.headers: + self._current_cookie = http_response.headers["Set-Cookie"] + +@pytest.fixture() +def cookie_policy(): + return CookiePolicy() + + +@pytest.fixture() +def credential(): + """I actually don't need anything, since the authentication policy + will bypass it. + """ + class FakeCredential: + pass + return FakeCredential() + +@pytest.fixture() +def authentication_policy(): + from azure.core.pipeline.policies import SansIOHTTPPolicy + return SansIOHTTPPolicy() \ No newline at end of file diff --git a/test/azure/AcceptanceTests/test_azure_custom_base_uri.py b/test/azure/legacy/AcceptanceTests/test_azure_custom_base_uri.py similarity index 100% rename from test/azure/AcceptanceTests/test_azure_custom_base_uri.py rename to test/azure/legacy/AcceptanceTests/test_azure_custom_base_uri.py diff --git a/test/azure/AcceptanceTests/test_azure_url.py b/test/azure/legacy/AcceptanceTests/test_azure_url.py similarity index 100% rename from test/azure/AcceptanceTests/test_azure_url.py rename to test/azure/legacy/AcceptanceTests/test_azure_url.py diff --git a/test/azure/AcceptanceTests/test_config.py b/test/azure/legacy/AcceptanceTests/test_config.py similarity index 100% rename from test/azure/AcceptanceTests/test_config.py rename to test/azure/legacy/AcceptanceTests/test_config.py diff --git a/test/azure/AcceptanceTests/test_custom_poller_pager.py b/test/azure/legacy/AcceptanceTests/test_custom_poller_pager.py similarity index 100% rename from test/azure/AcceptanceTests/test_custom_poller_pager.py rename to test/azure/legacy/AcceptanceTests/test_custom_poller_pager.py diff --git a/test/azure/AcceptanceTests/test_duration.py b/test/azure/legacy/AcceptanceTests/test_duration.py similarity index 100% rename from test/azure/AcceptanceTests/test_duration.py rename to test/azure/legacy/AcceptanceTests/test_duration.py diff --git a/test/azure/AcceptanceTests/test_head.py b/test/azure/legacy/AcceptanceTests/test_head.py similarity index 100% rename from test/azure/AcceptanceTests/test_head.py rename to test/azure/legacy/AcceptanceTests/test_head.py diff --git a/test/azure/AcceptanceTests/test_lro.py b/test/azure/legacy/AcceptanceTests/test_lro.py similarity index 100% rename from test/azure/AcceptanceTests/test_lro.py rename to test/azure/legacy/AcceptanceTests/test_lro.py diff --git a/test/azure/AcceptanceTests/test_lro_parameterized_endpoints.py b/test/azure/legacy/AcceptanceTests/test_lro_parameterized_endpoints.py similarity index 100% rename from test/azure/AcceptanceTests/test_lro_parameterized_endpoints.py rename to test/azure/legacy/AcceptanceTests/test_lro_parameterized_endpoints.py diff --git a/test/azure/AcceptanceTests/test_paging.py b/test/azure/legacy/AcceptanceTests/test_paging.py similarity index 100% rename from test/azure/AcceptanceTests/test_paging.py rename to test/azure/legacy/AcceptanceTests/test_paging.py diff --git a/test/azure/AcceptanceTests/test_parameter.py b/test/azure/legacy/AcceptanceTests/test_parameter.py similarity index 100% rename from test/azure/AcceptanceTests/test_parameter.py rename to test/azure/legacy/AcceptanceTests/test_parameter.py diff --git a/test/azure/AcceptanceTests/test_tracing.py b/test/azure/legacy/AcceptanceTests/test_tracing.py similarity index 96% rename from test/azure/AcceptanceTests/test_tracing.py rename to test/azure/legacy/AcceptanceTests/test_tracing.py index cf6e24c759b..397e9176db7 100644 --- a/test/azure/AcceptanceTests/test_tracing.py +++ b/test/azure/legacy/AcceptanceTests/test_tracing.py @@ -48,8 +48,6 @@ def test_lro(): with AutoRestLongRunningOperationTestService("cred", base_url="dummy url") as client: assert not has_tracing_decorator(client.lros._put201_creating_succeeded200_initial) assert has_tracing_decorator(client.lros.begin_put201_creating_succeeded200) - assert not has_tracing_decorator(client.lros._put201_creating_succeeded200_initial) - def test_azure_url(): client = MicrosoftAzureTestUrl("cred", "sub_id", base_url="dummy url") diff --git a/test/azure/AcceptanceTests/test_xms.py b/test/azure/legacy/AcceptanceTests/test_xms.py similarity index 100% rename from test/azure/AcceptanceTests/test_xms.py rename to test/azure/legacy/AcceptanceTests/test_xms.py diff --git a/test/azure/AcceptanceTests/test_zzz.py b/test/azure/legacy/AcceptanceTests/test_zzz.py similarity index 100% rename from test/azure/AcceptanceTests/test_zzz.py rename to test/azure/legacy/AcceptanceTests/test_zzz.py diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_auto_rest_duration_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..be77dd94ec9 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_auto_rest_duration_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestDurationTestServiceConfiguration +from .operations import DurationOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDurationTestService(object): + """Test Infrastructure for AutoRest. + + :ivar duration: DurationOperations operations + :vartype duration: bodyduration.operations.DurationOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**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.duration = DurationOperations(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. + + We have helper methods to create requests specific to this service in `bodyduration.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyduration._rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDurationTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_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/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/__init__.py new file mode 100644 index 00000000000..2551fd5500f --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/__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 ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_put_positive_duration_request + from ._request_builders_py3 import build_get_positive_duration_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_put_positive_duration_request # type: ignore + from ._request_builders import build_get_positive_duration_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_put_positive_duration_request", + "build_get_positive_duration_request", + "build_get_invalid_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/_request_builders.py new file mode 100644 index 00000000000..704a82ac6ff --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/_request_builders.py @@ -0,0 +1,153 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/_request_builders_py3.py new file mode 100644 index 00000000000..07c69434b2b --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_rest/duration/_request_builders_py3.py @@ -0,0 +1,116 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_positive_duration_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_positive_duration_request(**kwargs: Any) -> HttpRequest: + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_version.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_version.py diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..e14ce7a1895 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestDurationTestServiceConfiguration +from .operations import DurationOperations + + +class AutoRestDurationTestService: + """Test Infrastructure for AutoRest. + + :ivar duration: DurationOperations operations + :vartype duration: bodyduration.aio.operations.DurationOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**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.duration = DurationOperations(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. + + We have helper methods to create requests specific to this service in `bodyduration.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyduration._rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDurationTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py new file mode 100644 index 00000000000..c08b5059205 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py @@ -0,0 +1,203 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import duration as rest_duration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DurationOperations: + """DurationOperations 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: ~bodyduration.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 get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: + """Get null duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/duration/null"} # type: ignore + + @distributed_trace_async + async def put_positive_duration(self, duration_body: datetime.timedelta, **kwargs: Any) -> None: + """Put a positive duration value. + + :param duration_body: duration body. + :type duration_body: ~datetime.timedelta + :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/json") # type: Optional[str] + + json = self._serialize.body(duration_body, "duration") + + request = rest_duration.build_put_positive_duration_request( + content_type=content_type, + json=json, + template_url=self.put_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace_async + async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: + """Get a positive duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_positive_duration_request( + template_url=self.get_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: + """Get an invalid duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py new file mode 100644 index 00000000000..c19b4f56fe1 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py @@ -0,0 +1,213 @@ +# 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 datetime +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 .. import models as _models +from .._rest import duration as rest_duration + +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]] + + +class DurationOperations(object): + """DurationOperations 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: ~bodyduration.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[datetime.timedelta] + """Get null duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/duration/null"} # type: ignore + + @distributed_trace + def put_positive_duration( + self, + duration_body, # type: datetime.timedelta + **kwargs # type: Any + ): + # type: (...) -> None + """Put a positive duration value. + + :param duration_body: duration body. + :type duration_body: ~datetime.timedelta + :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/json") # type: Optional[str] + + json = self._serialize.body(duration_body, "duration") + + request = rest_duration.build_put_positive_duration_request( + content_type=content_type, + json=json, + template_url=self.put_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace + def get_positive_duration( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.timedelta + """Get a positive duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_positive_duration_request( + template_url=self.get_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.timedelta + """Get an invalid duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/py.typed b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/setup.py b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/setup.py new file mode 100644 index 00000000000..5d6c5294492 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/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 = "autorestdurationtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDurationTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDurationTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_auto_rest_parameter_grouping_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_auto_rest_parameter_grouping_test_service.py new file mode 100644 index 00000000000..a4347ba6c45 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_auto_rest_parameter_grouping_test_service.py @@ -0,0 +1,97 @@ +# 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 AutoRestParameterGroupingTestServiceConfiguration +from .operations import ParameterGroupingOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterGroupingTestService(object): + """Test Infrastructure for AutoRest. + + :ivar parameter_grouping: ParameterGroupingOperations operations + :vartype parameter_grouping: azureparametergrouping.operations.ParameterGroupingOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterGroupingTestServiceConfiguration(**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.parameter_grouping = ParameterGroupingOperations( + 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. + + We have helper methods to create requests specific to this service in `azureparametergrouping.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azureparametergrouping._rest import parameter_grouping + >>> request = parameter_grouping.build_post_required_request(path, json=json, content=content, custom_header=custom_header, query=query, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestParameterGroupingTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_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/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/__init__.py new file mode 100644 index 00000000000..7054a526d92 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/__init__.py @@ -0,0 +1,28 @@ +# 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_post_required_request + from ._request_builders_py3 import build_post_optional_request + from ._request_builders_py3 import build_post_reserved_words_request + from ._request_builders_py3 import build_post_multi_param_groups_request + from ._request_builders_py3 import build_post_shared_parameter_group_object_request +except (SyntaxError, ImportError): + from ._request_builders import build_post_required_request # type: ignore + from ._request_builders import build_post_optional_request # type: ignore + from ._request_builders import build_post_reserved_words_request # type: ignore + from ._request_builders import build_post_multi_param_groups_request # type: ignore + from ._request_builders import build_post_shared_parameter_group_object_request # type: ignore + +__all__ = [ + "build_post_required_request", + "build_post_optional_request", + "build_post_reserved_words_request", + "build_post_multi_param_groups_request", + "build_post_shared_parameter_group_object_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/_request_builders.py new file mode 100644 index 00000000000..f72ce8ad5c9 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/_request_builders.py @@ -0,0 +1,275 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_post_required_request( + path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post a bunch of required parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path: Path parameter. + :type path: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :paramtype content: any + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + custom_header = kwargs.pop('custom_header', None) # type: Optional[str] + query = kwargs.pop('query', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postRequired/{path}') + path_format_arguments = { + 'path': _SERIALIZER.url("path", path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters['query'] = _SERIALIZER.query("query", query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters['customHeader'] = _SERIALIZER.header("custom_header", custom_header, 'str') + if content_type is not None: + 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, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post a bunch of optional parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + """ + + custom_header = kwargs.pop('custom_header', None) # type: Optional[str] + query = kwargs.pop('query', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postOptional') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters['query'] = _SERIALIZER.query("query", query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters['customHeader'] = _SERIALIZER.header("custom_header", custom_header, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_reserved_words_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post a grouped parameters with reserved words. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword from_parameter: 'from' is a reserved word. Pass in 'bob' to pass. + :paramtype from_parameter: str + :keyword accept_parameter: 'accept' is a reserved word. Pass in 'yes' to pass. + :paramtype accept_parameter: str + :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 + """ + + from_parameter = kwargs.pop('from_parameter', None) # type: Optional[str] + accept_parameter = kwargs.pop('accept_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postReservedWords') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if from_parameter is not None: + query_parameters['from'] = _SERIALIZER.query("from_parameter", from_parameter, 'str') + if accept_parameter is not None: + query_parameters['accept'] = _SERIALIZER.query("accept_parameter", accept_parameter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_multi_param_groups_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post parameters from multiple different parameter groups. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :keyword header_two: + :paramtype header_two: str + :keyword query_two: Query parameter with default. + :paramtype query_two: int + :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 + """ + + header_one = kwargs.pop('header_one', None) # type: Optional[str] + query_one = kwargs.pop('query_one', 30) # type: Optional[int] + header_two = kwargs.pop('header_two', None) # type: Optional[str] + query_two = kwargs.pop('query_two', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postMultipleParameterGroups') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters['query-one'] = _SERIALIZER.query("query_one", query_one, 'int') + if query_two is not None: + query_parameters['query-two'] = _SERIALIZER.query("query_two", query_two, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters['header-one'] = _SERIALIZER.header("header_one", header_one, 'str') + if header_two is not None: + header_parameters['header-two'] = _SERIALIZER.header("header_two", header_two, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_shared_parameter_group_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post parameters with a shared parameter group object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :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 + """ + + header_one = kwargs.pop('header_one', None) # type: Optional[str] + query_one = kwargs.pop('query_one', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/sharedParameterGroupObject') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters['query-one'] = _SERIALIZER.query("query_one", query_one, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters['header-one'] = _SERIALIZER.header("header_one", header_one, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/_request_builders_py3.py new file mode 100644 index 00000000000..c8926543874 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_rest/parameter_grouping/_request_builders_py3.py @@ -0,0 +1,231 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_post_required_request( + path: str, + *, + json: Any = None, + content: Any = None, + custom_header: Optional[str] = None, + query: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """Post a bunch of required parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path: Path parameter. + :type path: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :paramtype content: any + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postRequired/{path}") + path_format_arguments = { + "path": _SERIALIZER.url("path", path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters["query"] = _SERIALIZER.query("query", query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters["customHeader"] = _SERIALIZER.header("custom_header", custom_header, "str") + if content_type is not None: + 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, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_post_optional_request( + *, custom_header: Optional[str] = None, query: Optional[int] = 30, **kwargs: Any +) -> HttpRequest: + """Post a bunch of optional parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postOptional") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters["query"] = _SERIALIZER.query("query", query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters["customHeader"] = _SERIALIZER.header("custom_header", custom_header, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_reserved_words_request( + *, from_parameter: Optional[str] = None, accept_parameter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + """Post a grouped parameters with reserved words. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword from_parameter: 'from' is a reserved word. Pass in 'bob' to pass. + :paramtype from_parameter: str + :keyword accept_parameter: 'accept' is a reserved word. Pass in 'yes' to pass. + :paramtype accept_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postReservedWords") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if from_parameter is not None: + query_parameters["from"] = _SERIALIZER.query("from_parameter", from_parameter, "str") + if accept_parameter is not None: + query_parameters["accept"] = _SERIALIZER.query("accept_parameter", accept_parameter, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_multi_param_groups_request( + *, + header_one: Optional[str] = None, + query_one: Optional[int] = 30, + header_two: Optional[str] = None, + query_two: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """Post parameters from multiple different parameter groups. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :keyword header_two: + :paramtype header_two: str + :keyword query_two: Query parameter with default. + :paramtype query_two: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postMultipleParameterGroups") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters["query-one"] = _SERIALIZER.query("query_one", query_one, "int") + if query_two is not None: + query_parameters["query-two"] = _SERIALIZER.query("query_two", query_two, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters["header-one"] = _SERIALIZER.header("header_one", header_one, "str") + if header_two is not None: + header_parameters["header-two"] = _SERIALIZER.header("header_two", header_two, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_shared_parameter_group_object_request( + *, header_one: Optional[str] = None, query_one: Optional[int] = 30, **kwargs: Any +) -> HttpRequest: + """Post parameters with a shared parameter group object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/sharedParameterGroupObject") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters["query-one"] = _SERIALIZER.query("query_one", query_one, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters["header-one"] = _SERIALIZER.header("header_one", header_one, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_version.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/_version.py diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_auto_rest_parameter_grouping_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_auto_rest_parameter_grouping_test_service.py new file mode 100644 index 00000000000..087b7516fda --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_auto_rest_parameter_grouping_test_service.py @@ -0,0 +1,79 @@ +# 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 AutoRestParameterGroupingTestServiceConfiguration +from .operations import ParameterGroupingOperations + + +class AutoRestParameterGroupingTestService: + """Test Infrastructure for AutoRest. + + :ivar parameter_grouping: ParameterGroupingOperations operations + :vartype parameter_grouping: azureparametergrouping.aio.operations.ParameterGroupingOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterGroupingTestServiceConfiguration(**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.parameter_grouping = ParameterGroupingOperations( + 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. + + We have helper methods to create requests specific to this service in `azureparametergrouping.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azureparametergrouping._rest import parameter_grouping + >>> request = parameter_grouping.build_post_required_request(path, json=json, content=content, custom_header=custom_header, query=query, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestParameterGroupingTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py new file mode 100644 index 00000000000..cb651c91231 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py @@ -0,0 +1,307 @@ +# 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 ... import models as _models +from ..._rest import parameter_grouping as rest_parameter_grouping + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ParameterGroupingOperations: + """ParameterGroupingOperations 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: ~azureparametergrouping.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 post_required( + self, + parameter_grouping_post_required_parameters: "_models.ParameterGroupingPostRequiredParameters", + **kwargs: Any + ) -> None: + """Post a bunch of required parameters grouped. + + :param parameter_grouping_post_required_parameters: Parameter group. + :type parameter_grouping_post_required_parameters: + ~azureparametergrouping.models.ParameterGroupingPostRequiredParameters + :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/json") # type: Optional[str] + + _custom_header = None + _query = None + _path = None + _body = None + if parameter_grouping_post_required_parameters is not None: + _custom_header = parameter_grouping_post_required_parameters.custom_header + _query = parameter_grouping_post_required_parameters.query + _path = parameter_grouping_post_required_parameters.path + _body = parameter_grouping_post_required_parameters.body + json = self._serialize.body(_body, "int") + + request = rest_parameter_grouping.build_post_required_request( + path=_path, + content_type=content_type, + custom_header=_custom_header, + query=_query, + json=json, + template_url=self.post_required.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required.metadata = {"url": "/parameterGrouping/postRequired/{path}"} # type: ignore + + @distributed_trace_async + async def post_optional( + self, + parameter_grouping_post_optional_parameters: Optional["_models.ParameterGroupingPostOptionalParameters"] = None, + **kwargs: Any + ) -> None: + """Post a bunch of optional parameters grouped. + + :param parameter_grouping_post_optional_parameters: Parameter group. + :type parameter_grouping_post_optional_parameters: + ~azureparametergrouping.models.ParameterGroupingPostOptionalParameters + :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", {})) + _custom_header = None + _query = None + if parameter_grouping_post_optional_parameters is not None: + _custom_header = parameter_grouping_post_optional_parameters.custom_header + _query = parameter_grouping_post_optional_parameters.query + + request = rest_parameter_grouping.build_post_optional_request( + custom_header=_custom_header, + query=_query, + template_url=self.post_optional.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional.metadata = {"url": "/parameterGrouping/postOptional"} # type: ignore + + @distributed_trace_async + async def post_reserved_words( + self, + parameter_grouping_post_reserved_words_parameters: Optional[ + "_models.ParameterGroupingPostReservedWordsParameters" + ] = None, + **kwargs: Any + ) -> None: + """Post a grouped parameters with reserved words. + + :param parameter_grouping_post_reserved_words_parameters: Parameter group. + :type parameter_grouping_post_reserved_words_parameters: + ~azureparametergrouping.models.ParameterGroupingPostReservedWordsParameters + :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", {})) + _from_parameter = None + _accept_parameter = None + if parameter_grouping_post_reserved_words_parameters is not None: + _from_parameter = parameter_grouping_post_reserved_words_parameters.from_property + _accept_parameter = parameter_grouping_post_reserved_words_parameters.accept + + request = rest_parameter_grouping.build_post_reserved_words_request( + from_parameter=_from_parameter, + accept_parameter=_accept_parameter, + template_url=self.post_reserved_words.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_reserved_words.metadata = {"url": "/parameterGrouping/postReservedWords"} # type: ignore + + @distributed_trace_async + async def post_multi_param_groups( + self, + first_parameter_group: Optional["_models.FirstParameterGroup"] = None, + parameter_grouping_post_multi_param_groups_second_param_group: Optional[ + "_models.ParameterGroupingPostMultiParamGroupsSecondParamGroup" + ] = None, + **kwargs: Any + ) -> None: + """Post parameters from multiple different parameter groups. + + :param first_parameter_group: Parameter group. + :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup + :param parameter_grouping_post_multi_param_groups_second_param_group: Parameter group. + :type parameter_grouping_post_multi_param_groups_second_param_group: + ~azureparametergrouping.models.ParameterGroupingPostMultiParamGroupsSecondParamGroup + :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", {})) + _header_one = None + _query_one = None + _header_two = None + _query_two = None + if first_parameter_group is not None: + _header_one = first_parameter_group.header_one + _query_one = first_parameter_group.query_one + if parameter_grouping_post_multi_param_groups_second_param_group is not None: + _header_two = parameter_grouping_post_multi_param_groups_second_param_group.header_two + _query_two = parameter_grouping_post_multi_param_groups_second_param_group.query_two + + request = rest_parameter_grouping.build_post_multi_param_groups_request( + header_one=_header_one, + query_one=_query_one, + header_two=_header_two, + query_two=_query_two, + template_url=self.post_multi_param_groups.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_multi_param_groups.metadata = {"url": "/parameterGrouping/postMultipleParameterGroups"} # type: ignore + + @distributed_trace_async + async def post_shared_parameter_group_object( + self, first_parameter_group: Optional["_models.FirstParameterGroup"] = None, **kwargs: Any + ) -> None: + """Post parameters with a shared parameter group object. + + :param first_parameter_group: Parameter group. + :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup + :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", {})) + _header_one = None + _query_one = None + if first_parameter_group is not None: + _header_one = first_parameter_group.header_one + _query_one = first_parameter_group.query_one + + request = rest_parameter_grouping.build_post_shared_parameter_group_object_request( + header_one=_header_one, + query_one=_query_one, + template_url=self.post_shared_parameter_group_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_shared_parameter_group_object.metadata = {"url": "/parameterGrouping/sharedParameterGroupObject"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py new file mode 100644 index 00000000000..bf642049e0b --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py @@ -0,0 +1,304 @@ +# 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 .. import models as _models +from .._rest import parameter_grouping as rest_parameter_grouping + +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]] + + +class ParameterGroupingOperations(object): + """ParameterGroupingOperations 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: ~azureparametergrouping.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 post_required( + self, + parameter_grouping_post_required_parameters, # type: "_models.ParameterGroupingPostRequiredParameters" + **kwargs # type: Any + ): + # type: (...) -> None + """Post a bunch of required parameters grouped. + + :param parameter_grouping_post_required_parameters: Parameter group. + :type parameter_grouping_post_required_parameters: + ~azureparametergrouping.models.ParameterGroupingPostRequiredParameters + :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/json") # type: Optional[str] + + _custom_header = None + _query = None + _path = None + _body = None + if parameter_grouping_post_required_parameters is not None: + _custom_header = parameter_grouping_post_required_parameters.custom_header + _query = parameter_grouping_post_required_parameters.query + _path = parameter_grouping_post_required_parameters.path + _body = parameter_grouping_post_required_parameters.body + json = self._serialize.body(_body, "int") + + request = rest_parameter_grouping.build_post_required_request( + path=_path, + content_type=content_type, + custom_header=_custom_header, + query=_query, + json=json, + template_url=self.post_required.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required.metadata = {"url": "/parameterGrouping/postRequired/{path}"} # type: ignore + + @distributed_trace + def post_optional( + self, + parameter_grouping_post_optional_parameters=None, # type: Optional["_models.ParameterGroupingPostOptionalParameters"] + **kwargs # type: Any + ): + # type: (...) -> None + """Post a bunch of optional parameters grouped. + + :param parameter_grouping_post_optional_parameters: Parameter group. + :type parameter_grouping_post_optional_parameters: + ~azureparametergrouping.models.ParameterGroupingPostOptionalParameters + :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", {})) + _custom_header = None + _query = None + if parameter_grouping_post_optional_parameters is not None: + _custom_header = parameter_grouping_post_optional_parameters.custom_header + _query = parameter_grouping_post_optional_parameters.query + + request = rest_parameter_grouping.build_post_optional_request( + custom_header=_custom_header, + query=_query, + template_url=self.post_optional.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional.metadata = {"url": "/parameterGrouping/postOptional"} # type: ignore + + @distributed_trace + def post_reserved_words( + self, + parameter_grouping_post_reserved_words_parameters=None, # type: Optional["_models.ParameterGroupingPostReservedWordsParameters"] + **kwargs # type: Any + ): + # type: (...) -> None + """Post a grouped parameters with reserved words. + + :param parameter_grouping_post_reserved_words_parameters: Parameter group. + :type parameter_grouping_post_reserved_words_parameters: + ~azureparametergrouping.models.ParameterGroupingPostReservedWordsParameters + :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", {})) + _from_parameter = None + _accept_parameter = None + if parameter_grouping_post_reserved_words_parameters is not None: + _from_parameter = parameter_grouping_post_reserved_words_parameters.from_property + _accept_parameter = parameter_grouping_post_reserved_words_parameters.accept + + request = rest_parameter_grouping.build_post_reserved_words_request( + from_parameter=_from_parameter, + accept_parameter=_accept_parameter, + template_url=self.post_reserved_words.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_reserved_words.metadata = {"url": "/parameterGrouping/postReservedWords"} # type: ignore + + @distributed_trace + def post_multi_param_groups( + self, + first_parameter_group=None, # type: Optional["_models.FirstParameterGroup"] + parameter_grouping_post_multi_param_groups_second_param_group=None, # type: Optional["_models.ParameterGroupingPostMultiParamGroupsSecondParamGroup"] + **kwargs # type: Any + ): + # type: (...) -> None + """Post parameters from multiple different parameter groups. + + :param first_parameter_group: Parameter group. + :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup + :param parameter_grouping_post_multi_param_groups_second_param_group: Parameter group. + :type parameter_grouping_post_multi_param_groups_second_param_group: + ~azureparametergrouping.models.ParameterGroupingPostMultiParamGroupsSecondParamGroup + :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", {})) + _header_one = None + _query_one = None + _header_two = None + _query_two = None + if first_parameter_group is not None: + _header_one = first_parameter_group.header_one + _query_one = first_parameter_group.query_one + if parameter_grouping_post_multi_param_groups_second_param_group is not None: + _header_two = parameter_grouping_post_multi_param_groups_second_param_group.header_two + _query_two = parameter_grouping_post_multi_param_groups_second_param_group.query_two + + request = rest_parameter_grouping.build_post_multi_param_groups_request( + header_one=_header_one, + query_one=_query_one, + header_two=_header_two, + query_two=_query_two, + template_url=self.post_multi_param_groups.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_multi_param_groups.metadata = {"url": "/parameterGrouping/postMultipleParameterGroups"} # type: ignore + + @distributed_trace + def post_shared_parameter_group_object( + self, + first_parameter_group=None, # type: Optional["_models.FirstParameterGroup"] + **kwargs # type: Any + ): + # type: (...) -> None + """Post parameters with a shared parameter group object. + + :param first_parameter_group: Parameter group. + :type first_parameter_group: ~azureparametergrouping.models.FirstParameterGroup + :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", {})) + _header_one = None + _query_one = None + if first_parameter_group is not None: + _header_one = first_parameter_group.header_one + _query_one = first_parameter_group.query_one + + request = rest_parameter_grouping.build_post_shared_parameter_group_object_request( + header_one=_header_one, + query_one=_query_one, + template_url=self.post_shared_parameter_group_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_shared_parameter_group_object.metadata = {"url": "/parameterGrouping/sharedParameterGroupObject"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/py.typed b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/setup.py b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/setup.py new file mode 100644 index 00000000000..43fc9e7bdd6 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/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 = "autorestparametergroupingtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterGroupingTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterGroupingTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_auto_rest_report_service_for_azure.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_auto_rest_report_service_for_azure.py new file mode 100644 index 00000000000..241ce102033 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_auto_rest_report_service_for_azure.py @@ -0,0 +1,93 @@ +# 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 AutoRestReportServiceForAzureConfiguration +from .operations import AutoRestReportServiceForAzureOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestReportServiceForAzure(AutoRestReportServiceForAzureOperationsMixin): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceForAzureConfiguration(**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 + + 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 `azurereport.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurereport._rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestReportServiceForAzure + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/__init__.py new file mode 100644 index 00000000000..47e8a3b88d4 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/__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_get_report_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_report_request # type: ignore + +__all__ = [ + "build_get_report_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/_request_builders.py new file mode 100644 index 00000000000..aecbb98032e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_report_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + """ + + qualifier = kwargs.pop('qualifier', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/report/azure') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters['qualifier'] = _SERIALIZER.query("qualifier", qualifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..0eb362bd39c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_rest/_request_builders_py3.py @@ -0,0 +1,45 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_report_request(*, qualifier: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/report/azure") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters["qualifier"] = _SERIALIZER.query("qualifier", qualifier, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_version.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_version.py diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_auto_rest_report_service_for_azure.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_auto_rest_report_service_for_azure.py new file mode 100644 index 00000000000..19cd084dd44 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_auto_rest_report_service_for_azure.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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestReportServiceForAzureConfiguration +from .operations import AutoRestReportServiceForAzureOperationsMixin + + +class AutoRestReportServiceForAzure(AutoRestReportServiceForAzureOperationsMixin): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceForAzureConfiguration(**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 + + 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 `azurereport.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurereport._rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestReportServiceForAzure": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py new file mode 100644 index 00000000000..04b5a804ae9 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.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. +# -------------------------------------------------------------------------- +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 ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutoRestReportServiceForAzureOperationsMixin: + @distributed_trace_async + async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str, int]: + """Get test coverage report. + + :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in + for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :type qualifier: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_report_request( + qualifier=qualifier, + template_url=self.get_report.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_report.metadata = {"url": "/report/azure"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py new file mode 100644 index 00000000000..21bbe857160 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py @@ -0,0 +1,78 @@ +# 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 .. import _rest as rest, models as _models + +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]] + + +class AutoRestReportServiceForAzureOperationsMixin(object): + @distributed_trace + def get_report( + self, + qualifier=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get test coverage report. + + :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in + for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :type qualifier: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_report_request( + qualifier=qualifier, + template_url=self.get_report.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_report.metadata = {"url": "/report/azure"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureReport/azurereport/py.typed b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureReport/azurereport/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureReport/setup.py b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/setup.py new file mode 100644 index 00000000000..e36aa3e6023 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureReport/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 = "autorestreportserviceforazure" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestReportServiceForAzure", + author_email="", + url="", + keywords=["Swagger", "AutoRestReportServiceForAzure"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_auto_rest_azure_special_parameters_test_client.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_auto_rest_azure_special_parameters_test_client.py new file mode 100644 index 00000000000..8e191d136d6 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_auto_rest_azure_special_parameters_test_client.py @@ -0,0 +1,147 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration +from .operations import ( + ApiVersionDefaultOperations, + ApiVersionLocalOperations, + HeaderOperations, + OdataOperations, + SkipUrlEncodingOperations, + SubscriptionInCredentialsOperations, + SubscriptionInMethodOperations, + XMsClientRequestIdOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestAzureSpecialParametersTestClient(object): + """Test Infrastructure for AutoRest. + + :ivar xms_client_request_id: XMsClientRequestIdOperations operations + :vartype xms_client_request_id: azurespecialproperties.operations.XMsClientRequestIdOperations + :ivar subscription_in_credentials: SubscriptionInCredentialsOperations operations + :vartype subscription_in_credentials: + azurespecialproperties.operations.SubscriptionInCredentialsOperations + :ivar subscription_in_method: SubscriptionInMethodOperations operations + :vartype subscription_in_method: + azurespecialproperties.operations.SubscriptionInMethodOperations + :ivar api_version_default: ApiVersionDefaultOperations operations + :vartype api_version_default: azurespecialproperties.operations.ApiVersionDefaultOperations + :ivar api_version_local: ApiVersionLocalOperations operations + :vartype api_version_local: azurespecialproperties.operations.ApiVersionLocalOperations + :ivar skip_url_encoding: SkipUrlEncodingOperations operations + :vartype skip_url_encoding: azurespecialproperties.operations.SkipUrlEncodingOperations + :ivar odata: OdataOperations operations + :vartype odata: azurespecialproperties.operations.OdataOperations + :ivar header: HeaderOperations operations + :vartype header: azurespecialproperties.operations.HeaderOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestAzureSpecialParametersTestClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(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.xms_client_request_id = XMsClientRequestIdOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_in_credentials = SubscriptionInCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_in_method = SubscriptionInMethodOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_version_default = ApiVersionDefaultOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_version_local = ApiVersionLocalOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skip_url_encoding = SkipUrlEncodingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.odata = OdataOperations(self._client, self._config, self._serialize, self._deserialize) + self.header = HeaderOperations(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. + + We have helper methods to create requests specific to this service in `azurespecialproperties.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurespecialproperties._rest import xms_client_request_id + >>> request = xms_client_request_id.build_get_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestAzureSpecialParametersTestClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_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/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/__init__.py new file mode 100644 index 00000000000..2de384d5760 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/__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 ._request_builders_py3 import build_get_method_global_valid_request + from ._request_builders_py3 import build_get_method_global_not_provided_valid_request + from ._request_builders_py3 import build_get_path_global_valid_request + from ._request_builders_py3 import build_get_swagger_global_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_method_global_valid_request # type: ignore + from ._request_builders import build_get_method_global_not_provided_valid_request # type: ignore + from ._request_builders import build_get_path_global_valid_request # type: ignore + from ._request_builders import build_get_swagger_global_valid_request # type: ignore + +__all__ = [ + "build_get_method_global_valid_request", + "build_get_method_global_not_provided_valid_request", + "build_get_path_global_valid_request", + "build_get_swagger_global_valid_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/_request_builders.py new file mode 100644 index 00000000000..9d0212cacf0 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/_request_builders.py @@ -0,0 +1,167 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_method_global_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_global_not_provided_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_global_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_global_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/_request_builders_py3.py new file mode 100644 index 00000000000..34e2b583232 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_default/_request_builders_py3.py @@ -0,0 +1,128 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_method_global_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_method_global_not_provided_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview" + ) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_path_global_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_swagger_global_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/__init__.py new file mode 100644 index 00000000000..1b0edf68897 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/__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 ._request_builders_py3 import build_get_method_local_valid_request + from ._request_builders_py3 import build_get_method_local_null_request + from ._request_builders_py3 import build_get_path_local_valid_request + from ._request_builders_py3 import build_get_swagger_local_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_method_local_valid_request # type: ignore + from ._request_builders import build_get_method_local_null_request # type: ignore + from ._request_builders import build_get_path_local_valid_request # type: ignore + from ._request_builders import build_get_swagger_local_valid_request # type: ignore + +__all__ = [ + "build_get_method_local_valid_request", + "build_get_method_local_null_request", + "build_get_path_local_valid_request", + "build_get_swagger_local_valid_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/_request_builders.py new file mode 100644 index 00000000000..1ee46fb4fb1 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/_request_builders.py @@ -0,0 +1,172 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_method_local_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/local/2.0') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_local_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = null to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword api_version: This should appear as a method parameter, use value null, this should + result in no serialized parameter. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/local/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_local_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/path/string/none/query/local/2.0') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_local_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/swagger/string/none/query/local/2.0') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/_request_builders_py3.py new file mode 100644 index 00000000000..d0184493ecf --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/api_version_local/_request_builders_py3.py @@ -0,0 +1,129 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_method_local_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/method/string/none/query/local/2.0") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_method_local_null_request(*, api_version: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = null to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword api_version: This should appear as a method parameter, use value null, this should + result in no serialized parameter. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/method/string/none/query/local/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if api_version is not None: + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_path_local_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/path/string/none/query/local/2.0") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_swagger_local_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/swagger/string/none/query/local/2.0") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/__init__.py new file mode 100644 index 00000000000..9482c75db3a --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/__init__.py @@ -0,0 +1,22 @@ +# 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_custom_named_request_id_request + from ._request_builders_py3 import build_custom_named_request_id_param_grouping_request + from ._request_builders_py3 import build_custom_named_request_id_head_request +except (SyntaxError, ImportError): + from ._request_builders import build_custom_named_request_id_request # type: ignore + from ._request_builders import build_custom_named_request_id_param_grouping_request # type: ignore + from ._request_builders import build_custom_named_request_id_head_request # type: ignore + +__all__ = [ + "build_custom_named_request_id_request", + "build_custom_named_request_id_param_grouping_request", + "build_custom_named_request_id_head_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/_request_builders.py new file mode 100644 index 00000000000..ed52917034e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/_request_builders.py @@ -0,0 +1,128 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_custom_named_request_id_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + foo_client_request_id = kwargs.pop('foo_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/customNamedRequestId') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['foo-client-request-id'] = _SERIALIZER.header("foo_client_request_id", foo_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_custom_named_request_id_param_grouping_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, + via a parameter group. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + foo_client_request_id = kwargs.pop('foo_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/customNamedRequestIdParamGrouping') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['foo-client-request-id'] = _SERIALIZER.header("foo_client_request_id", foo_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_custom_named_request_id_head_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + foo_client_request_id = kwargs.pop('foo_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/customNamedRequestIdHead') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['foo-client-request-id'] = _SERIALIZER.header("foo_client_request_id", foo_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/_request_builders_py3.py new file mode 100644 index 00000000000..2b144e1a554 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/header/_request_builders_py3.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. +# -------------------------------------------------------------------------- +from typing import Any, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_custom_named_request_id_request(*, foo_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/customNamedRequestId") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["foo-client-request-id"] = _SERIALIZER.header( + "foo_client_request_id", foo_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_custom_named_request_id_param_grouping_request(*, foo_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, + via a parameter group. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/customNamedRequestIdParamGrouping") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["foo-client-request-id"] = _SERIALIZER.header( + "foo_client_request_id", foo_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_custom_named_request_id_head_request(*, foo_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/customNamedRequestIdHead") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["foo-client-request-id"] = _SERIALIZER.header( + "foo_client_request_id", foo_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/__init__.py new file mode 100644 index 00000000000..ed7f4a99f12 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/__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_get_with_filter_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_with_filter_request # type: ignore + +__all__ = [ + "build_get_with_filter_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/_request_builders.py new file mode 100644 index 00000000000..431f7ffa00c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/_request_builders.py @@ -0,0 +1,70 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_with_filter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. + :paramtype filter: str + :keyword top: The top parameter with value 10. + :paramtype top: int + :keyword orderby: The orderby parameter with value id. + :paramtype orderby: str + :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 + """ + + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + orderby = kwargs.pop('orderby', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/odata/filter') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/_request_builders_py3.py new file mode 100644 index 00000000000..0380bbd8220 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/odata/_request_builders_py3.py @@ -0,0 +1,54 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_with_filter_request( + *, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. + :paramtype filter: str + :keyword top: The top parameter with value 10. + :paramtype top: int + :keyword orderby: The orderby parameter with value id. + :paramtype orderby: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/odata/filter") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + query_parameters["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + query_parameters["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/__init__.py new file mode 100644 index 00000000000..75de623f002 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/__init__.py @@ -0,0 +1,34 @@ +# 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_get_method_path_valid_request + from ._request_builders_py3 import build_get_path_valid_request + from ._request_builders_py3 import build_get_swagger_path_valid_request + from ._request_builders_py3 import build_get_method_query_valid_request + from ._request_builders_py3 import build_get_method_query_null_request + from ._request_builders_py3 import build_get_path_query_valid_request + from ._request_builders_py3 import build_get_swagger_query_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_method_path_valid_request # type: ignore + from ._request_builders import build_get_path_valid_request # type: ignore + from ._request_builders import build_get_swagger_path_valid_request # type: ignore + from ._request_builders import build_get_method_query_valid_request # type: ignore + from ._request_builders import build_get_method_query_null_request # type: ignore + from ._request_builders import build_get_path_query_valid_request # type: ignore + from ._request_builders import build_get_swagger_query_valid_request # type: ignore + +__all__ = [ + "build_get_method_path_valid_request", + "build_get_path_valid_request", + "build_get_swagger_path_valid_request", + "build_get_method_query_valid_request", + "build_get_method_query_null_request", + "build_get_path_query_valid_request", + "build_get_swagger_query_valid_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/_request_builders.py new file mode 100644 index 00000000000..20cf11a113e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/_request_builders.py @@ -0,0 +1,289 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_method_path_valid_request( + unencoded_path_param, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}') + path_format_arguments = { + 'unencodedPathParam': _SERIALIZER.url("unencoded_path_param", unencoded_path_param, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_valid_request( + unencoded_path_param, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}') + path_format_arguments = { + 'unencodedPathParam': _SERIALIZER.url("unencoded_path_param", unencoded_path_param, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_path_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + unencoded_path_param = "path1/path2/path3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}') + path_format_arguments = { + 'unencodedPathParam': _SERIALIZER.url("unencoded_path_param", unencoded_path_param, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_query_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + q1 = kwargs.pop('q1') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/method/query/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_query_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword q1: Unencoded query parameter with value null. + :paramtype q1: str + :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 + """ + + q1 = kwargs.pop('q1', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/method/query/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if q1 is not None: + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_query_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + q1 = kwargs.pop('q1') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/path/query/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_query_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + q1 = "value1&q2=value2&q3=value3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/swagger/query/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/_request_builders_py3.py new file mode 100644 index 00000000000..25508a2cb52 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/skip_url_encoding/_request_builders_py3.py @@ -0,0 +1,216 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_method_path_valid_request(unencoded_path_param: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}") + path_format_arguments = { + "unencodedPathParam": _SERIALIZER.url("unencoded_path_param", unencoded_path_param, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_path_valid_request(unencoded_path_param: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}") + path_format_arguments = { + "unencodedPathParam": _SERIALIZER.url("unencoded_path_param", unencoded_path_param, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_swagger_path_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + unencoded_path_param = "path1/path2/path3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}") + path_format_arguments = { + "unencodedPathParam": _SERIALIZER.url("unencoded_path_param", unencoded_path_param, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_method_query_valid_request(*, q1: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/method/query/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_method_query_null_request(*, q1: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword q1: Unencoded query parameter with value null. + :paramtype q1: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/method/query/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if q1 is not None: + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_path_query_valid_request(*, q1: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/path/query/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_swagger_query_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + q1 = "value1&q2=value2&q3=value3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/swagger/query/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/__init__.py new file mode 100644 index 00000000000..037aec6cb67 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/__init__.py @@ -0,0 +1,28 @@ +# 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_post_method_global_valid_request + from ._request_builders_py3 import build_post_method_global_null_request + from ._request_builders_py3 import build_post_method_global_not_provided_valid_request + from ._request_builders_py3 import build_post_path_global_valid_request + from ._request_builders_py3 import build_post_swagger_global_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_post_method_global_valid_request # type: ignore + from ._request_builders import build_post_method_global_null_request # type: ignore + from ._request_builders import build_post_method_global_not_provided_valid_request # type: ignore + from ._request_builders import build_post_path_global_valid_request # type: ignore + from ._request_builders import build_post_swagger_global_valid_request # type: ignore + +__all__ = [ + "build_post_method_global_valid_request", + "build_post_method_global_null_request", + "build_post_method_global_not_provided_valid_request", + "build_post_path_global_valid_request", + "build_post_swagger_global_valid_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/_request_builders.py new file mode 100644 index 00000000000..defc4b4fcb0 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/_request_builders.py @@ -0,0 +1,225 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_post_method_global_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_method_global_null_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + null, and client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_method_global_not_provided_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_path_global_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_swagger_global_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/_request_builders_py3.py new file mode 100644 index 00000000000..37da683848d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_credentials/_request_builders_py3.py @@ -0,0 +1,188 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_post_method_global_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_method_global_null_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + null, and client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_method_global_not_provided_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_path_global_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_swagger_global_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/__init__.py new file mode 100644 index 00000000000..f9e02296e01 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/__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 ._request_builders_py3 import build_post_method_local_valid_request + from ._request_builders_py3 import build_post_method_local_null_request + from ._request_builders_py3 import build_post_path_local_valid_request + from ._request_builders_py3 import build_post_swagger_local_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_post_method_local_valid_request # type: ignore + from ._request_builders import build_post_method_local_null_request # type: ignore + from ._request_builders import build_post_path_local_valid_request # type: ignore + from ._request_builders import build_post_swagger_local_valid_request # type: ignore + +__all__ = [ + "build_post_method_local_valid_request", + "build_post_method_local_null_request", + "build_post_path_local_valid_request", + "build_post_swagger_local_valid_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/_request_builders.py new file mode 100644 index 00000000000..2a456d8cf20 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/_request_builders.py @@ -0,0 +1,178 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_post_method_local_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: This should appear as a method parameter, use value + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_method_local_null_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = null, + client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: This should appear as a method parameter, use value null, client-side + validation should prvenet the call. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_path_local_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_swagger_local_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscriptionId, which appears in the path, the value is always + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/_request_builders_py3.py new file mode 100644 index 00000000000..ca9d9e0ac21 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/subscription_in_method/_request_builders_py3.py @@ -0,0 +1,147 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_post_method_local_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: This should appear as a method parameter, use value + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_method_local_null_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = null, + client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: This should appear as a method parameter, use value null, client-side + validation should prvenet the call. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_path_local_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_swagger_local_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: The subscriptionId, which appears in the path, the value is always + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/__init__.py new file mode 100644 index 00000000000..d91016b544c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/__init__.py @@ -0,0 +1,19 @@ +# 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_get_request + from ._request_builders_py3 import build_param_get_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_request # type: ignore + from ._request_builders import build_param_get_request # type: ignore + +__all__ = [ + "build_get_request", + "build_param_get_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/_request_builders.py new file mode 100644 index 00000000000..6b564681d8b --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/_request_builders.py @@ -0,0 +1,83 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/overwrite/x-ms-client-request-id/method/') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_param_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword x_ms_client_request_id: This should appear as a method parameter, use value + '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. + :paramtype x_ms_client_request_id: str + :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 + """ + + x_ms_client_request_id = kwargs.pop('x_ms_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/overwrite/x-ms-client-request-id/via-param/method/') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("x_ms_client_request_id", x_ms_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/_request_builders_py3.py new file mode 100644 index 00000000000..076eb4120a4 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_rest/xms_client_request_id/_request_builders_py3.py @@ -0,0 +1,63 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/overwrite/x-ms-client-request-id/method/") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_param_get_request(*, x_ms_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword x_ms_client_request_id: This should appear as a method parameter, use value + '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. + :paramtype x_ms_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/overwrite/x-ms-client-request-id/via-param/method/") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["x-ms-client-request-id"] = _SERIALIZER.header( + "x_ms_client_request_id", x_ms_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_version.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_version.py diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_auto_rest_azure_special_parameters_test_client.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_auto_rest_azure_special_parameters_test_client.py new file mode 100644 index 00000000000..73f3b409920 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_auto_rest_azure_special_parameters_test_client.py @@ -0,0 +1,133 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration +from .operations import ( + ApiVersionDefaultOperations, + ApiVersionLocalOperations, + HeaderOperations, + OdataOperations, + SkipUrlEncodingOperations, + SubscriptionInCredentialsOperations, + SubscriptionInMethodOperations, + XMsClientRequestIdOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestAzureSpecialParametersTestClient: + """Test Infrastructure for AutoRest. + + :ivar xms_client_request_id: XMsClientRequestIdOperations operations + :vartype xms_client_request_id: + azurespecialproperties.aio.operations.XMsClientRequestIdOperations + :ivar subscription_in_credentials: SubscriptionInCredentialsOperations operations + :vartype subscription_in_credentials: + azurespecialproperties.aio.operations.SubscriptionInCredentialsOperations + :ivar subscription_in_method: SubscriptionInMethodOperations operations + :vartype subscription_in_method: + azurespecialproperties.aio.operations.SubscriptionInMethodOperations + :ivar api_version_default: ApiVersionDefaultOperations operations + :vartype api_version_default: azurespecialproperties.aio.operations.ApiVersionDefaultOperations + :ivar api_version_local: ApiVersionLocalOperations operations + :vartype api_version_local: azurespecialproperties.aio.operations.ApiVersionLocalOperations + :ivar skip_url_encoding: SkipUrlEncodingOperations operations + :vartype skip_url_encoding: azurespecialproperties.aio.operations.SkipUrlEncodingOperations + :ivar odata: OdataOperations operations + :vartype odata: azurespecialproperties.aio.operations.OdataOperations + :ivar header: HeaderOperations operations + :vartype header: azurespecialproperties.aio.operations.HeaderOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestAzureSpecialParametersTestClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(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.xms_client_request_id = XMsClientRequestIdOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_in_credentials = SubscriptionInCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_in_method = SubscriptionInMethodOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_version_default = ApiVersionDefaultOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_version_local = ApiVersionLocalOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skip_url_encoding = SkipUrlEncodingOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.odata = OdataOperations(self._client, self._config, self._serialize, self._deserialize) + self.header = HeaderOperations(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. + + We have helper methods to create requests specific to this service in `azurespecialproperties.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurespecialproperties._rest import xms_client_request_id + >>> request = xms_client_request_id.build_get_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestAzureSpecialParametersTestClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py new file mode 100644 index 00000000000..fb5f6dcd97b --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_default_operations.py @@ -0,0 +1,184 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import api_version_default as rest_api_version_default + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiVersionDefaultOperations: + """ApiVersionDefaultOperations 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: ~azurespecialproperties.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 get_method_global_valid(self, **kwargs: Any) -> None: + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_method_global_valid_request( + template_url=self.get_method_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_global_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview"} # type: ignore + + @distributed_trace_async + async def get_method_global_not_provided_valid(self, **kwargs: Any) -> None: + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_method_global_not_provided_valid_request( + template_url=self.get_method_global_not_provided_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_global_not_provided_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview"} # type: ignore + + @distributed_trace_async + async def get_path_global_valid(self, **kwargs: Any) -> None: + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_path_global_valid_request( + template_url=self.get_path_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_global_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview"} # type: ignore + + @distributed_trace_async + async def get_swagger_global_valid(self, **kwargs: Any) -> None: + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_swagger_global_valid_request( + template_url=self.get_swagger_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_global_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py new file mode 100644 index 00000000000..3cd226d2824 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_api_version_local_operations.py @@ -0,0 +1,188 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import api_version_local as rest_api_version_local + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiVersionLocalOperations: + """ApiVersionLocalOperations 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: ~azurespecialproperties.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 get_method_local_valid(self, **kwargs: Any) -> None: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + :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", {})) + + request = rest_api_version_local.build_get_method_local_valid_request( + template_url=self.get_method_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_local_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/2.0"} # type: ignore + + @distributed_trace_async + async def get_method_local_null(self, api_version: Optional[str] = None, **kwargs: Any) -> None: + """Get method with api-version modeled in the method. pass in api-version = null to succeed. + + :param api_version: This should appear as a method parameter, use value null, this should + result in no serialized parameter. + :type api_version: 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", {})) + + request = rest_api_version_local.build_get_method_local_null_request( + api_version=api_version, + template_url=self.get_method_local_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_local_null.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/null"} # type: ignore + + @distributed_trace_async + async def get_path_local_valid(self, **kwargs: Any) -> None: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + :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", {})) + + request = rest_api_version_local.build_get_path_local_valid_request( + template_url=self.get_path_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_local_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/local/2.0"} # type: ignore + + @distributed_trace_async + async def get_swagger_local_valid(self, **kwargs: Any) -> None: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + :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", {})) + + request = rest_api_version_local.build_get_swagger_local_valid_request( + template_url=self.get_swagger_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_local_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/local/2.0"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py new file mode 100644 index 00000000000..47d4ad08193 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py @@ -0,0 +1,180 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import header as rest_header + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HeaderOperations: + """HeaderOperations 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: ~azurespecialproperties.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 custom_named_request_id(self, foo_client_request_id: str, **kwargs: Any) -> None: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + :param foo_client_request_id: The fooRequestId. + :type foo_client_request_id: 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", {})) + + request = rest_header.build_custom_named_request_id_request( + foo_client_request_id=foo_client_request_id, + template_url=self.custom_named_request_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) + + if cls: + return cls(pipeline_response, None, response_headers) + + custom_named_request_id.metadata = {"url": "/azurespecials/customNamedRequestId"} # type: ignore + + @distributed_trace_async + async def custom_named_request_id_param_grouping( + self, + header_custom_named_request_id_param_grouping_parameters: "_models.HeaderCustomNamedRequestIdParamGroupingParameters", + **kwargs: Any + ) -> None: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, + via a parameter group. + + :param header_custom_named_request_id_param_grouping_parameters: Parameter group. + :type header_custom_named_request_id_param_grouping_parameters: + ~azurespecialproperties.models.HeaderCustomNamedRequestIdParamGroupingParameters + :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", {})) + _foo_client_request_id = None + if header_custom_named_request_id_param_grouping_parameters is not None: + _foo_client_request_id = header_custom_named_request_id_param_grouping_parameters.foo_client_request_id + + request = rest_header.build_custom_named_request_id_param_grouping_request( + foo_client_request_id=_foo_client_request_id, + template_url=self.custom_named_request_id_param_grouping.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) + + if cls: + return cls(pipeline_response, None, response_headers) + + custom_named_request_id_param_grouping.metadata = {"url": "/azurespecials/customNamedRequestIdParamGrouping"} # type: ignore + + @distributed_trace_async + async def custom_named_request_id_head(self, foo_client_request_id: str, **kwargs: Any) -> None: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + :param foo_client_request_id: The fooRequestId. + :type foo_client_request_id: 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", {})) + + request = rest_header.build_custom_named_request_id_head_request( + foo_client_request_id=foo_client_request_id, + template_url=self.custom_named_request_id_head.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) + + if cls: + return cls(pipeline_response, None, response_headers) + return 200 <= response.status_code <= 299 + + custom_named_request_id_head.metadata = {"url": "/azurespecials/customNamedRequestIdHead"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py new file mode 100644 index 00000000000..4e8b60b4405 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_odata_operations.py @@ -0,0 +1,96 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import odata as rest_odata + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OdataOperations: + """OdataOperations 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: ~azurespecialproperties.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 get_with_filter( + self, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any + ) -> None: + """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. + + :param filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. + :type filter: str + :param top: The top parameter with value 10. + :type top: int + :param orderby: The orderby parameter with value id. + :type orderby: 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", {})) + + request = rest_odata.build_get_with_filter_request( + filter=filter, + top=top, + orderby=orderby, + template_url=self.get_with_filter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_with_filter.metadata = {"url": "/azurespecials/odata/filter"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py new file mode 100644 index 00000000000..f022e008df6 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_skip_url_encoding_operations.py @@ -0,0 +1,298 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import skip_url_encoding as rest_skip_url_encoding + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SkipUrlEncodingOperations: + """SkipUrlEncodingOperations 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: ~azurespecialproperties.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 get_method_path_valid(self, unencoded_path_param: str, **kwargs: Any) -> None: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: 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", {})) + + request = rest_skip_url_encoding.build_get_method_path_valid_request( + unencoded_path_param=unencoded_path_param, + template_url=self.get_method_path_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}"} # type: ignore + + @distributed_trace_async + async def get_path_valid(self, unencoded_path_param: str, **kwargs: Any) -> None: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: 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", {})) + + request = rest_skip_url_encoding.build_get_path_valid_request( + unencoded_path_param=unencoded_path_param, + template_url=self.get_path_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}"} # type: ignore + + @distributed_trace_async + async def get_swagger_path_valid(self, **kwargs: Any) -> None: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + :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", {})) + + request = rest_skip_url_encoding.build_get_swagger_path_valid_request( + template_url=self.get_swagger_path_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}"} # type: ignore + + @distributed_trace_async + async def get_method_query_valid(self, q1: str, **kwargs: Any) -> None: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :type q1: 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", {})) + + request = rest_skip_url_encoding.build_get_method_query_valid_request( + q1=q1, + template_url=self.get_method_query_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/valid"} # type: ignore + + @distributed_trace_async + async def get_method_query_null(self, q1: Optional[str] = None, **kwargs: Any) -> None: + """Get method with unencoded query parameter with value null. + + :param q1: Unencoded query parameter with value null. + :type q1: 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", {})) + + request = rest_skip_url_encoding.build_get_method_query_null_request( + q1=q1, + template_url=self.get_method_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_query_null.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/null"} # type: ignore + + @distributed_trace_async + async def get_path_query_valid(self, q1: str, **kwargs: Any) -> None: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :type q1: 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", {})) + + request = rest_skip_url_encoding.build_get_path_query_valid_request( + q1=q1, + template_url=self.get_path_query_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/query/valid"} # type: ignore + + @distributed_trace_async + async def get_swagger_query_valid(self, **kwargs: Any) -> None: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + :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", {})) + + request = rest_skip_url_encoding.build_get_swagger_query_valid_request( + template_url=self.get_swagger_query_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/query/valid"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py new file mode 100644 index 00000000000..84ca0ed027d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_credentials_operations.py @@ -0,0 +1,227 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import subscription_in_credentials as rest_subscription_in_credentials + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SubscriptionInCredentialsOperations: + """SubscriptionInCredentialsOperations 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: ~azurespecialproperties.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 post_method_global_valid(self, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_method_global_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_method_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_global_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_method_global_null(self, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + null, and client-side validation should prevent you from making this call. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_method_global_null_request( + subscription_id=self._config.subscription_id, + template_url=self.post_method_global_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_global_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_method_global_not_provided_valid(self, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_method_global_not_provided_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_method_global_not_provided_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_global_not_provided_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_path_global_valid(self, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_path_global_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_path_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_path_global_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_swagger_global_valid(self, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_swagger_global_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_swagger_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_swagger_global_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py new file mode 100644 index 00000000000..e61a35e31fe --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_subscription_in_method_operations.py @@ -0,0 +1,203 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import subscription_in_method as rest_subscription_in_method + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SubscriptionInMethodOperations: + """SubscriptionInMethodOperations 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: ~azurespecialproperties.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 post_method_local_valid(self, subscription_id: str, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + :param subscription_id: This should appear as a method parameter, use value + '1234-5678-9012-3456'. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_method_local_valid_request( + subscription_id=subscription_id, + template_url=self.post_method_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_local_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_method_local_null(self, subscription_id: str, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in the method. pass in subscription id = null, + client-side validation should prevent you from making this call. + + :param subscription_id: This should appear as a method parameter, use value null, client-side + validation should prvenet the call. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_method_local_null_request( + subscription_id=subscription_id, + template_url=self.post_method_local_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_local_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_path_local_valid(self, subscription_id: str, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_path_local_valid_request( + subscription_id=subscription_id, + template_url=self.post_path_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_path_local_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace_async + async def post_swagger_local_valid(self, subscription_id: str, **kwargs: Any) -> None: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + :param subscription_id: The subscriptionId, which appears in the path, the value is always + '1234-5678-9012-3456'. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_swagger_local_valid_request( + subscription_id=subscription_id, + template_url=self.post_swagger_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_swagger_local_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py new file mode 100644 index 00000000000..6b127625733 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_xms_client_request_id_operations.py @@ -0,0 +1,123 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import xms_client_request_id as rest_xms_client_request_id + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class XMsClientRequestIdOperations: + """XMsClientRequestIdOperations 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: ~azurespecialproperties.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 get(self, **kwargs: Any) -> None: + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + :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", {})) + + request = rest_xms_client_request_id.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/method/"} # type: ignore + + @distributed_trace_async + async def param_get(self, x_ms_client_request_id: str, **kwargs: Any) -> None: + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + :param x_ms_client_request_id: This should appear as a method parameter, use value + '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. + :type x_ms_client_request_id: 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", {})) + + request = rest_xms_client_request_id.build_param_get_request( + x_ms_client_request_id=x_ms_client_request_id, + template_url=self.param_get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + param_get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/via-param/method/"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py new file mode 100644 index 00000000000..dc4857b3463 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py @@ -0,0 +1,192 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import api_version_default as rest_api_version_default + +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]] + + +class ApiVersionDefaultOperations(object): + """ApiVersionDefaultOperations 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: ~azurespecialproperties.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 get_method_global_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_method_global_valid_request( + template_url=self.get_method_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_global_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview"} # type: ignore + + @distributed_trace + def get_method_global_not_provided_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_method_global_not_provided_valid_request( + template_url=self.get_method_global_not_provided_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_global_not_provided_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview"} # type: ignore + + @distributed_trace + def get_path_global_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_path_global_valid_request( + template_url=self.get_path_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_global_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview"} # type: ignore + + @distributed_trace + def get_swagger_global_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """GET method with api-version modeled in global settings. + + :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", {})) + + request = rest_api_version_default.build_get_swagger_global_valid_request( + template_url=self.get_swagger_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_global_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py new file mode 100644 index 00000000000..7ce7f0192e4 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_local_operations.py @@ -0,0 +1,198 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import api_version_local as rest_api_version_local + +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]] + + +class ApiVersionLocalOperations(object): + """ApiVersionLocalOperations 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: ~azurespecialproperties.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 get_method_local_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + :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", {})) + + request = rest_api_version_local.build_get_method_local_valid_request( + template_url=self.get_method_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_local_valid.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/2.0"} # type: ignore + + @distributed_trace + def get_method_local_null( + self, + api_version=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Get method with api-version modeled in the method. pass in api-version = null to succeed. + + :param api_version: This should appear as a method parameter, use value null, this should + result in no serialized parameter. + :type api_version: 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", {})) + + request = rest_api_version_local.build_get_method_local_null_request( + api_version=api_version, + template_url=self.get_method_local_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_local_null.metadata = {"url": "/azurespecials/apiVersion/method/string/none/query/local/null"} # type: ignore + + @distributed_trace + def get_path_local_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + :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", {})) + + request = rest_api_version_local.build_get_path_local_valid_request( + template_url=self.get_path_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_local_valid.metadata = {"url": "/azurespecials/apiVersion/path/string/none/query/local/2.0"} # type: ignore + + @distributed_trace + def get_swagger_local_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + :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", {})) + + request = rest_api_version_local.build_get_swagger_local_valid_request( + template_url=self.get_swagger_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_local_valid.metadata = {"url": "/azurespecials/apiVersion/swagger/string/none/query/local/2.0"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py new file mode 100644 index 00000000000..7cfc3fc2e8d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py @@ -0,0 +1,189 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import header as rest_header + +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]] + + +class HeaderOperations(object): + """HeaderOperations 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: ~azurespecialproperties.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 custom_named_request_id( + self, + foo_client_request_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + :param foo_client_request_id: The fooRequestId. + :type foo_client_request_id: 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", {})) + + request = rest_header.build_custom_named_request_id_request( + foo_client_request_id=foo_client_request_id, + template_url=self.custom_named_request_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) + + if cls: + return cls(pipeline_response, None, response_headers) + + custom_named_request_id.metadata = {"url": "/azurespecials/customNamedRequestId"} # type: ignore + + @distributed_trace + def custom_named_request_id_param_grouping( + self, + header_custom_named_request_id_param_grouping_parameters, # type: "_models.HeaderCustomNamedRequestIdParamGroupingParameters" + **kwargs # type: Any + ): + # type: (...) -> None + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, + via a parameter group. + + :param header_custom_named_request_id_param_grouping_parameters: Parameter group. + :type header_custom_named_request_id_param_grouping_parameters: + ~azurespecialproperties.models.HeaderCustomNamedRequestIdParamGroupingParameters + :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", {})) + _foo_client_request_id = None + if header_custom_named_request_id_param_grouping_parameters is not None: + _foo_client_request_id = header_custom_named_request_id_param_grouping_parameters.foo_client_request_id + + request = rest_header.build_custom_named_request_id_param_grouping_request( + foo_client_request_id=_foo_client_request_id, + template_url=self.custom_named_request_id_param_grouping.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) + + if cls: + return cls(pipeline_response, None, response_headers) + + custom_named_request_id_param_grouping.metadata = {"url": "/azurespecials/customNamedRequestIdParamGrouping"} # type: ignore + + @distributed_trace + def custom_named_request_id_head( + self, + foo_client_request_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + :param foo_client_request_id: The fooRequestId. + :type foo_client_request_id: 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", {})) + + request = rest_header.build_custom_named_request_id_head_request( + foo_client_request_id=foo_client_request_id, + template_url=self.custom_named_request_id_head.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["foo-request-id"] = self._deserialize("str", response.headers.get("foo-request-id")) + + if cls: + return cls(pipeline_response, None, response_headers) + return 200 <= response.status_code <= 299 + + custom_named_request_id_head.metadata = {"url": "/azurespecials/customNamedRequestIdHead"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py new file mode 100644 index 00000000000..ca427e352de --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_odata_operations.py @@ -0,0 +1,103 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import odata as rest_odata + +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]] + + +class OdataOperations(object): + """OdataOperations 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: ~azurespecialproperties.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 get_with_filter( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. + + :param filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. + :type filter: str + :param top: The top parameter with value 10. + :type top: int + :param orderby: The orderby parameter with value id. + :type orderby: 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", {})) + + request = rest_odata.build_get_with_filter_request( + filter=filter, + top=top, + orderby=orderby, + template_url=self.get_with_filter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_with_filter.metadata = {"url": "/azurespecials/odata/filter"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py new file mode 100644 index 00000000000..547dee603df --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_skip_url_encoding_operations.py @@ -0,0 +1,319 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import skip_url_encoding as rest_skip_url_encoding + +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]] + + +class SkipUrlEncodingOperations(object): + """SkipUrlEncodingOperations 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: ~azurespecialproperties.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 get_method_path_valid( + self, + unencoded_path_param, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: 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", {})) + + request = rest_skip_url_encoding.build_get_method_path_valid_request( + unencoded_path_param=unencoded_path_param, + template_url=self.get_method_path_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}"} # type: ignore + + @distributed_trace + def get_path_valid( + self, + unencoded_path_param, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: 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", {})) + + request = rest_skip_url_encoding.build_get_path_valid_request( + unencoded_path_param=unencoded_path_param, + template_url=self.get_path_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}"} # type: ignore + + @distributed_trace + def get_swagger_path_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + :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", {})) + + request = rest_skip_url_encoding.build_get_swagger_path_valid_request( + template_url=self.get_swagger_path_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_path_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}"} # type: ignore + + @distributed_trace + def get_method_query_valid( + self, + q1, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :type q1: 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", {})) + + request = rest_skip_url_encoding.build_get_method_query_valid_request( + q1=q1, + template_url=self.get_method_query_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/valid"} # type: ignore + + @distributed_trace + def get_method_query_null( + self, + q1=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded query parameter with value null. + + :param q1: Unencoded query parameter with value null. + :type q1: 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", {})) + + request = rest_skip_url_encoding.build_get_method_query_null_request( + q1=q1, + template_url=self.get_method_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_method_query_null.metadata = {"url": "/azurespecials/skipUrlEncoding/method/query/null"} # type: ignore + + @distributed_trace + def get_path_query_valid( + self, + q1, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + :param q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :type q1: 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", {})) + + request = rest_skip_url_encoding.build_get_path_query_valid_request( + q1=q1, + template_url=self.get_path_query_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_path_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/path/query/valid"} # type: ignore + + @distributed_trace + def get_swagger_query_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + :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", {})) + + request = rest_skip_url_encoding.build_get_swagger_query_valid_request( + template_url=self.get_swagger_query_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get_swagger_query_valid.metadata = {"url": "/azurespecials/skipUrlEncoding/swagger/query/valid"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py new file mode 100644 index 00000000000..d11bfd80108 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py @@ -0,0 +1,236 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import subscription_in_credentials as rest_subscription_in_credentials + +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]] + + +class SubscriptionInCredentialsOperations(object): + """SubscriptionInCredentialsOperations 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: ~azurespecialproperties.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 post_method_global_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_method_global_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_method_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_global_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_method_global_null( + self, **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + null, and client-side validation should prevent you from making this call. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_method_global_null_request( + subscription_id=self._config.subscription_id, + template_url=self.post_method_global_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_global_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_method_global_not_provided_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_method_global_not_provided_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_method_global_not_provided_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_global_not_provided_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_path_global_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_path_global_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_path_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_path_global_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_swagger_global_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + :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", {})) + + request = rest_subscription_in_credentials.build_post_swagger_global_valid_request( + subscription_id=self._config.subscription_id, + template_url=self.post_swagger_global_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_swagger_global_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py new file mode 100644 index 00000000000..77da35d698f --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py @@ -0,0 +1,219 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import subscription_in_method as rest_subscription_in_method + +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]] + + +class SubscriptionInMethodOperations(object): + """SubscriptionInMethodOperations 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: ~azurespecialproperties.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 post_method_local_valid( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + :param subscription_id: This should appear as a method parameter, use value + '1234-5678-9012-3456'. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_method_local_valid_request( + subscription_id=subscription_id, + template_url=self.post_method_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_local_valid.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_method_local_null( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in the method. pass in subscription id = null, + client-side validation should prevent you from making this call. + + :param subscription_id: This should appear as a method parameter, use value null, client-side + validation should prvenet the call. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_method_local_null_request( + subscription_id=subscription_id, + template_url=self.post_method_local_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_method_local_null.metadata = {"url": "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_path_local_valid( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_path_local_valid_request( + subscription_id=subscription_id, + template_url=self.post_path_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_path_local_valid.metadata = {"url": "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore + + @distributed_trace + def post_swagger_local_valid( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + :param subscription_id: The subscriptionId, which appears in the path, the value is always + '1234-5678-9012-3456'. + :type subscription_id: 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", {})) + + request = rest_subscription_in_method.build_post_swagger_local_valid_request( + subscription_id=subscription_id, + template_url=self.post_swagger_local_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + post_swagger_local_valid.metadata = {"url": "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py new file mode 100644 index 00000000000..64067e3cf6b --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_xms_client_request_id_operations.py @@ -0,0 +1,131 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import xms_client_request_id as rest_xms_client_request_id + +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]] + + +class XMsClientRequestIdOperations(object): + """XMsClientRequestIdOperations 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: ~azurespecialproperties.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 get( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + :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", {})) + + request = rest_xms_client_request_id.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/method/"} # type: ignore + + @distributed_trace + def param_get( + self, + x_ms_client_request_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + :param x_ms_client_request_id: This should appear as a method parameter, use value + '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. + :type x_ms_client_request_id: 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", {})) + + request = rest_xms_client_request_id.build_param_get_request( + x_ms_client_request_id=x_ms_client_request_id, + template_url=self.param_get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + param_get.metadata = {"url": "/azurespecials/overwrite/x-ms-client-request-id/via-param/method/"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/py.typed b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/setup.py b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/setup.py new file mode 100644 index 00000000000..90ff32230bf --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/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 = "autorestazurespecialparameterstestclient" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestAzureSpecialParametersTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestAzureSpecialParametersTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..336b4570eb9 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,97 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration +from .operations import PathsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedHostTestClient(object): + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: custombaseurl.operations.PathsOperations + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurl.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurl._rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedHostTestClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_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/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/__init__.py new file mode 100644 index 00000000000..5daa0aa077d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/__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_get_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_request # type: ignore + +__all__ = [ + "build_get_empty_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders.py new file mode 100644 index 00000000000..0931964c6cb --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders.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.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/customuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..5a2da7d8789 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders_py3.py @@ -0,0 +1,36 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/customuri") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..5dcf9d9b3ed --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,79 @@ +# 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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestParameterizedHostTestClientConfiguration +from .operations import PathsOperations + + +class AutoRestParameterizedHostTestClient: + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: custombaseurl.aio.operations.PathsOperations + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurl.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurl._rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedHostTestClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py new file mode 100644 index 00000000000..70f7776f229 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.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. +# -------------------------------------------------------------------------- +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 ... import models as _models +from ..._rest import paths as rest_paths + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PathsOperations: + """PathsOperations 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: ~custombaseurl.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 get_empty(self, account_name: str, **kwargs: Any) -> None: + """Get a 200 to test a valid base uri. + + :param account_name: Account Name. + :type account_name: 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", {})) + + request = rest_paths.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py new file mode 100644 index 00000000000..6fecf75707f --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py @@ -0,0 +1,97 @@ +# 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 .. import models as _models +from .._rest import paths as rest_paths + +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]] + + +class PathsOperations(object): + """PathsOperations 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: ~custombaseurl.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 get_empty( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a 200 to test a valid base uri. + + :param account_name: Account Name. + :type account_name: 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", {})) + + request = rest_paths.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/setup.py b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/setup.py new file mode 100644 index 00000000000..37d0593ce8f --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomBaseUri/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 = "autorestparameterizedhosttestclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_auto_rest_paging_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_auto_rest_paging_test_service.py new file mode 100644 index 00000000000..b20b58f4d06 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_auto_rest_paging_test_service.py @@ -0,0 +1,102 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import AutoRestPagingTestServiceConfiguration +from .operations import PagingOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + +class AutoRestPagingTestService(object): + """Long-running Operation for AutoRest. + + :ivar paging: PagingOperations operations + :vartype paging: custompollerpager.operations.PagingOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'http://localhost:3000' + self._config = AutoRestPagingTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(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.paging = PagingOperations(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. + + We have helper methods to create requests specific to this service in `custompollerpager.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custompollerpager._rest import paging + >>> request = paging.build_get_no_item_name_pages_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestPagingTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/__init__.py new file mode 100644 index 00000000000..8e6cf7ef943 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_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. +# -------------------------------------------------------------------------- \ No newline at end of file diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/__init__.py new file mode 100644 index 00000000000..a9367d1b85d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/__init__.py @@ -0,0 +1,73 @@ +# 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_get_no_item_name_pages_request + from ._request_builders_py3 import build_get_null_next_link_name_pages_request + from ._request_builders_py3 import build_get_single_pages_request + from ._request_builders_py3 import build_first_response_empty_request + from ._request_builders_py3 import build_get_multiple_pages_request + from ._request_builders_py3 import build_get_with_query_params_request + from ._request_builders_py3 import build_next_operation_with_query_params_request + from ._request_builders_py3 import build_get_odata_multiple_pages_request + from ._request_builders_py3 import build_get_multiple_pages_with_offset_request + from ._request_builders_py3 import build_get_multiple_pages_retry_first_request + from ._request_builders_py3 import build_get_multiple_pages_retry_second_request + from ._request_builders_py3 import build_get_single_pages_failure_request + from ._request_builders_py3 import build_get_multiple_pages_failure_request + from ._request_builders_py3 import build_get_multiple_pages_failure_uri_request + from ._request_builders_py3 import build_get_multiple_pages_fragment_next_link_request + from ._request_builders_py3 import build_get_multiple_pages_fragment_with_grouping_next_link_request + from ._request_builders_py3 import build_get_multiple_pages_lro_request_initial + from ._request_builders_py3 import build_next_fragment_request + from ._request_builders_py3 import build_next_fragment_with_grouping_request + from ._request_builders_py3 import build_get_paging_model_with_item_name_with_xms_client_name_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_no_item_name_pages_request # type: ignore + from ._request_builders import build_get_null_next_link_name_pages_request # type: ignore + from ._request_builders import build_get_single_pages_request # type: ignore + from ._request_builders import build_first_response_empty_request # type: ignore + from ._request_builders import build_get_multiple_pages_request # type: ignore + from ._request_builders import build_get_with_query_params_request # type: ignore + from ._request_builders import build_next_operation_with_query_params_request # type: ignore + from ._request_builders import build_get_odata_multiple_pages_request # type: ignore + from ._request_builders import build_get_multiple_pages_with_offset_request # type: ignore + from ._request_builders import build_get_multiple_pages_retry_first_request # type: ignore + from ._request_builders import build_get_multiple_pages_retry_second_request # type: ignore + from ._request_builders import build_get_single_pages_failure_request # type: ignore + from ._request_builders import build_get_multiple_pages_failure_request # type: ignore + from ._request_builders import build_get_multiple_pages_failure_uri_request # type: ignore + from ._request_builders import build_get_multiple_pages_fragment_next_link_request # type: ignore + from ._request_builders import build_get_multiple_pages_fragment_with_grouping_next_link_request # type: ignore + from ._request_builders import build_get_multiple_pages_lro_request_initial # type: ignore + from ._request_builders import build_next_fragment_request # type: ignore + from ._request_builders import build_next_fragment_with_grouping_request # type: ignore + from ._request_builders import build_get_paging_model_with_item_name_with_xms_client_name_request # type: ignore + +__all__ = [ + 'build_get_no_item_name_pages_request', + 'build_get_null_next_link_name_pages_request', + 'build_get_single_pages_request', + 'build_first_response_empty_request', + 'build_get_multiple_pages_request', + 'build_get_with_query_params_request', + 'build_next_operation_with_query_params_request', + 'build_get_odata_multiple_pages_request', + 'build_get_multiple_pages_with_offset_request', + 'build_get_multiple_pages_retry_first_request', + 'build_get_multiple_pages_retry_second_request', + 'build_get_single_pages_failure_request', + 'build_get_multiple_pages_failure_request', + 'build_get_multiple_pages_failure_uri_request', + 'build_get_multiple_pages_fragment_next_link_request', + 'build_get_multiple_pages_fragment_with_grouping_next_link_request', + 'build_get_multiple_pages_lro_request_initial', + 'build_next_fragment_request', + 'build_next_fragment_with_grouping_request', + 'build_get_paging_model_with_item_name_with_xms_client_name_request', +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/_request_builders.py new file mode 100644 index 00000000000..a0f38d99d7c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/_request_builders.py @@ -0,0 +1,810 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_no_item_name_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that must return result of the default 'value' node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/noitemname') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_next_link_name_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/nullnextlink') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that finishes on the first call without a nextlink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_first_response_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/firstResponseEmpty/1') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_with_query_params_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_query_parameter: A required integer query parameter. Put in value '100' to + pass test. + :paramtype required_query_parameter: int + :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 + """ + + required_query_parameter = kwargs.pop('required_query_parameter') # type: int + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/getWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['requiredQueryParameter'] = _SERIALIZER.query("required_query_parameter", required_query_parameter, 'int') + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_operation_with_query_params_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/nextOperationWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_odata_multiple_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink in odata format that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/odata') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_with_offset_request( + offset, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param offset: Offset of return value. + :type offset: int + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/withpath/{offset}') + path_format_arguments = { + 'offset': _SERIALIZER.url("offset", offset, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_first_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retryfirst') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_second_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retrysecond') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_failure_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives a 400 on the first call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives a 400 on the second call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives an invalid nextLink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failureuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_next_link_request( + tenant, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/lro') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_request( + tenant, # type: str + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_with_grouping_request( + tenant, # type: str + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_paging_model_with_item_name_with_xms_client_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/itemNameWithXMSClientName') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/_request_builders_py3.py new file mode 100644 index 00000000000..63bde7ebfe4 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_rest/paging/_request_builders_py3.py @@ -0,0 +1,785 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_no_item_name_pages_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that must return result of the default 'value' node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/noitemname') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_next_link_name_pages_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/nullnextlink') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that finishes on the first call without a nextlink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_first_response_empty_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/firstResponseEmpty/1') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_with_query_params_request( + *, + required_query_parameter: int, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_query_parameter: A required integer query parameter. Put in value '100' to + pass test. + :paramtype required_query_parameter: int + :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 + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/getWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['requiredQueryParameter'] = _SERIALIZER.query("required_query_parameter", required_query_parameter, 'int') + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_operation_with_query_params_request( + **kwargs: Any +) -> HttpRequest: + """Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/nextOperationWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_odata_multiple_pages_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink in odata format that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/odata') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_with_offset_request( + offset: int, + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param offset: Offset of return value. + :type offset: int + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/withpath/{offset}') + path_format_arguments = { + 'offset': _SERIALIZER.url("offset", offset, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_first_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retryfirst') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_second_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retrysecond') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_failure_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that receives a 400 on the first call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that receives a 400 on the second call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_uri_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that receives an invalid nextLink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failureuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_next_link_request( + tenant: str, + *, + api_version: str, + **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant: str, + *, + api_version: str, + **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_lro_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/lro') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_request( + tenant: str, + next_link: str, + *, + api_version: str, + **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_with_grouping_request( + tenant: str, + next_link: str, + *, + api_version: str, + **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_paging_model_with_item_name_with_xms_client_name_request( + **kwargs: Any +) -> HttpRequest: + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/itemNameWithXMSClientName') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_version.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_version.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_auto_rest_paging_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_auto_rest_paging_test_service.py new file mode 100644 index 00000000000..2d04fbf9317 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_auto_rest_paging_test_service.py @@ -0,0 +1,95 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestPagingTestServiceConfiguration +from .operations import PagingOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AutoRestPagingTestService: + """Long-running Operation for AutoRest. + + :ivar paging: PagingOperations operations + :vartype paging: custompollerpager.aio.operations.PagingOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'http://localhost:3000' + self._config = AutoRestPagingTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(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.paging = PagingOperations(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. + + We have helper methods to create requests specific to this service in `custompollerpager.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custompollerpager._rest import paging + >>> request = paging.build_get_no_item_name_pages_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestPagingTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py new file mode 100644 index 00000000000..dcd21fb2569 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py @@ -0,0 +1,1259 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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.polling import AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling +from custompollerpagerdefinitions.aio import AsyncCustomPager, AsyncCustomPoller + +from ... import models as _models +from ..._rest import paging as rest_paging + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PagingOperations: + """PagingOperations 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: ~custompollerpager.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 + + def get_no_item_name_pages( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResultValue"]: + """A paging operation that must return result of the default 'value' node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=self.get_no_item_name_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResultValue', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_no_item_name_pages.metadata = {'url': '/paging/noitemname'} # type: ignore + + def get_null_next_link_name_pages( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=self.get_null_next_link_name_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_null_next_link_name_pages.metadata = {'url': '/paging/nullnextlink'} # type: ignore + + def get_single_pages( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that finishes on the first call without a nextlink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: + ~custompollerpagerdefinitions.aio.AsyncCustomPager[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_request( + template_url=self.get_single_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncCustomPager( + get_next, extract_data + ) + get_single_pages.metadata = {'url': '/paging/single'} # type: ignore + + def first_response_empty( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResultValue"]: + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_first_response_empty_request( + template_url=self.first_response_empty.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_first_response_empty_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResultValue', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + first_response_empty.metadata = {'url': '/paging/firstResponseEmpty/1'} # type: ignore + + def get_multiple_pages( + self, + client_request_id: Optional[str] = None, + paging_get_multiple_pages_options: Optional["_models.PagingGetMultiplePagesOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_options: Parameter group. + :type paging_get_multiple_pages_options: + ~custompollerpager.models.PagingGetMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages.metadata = {'url': '/paging/multiple'} # type: ignore + + def get_with_query_params( + self, + required_query_parameter: int, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + :param required_query_parameter: A required integer query parameter. Put in value '100' to pass + test. + :type required_query_parameter: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_with_query_params_request( + required_query_parameter=required_query_parameter, + template_url=self.get_with_query_params.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_operation_with_query_params_request( + template_url='/paging/multiple/nextOperationWithQueryParams', + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_with_query_params.metadata = {'url': '/paging/multiple/getWithQueryParams'} # type: ignore + + def get_odata_multiple_pages( + self, + client_request_id: Optional[str] = None, + paging_get_odata_multiple_pages_options: Optional["_models.PagingGetOdataMultiplePagesOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.OdataProductResult"]: + """A paging operation that includes a nextLink in odata format that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_odata_multiple_pages_options: Parameter group. + :type paging_get_odata_multiple_pages_options: + ~custompollerpager.models.PagingGetOdataMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_odata_multiple_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OdataProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_odata_multiple_pages.metadata = {'url': '/paging/multiple/odata'} # type: ignore + + def get_multiple_pages_with_offset( + self, + paging_get_multiple_pages_with_offset_options: "_models.PagingGetMultiplePagesWithOffsetOptions", + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a nextLink that has 10 pages. + + :param paging_get_multiple_pages_with_offset_options: Parameter group. + :type paging_get_multiple_pages_with_offset_options: + ~custompollerpager.models.PagingGetMultiplePagesWithOffsetOptions + :param client_request_id: + :type client_request_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages_with_offset.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_with_offset.metadata = {'url': '/paging/multiple/withpath/{offset}'} # type: ignore + + def get_multiple_pages_retry_first( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=self.get_multiple_pages_retry_first.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_retry_first.metadata = {'url': '/paging/multiple/retryfirst'} # type: ignore + + def get_multiple_pages_retry_second( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=self.get_multiple_pages_retry_second.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_retry_second.metadata = {'url': '/paging/multiple/retrysecond'} # type: ignore + + def get_single_pages_failure( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that receives a 400 on the first call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=self.get_single_pages_failure.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_single_pages_failure.metadata = {'url': '/paging/single/failure'} # type: ignore + + def get_multiple_pages_failure( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that receives a 400 on the second call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=self.get_multiple_pages_failure.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_failure.metadata = {'url': '/paging/multiple/failure'} # type: ignore + + def get_multiple_pages_failure_uri( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that receives an invalid nextLink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=self.get_multiple_pages_failure_uri.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_failure_uri.metadata = {'url': '/paging/multiple/failureuri'} # type: ignore + + def get_multiple_pages_fragment_next_link( + self, + api_version: str, + tenant: str, + **kwargs: Any + ) -> AsyncIterable["_models.OdataProductResult"]: + """A paging operation that doesn't return a full URL, just a fragment. + + :param api_version: Sets the api version to use. + :type api_version: str + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_fragment_next_link_request( + tenant=tenant, + api_version=api_version, + template_url=self.get_multiple_pages_fragment_next_link.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_fragment_request( + tenant=tenant, + next_link=next_link, + api_version=api_version, + template_url='/paging/multiple/fragment/{tenant}/{nextLink}', + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OdataProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_fragment_next_link.metadata = {'url': '/paging/multiple/fragment/{tenant}'} # type: ignore + + def get_multiple_pages_fragment_with_grouping_next_link( + self, + custom_parameter_group: "_models.CustomParameterGroup", + **kwargs: Any + ) -> AsyncIterable["_models.OdataProductResult"]: + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + :param custom_parameter_group: Parameter group. + :type custom_parameter_group: ~custompollerpager.models.CustomParameterGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant=_tenant, + api_version=_api_version, + template_url=self.get_multiple_pages_fragment_with_grouping_next_link.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_next_fragment_with_grouping_request( + tenant=_tenant, + next_link=next_link, + api_version=_api_version, + template_url='/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}', + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OdataProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_multiple_pages_fragment_with_grouping_next_link.metadata = {'url': '/paging/multiple/fragmentwithgrouping/{tenant}'} # type: ignore + + async def _get_multiple_pages_lro_initial( + self, + client_request_id: Optional[str] = None, + paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, + **kwargs: Any + ) -> "_models.ProductResult": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._get_multiple_pages_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ProductResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _get_multiple_pages_lro_initial.metadata = {'url': '/paging/multiple/lro'} # type: ignore + + + async def begin_get_multiple_pages_lro( + self, + client_request_id: Optional[str] = None, + paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, + **kwargs: Any + ) -> AsyncCustomPoller[AsyncItemPaged["_models.ProductResult"]]: + """A long-running paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_lro_options: Parameter group. + :type paging_get_multiple_pages_lro_options: + ~custompollerpager.models.PagingGetMultiplePagesLroOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncCustomPoller that returns an iterator like instance of either + ProductResult or the result of cls(response) + :rtype: + ~custompollerpagerdefinitions.aio.AsyncCustomPoller[~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResult]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_get_multiple_pages_lro.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._get_multiple_pages_lro_initial( + client_request_id=client_request_id, + paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + def get_long_running_output(pipeline_response): + async def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + else: + return await get_next(next_link) + + return AsyncItemPaged( + internal_get_next, extract_data + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncCustomPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncCustomPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_get_multiple_pages_lro.metadata = {'url': '/paging/multiple/lro'} # type: ignore + + + def get_paging_model_with_item_name_with_xms_client_name( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResultValueWithXMSClientName"]: + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~custompollerpager.models.ProductResultValueWithXMSClientName] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=self.get_paging_model_with_item_name_with_xms_client_name.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResultValueWithXMSClientName', pipeline_response) + list_of_elem = deserialized.indexes + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_paging_model_with_item_name_with_xms_client_name.metadata = {'url': '/paging/itemNameWithXMSClientName'} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_auto_rest_paging_test_service_enums.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_auto_rest_paging_test_service_enums.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_auto_rest_paging_test_service_enums.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_auto_rest_paging_test_service_enums.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py new file mode 100644 index 00000000000..b12f05784f2 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/operations/_paging_operations.py @@ -0,0 +1,1280 @@ +# 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.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from custompollerpagerdefinitions import CustomPager, CustomPoller + +from .. import models as _models +from .._rest import paging as rest_paging + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class PagingOperations(object): + """PagingOperations 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: ~custompollerpager.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 + + def get_no_item_name_pages( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResultValue"] + """A paging operation that must return result of the default 'value' node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=self.get_no_item_name_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResultValue', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_no_item_name_pages.metadata = {'url': '/paging/noitemname'} # type: ignore + + def get_null_next_link_name_pages( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=self.get_null_next_link_name_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_null_next_link_name_pages.metadata = {'url': '/paging/nullnextlink'} # type: ignore + + def get_single_pages( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that finishes on the first call without a nextlink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~custompollerpagerdefinitions.CustomPager[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_request( + template_url=self.get_single_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return CustomPager( + get_next, extract_data + ) + get_single_pages.metadata = {'url': '/paging/single'} # type: ignore + + def first_response_empty( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResultValue"] + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_first_response_empty_request( + template_url=self.first_response_empty.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_first_response_empty_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResultValue', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + first_response_empty.metadata = {'url': '/paging/firstResponseEmpty/1'} # type: ignore + + def get_multiple_pages( + self, + client_request_id=None, # type: Optional[str] + paging_get_multiple_pages_options=None, # type: Optional["_models.PagingGetMultiplePagesOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_options: Parameter group. + :type paging_get_multiple_pages_options: + ~custompollerpager.models.PagingGetMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages.metadata = {'url': '/paging/multiple'} # type: ignore + + def get_with_query_params( + self, + required_query_parameter, # type: int + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + :param required_query_parameter: A required integer query parameter. Put in value '100' to pass + test. + :type required_query_parameter: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_with_query_params_request( + required_query_parameter=required_query_parameter, + template_url=self.get_with_query_params.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_operation_with_query_params_request( + template_url='/paging/multiple/nextOperationWithQueryParams', + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_with_query_params.metadata = {'url': '/paging/multiple/getWithQueryParams'} # type: ignore + + def get_odata_multiple_pages( + self, + client_request_id=None, # type: Optional[str] + paging_get_odata_multiple_pages_options=None, # type: Optional["_models.PagingGetOdataMultiplePagesOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OdataProductResult"] + """A paging operation that includes a nextLink in odata format that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_odata_multiple_pages_options: Parameter group. + :type paging_get_odata_multiple_pages_options: + ~custompollerpager.models.PagingGetOdataMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_odata_multiple_pages.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OdataProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_odata_multiple_pages.metadata = {'url': '/paging/multiple/odata'} # type: ignore + + def get_multiple_pages_with_offset( + self, + paging_get_multiple_pages_with_offset_options, # type: "_models.PagingGetMultiplePagesWithOffsetOptions" + client_request_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a nextLink that has 10 pages. + + :param paging_get_multiple_pages_with_offset_options: Parameter group. + :type paging_get_multiple_pages_with_offset_options: + ~custompollerpager.models.PagingGetMultiplePagesWithOffsetOptions + :param client_request_id: + :type client_request_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages_with_offset.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_with_offset.metadata = {'url': '/paging/multiple/withpath/{offset}'} # type: ignore + + def get_multiple_pages_retry_first( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=self.get_multiple_pages_retry_first.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_retry_first.metadata = {'url': '/paging/multiple/retryfirst'} # type: ignore + + def get_multiple_pages_retry_second( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=self.get_multiple_pages_retry_second.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_retry_second.metadata = {'url': '/paging/multiple/retrysecond'} # type: ignore + + def get_single_pages_failure( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that receives a 400 on the first call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=self.get_single_pages_failure.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_single_pages_failure.metadata = {'url': '/paging/single/failure'} # type: ignore + + def get_multiple_pages_failure( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that receives a 400 on the second call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=self.get_multiple_pages_failure.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_failure.metadata = {'url': '/paging/multiple/failure'} # type: ignore + + def get_multiple_pages_failure_uri( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that receives an invalid nextLink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=self.get_multiple_pages_failure_uri.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_failure_uri.metadata = {'url': '/paging/multiple/failureuri'} # type: ignore + + def get_multiple_pages_fragment_next_link( + self, + api_version, # type: str + tenant, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OdataProductResult"] + """A paging operation that doesn't return a full URL, just a fragment. + + :param api_version: Sets the api version to use. + :type api_version: str + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_fragment_next_link_request( + tenant=tenant, + api_version=api_version, + template_url=self.get_multiple_pages_fragment_next_link.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_fragment_request( + tenant=tenant, + next_link=next_link, + api_version=api_version, + template_url='/paging/multiple/fragment/{tenant}/{nextLink}', + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OdataProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_fragment_next_link.metadata = {'url': '/paging/multiple/fragment/{tenant}'} # type: ignore + + def get_multiple_pages_fragment_with_grouping_next_link( + self, + custom_parameter_group, # type: "_models.CustomParameterGroup" + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OdataProductResult"] + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + :param custom_parameter_group: Parameter group. + :type custom_parameter_group: ~custompollerpager.models.CustomParameterGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custompollerpager.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OdataProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant=_tenant, + api_version=_api_version, + template_url=self.get_multiple_pages_fragment_with_grouping_next_link.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_next_fragment_with_grouping_request( + tenant=_tenant, + next_link=next_link, + api_version=_api_version, + template_url='/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}', + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OdataProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_multiple_pages_fragment_with_grouping_next_link.metadata = {'url': '/paging/multiple/fragmentwithgrouping/{tenant}'} # type: ignore + + def _get_multiple_pages_lro_initial( + self, + client_request_id=None, # type: Optional[str] + paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] + **kwargs # type: Any + ): + # type: (...) -> "_models.ProductResult" + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._get_multiple_pages_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ProductResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _get_multiple_pages_lro_initial.metadata = {'url': '/paging/multiple/lro'} # type: ignore + + + def begin_get_multiple_pages_lro( + self, + client_request_id=None, # type: Optional[str] + paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] + **kwargs # type: Any + ): + # type: (...) -> CustomPoller[ItemPaged["_models.ProductResult"]] + """A long-running paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_lro_options: Parameter group. + :type paging_get_multiple_pages_lro_options: + ~custompollerpager.models.PagingGetMultiplePagesLroOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of CustomPoller that returns an iterator like instance of either + ProductResult or the result of cls(response) + :rtype: + ~custompollerpagerdefinitions.CustomPoller[~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResult]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_get_multiple_pages_lro.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResult', pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._get_multiple_pages_lro_initial( + client_request_id=client_request_id, + paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + def get_long_running_output(pipeline_response): + def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + else: + return get_next(next_link) + + return ItemPaged( + internal_get_next, extract_data + ) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return CustomPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return CustomPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_get_multiple_pages_lro.metadata = {'url': '/paging/multiple/lro'} # type: ignore + + + def get_paging_model_with_item_name_with_xms_client_name( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResultValueWithXMSClientName"] + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~custompollerpager.models.ProductResultValueWithXMSClientName] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=self.get_paging_model_with_item_name_with_xms_client_name.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductResultValueWithXMSClientName', pipeline_response) + list_of_elem = deserialized.indexes + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_paging_model_with_item_name_with_xms_client_name.metadata = {'url': '/paging/itemNameWithXMSClientName'} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/py.typed b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/setup.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/setup.py new file mode 100644 index 00000000000..66e1c1fd927 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/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 = "custompollerpager" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="custompollerpager", + author_email="", + url="", + keywords=["Swagger", "AutoRestPagingTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Long-running Operation for AutoRest. + """ +) diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPagerDefinitions/custompollerpagerdefinitions/aio/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/CustomPollerPagerDefinitions/setup.py b/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPagerDefinitions/setup.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomPollerPagerDefinitions/setup.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomPollerPagerDefinitions/setup.py diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py new file mode 100644 index 00000000000..916e5b8f2a5 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py @@ -0,0 +1,98 @@ +# 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 AutoRestParameterizedHostTestPagingClientConfiguration +from .operations import PagingOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedHostTestPagingClient(object): + """Test Infrastructure for AutoRest. + + :ivar paging: PagingOperations operations + :vartype paging: custombaseurlpaging.operations.PagingOperations + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **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.paging = PagingOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurlpaging.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlpaging._rest import paging + >>> request = paging.build_get_pages_partial_url_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedHostTestPagingClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_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/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/__init__.py new file mode 100644 index 00000000000..2bf67c01227 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/__init__.py @@ -0,0 +1,22 @@ +# 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_get_pages_partial_url_request + from ._request_builders_py3 import build_get_pages_partial_url_operation_request + from ._request_builders_py3 import build_get_pages_partial_url_operation_next_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_pages_partial_url_request # type: ignore + from ._request_builders import build_get_pages_partial_url_operation_request # type: ignore + from ._request_builders import build_get_pages_partial_url_operation_next_request # type: ignore + +__all__ = [ + "build_get_pages_partial_url_request", + "build_get_pages_partial_url_operation_request", + "build_get_pages_partial_url_operation_next_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/_request_builders.py new file mode 100644 index 00000000000..028d0274508 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/_request_builders.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. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_pages_partial_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that combines custom url, paging and partial URL and expect to concat after + host. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/customurl/partialnextlink') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_pages_partial_url_operation_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that combines custom url, paging and partial URL with next operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/customurl/partialnextlinkop') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_pages_partial_url_operation_next_request( + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that combines custom url, paging and partial URL. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param next_link: Next link for the list operation. + :type next_link: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/customurl/{nextLink}') + path_format_arguments = { + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/_request_builders_py3.py new file mode 100644 index 00000000000..1db1b35f5a8 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_rest/paging/_request_builders_py3.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 typing import Any + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_pages_partial_url_request(**kwargs: Any) -> HttpRequest: + """A paging operation that combines custom url, paging and partial URL and expect to concat after + host. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/customurl/partialnextlink") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_pages_partial_url_operation_request(**kwargs: Any) -> HttpRequest: + """A paging operation that combines custom url, paging and partial URL with next operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/customurl/partialnextlinkop") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_pages_partial_url_operation_next_request(next_link: str, **kwargs: Any) -> HttpRequest: + """A paging operation that combines custom url, paging and partial URL. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param next_link: Next link for the list operation. + :type next_link: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/customurl/{nextLink}") + path_format_arguments = { + "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_version.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_version.py diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py new file mode 100644 index 00000000000..319bf714b9c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py @@ -0,0 +1,80 @@ +# 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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestParameterizedHostTestPagingClientConfiguration +from .operations import PagingOperations + + +class AutoRestParameterizedHostTestPagingClient: + """Test Infrastructure for AutoRest. + + :ivar paging: PagingOperations operations + :vartype paging: custombaseurlpaging.aio.operations.PagingOperations + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **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.paging = PagingOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurlpaging.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlpaging._rest import paging + >>> request = paging.build_get_pages_partial_url_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedHostTestPagingClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py new file mode 100644 index 00000000000..859833146d5 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py @@ -0,0 +1,188 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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 import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async + +from ... import models as _models +from ..._rest import paging as rest_paging + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PagingOperations: + """PagingOperations 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: ~custombaseurlpaging.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 + def get_pages_partial_url(self, account_name: str, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that combines custom url, paging and partial URL and expect to concat after + host. + + :param account_name: Account Name. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custombaseurlpaging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_pages_partial_url_request( + template_url=self.get_pages_partial_url.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = rest_paging.build_get_pages_partial_url_request( + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_pages_partial_url.metadata = {"url": "/paging/customurl/partialnextlink"} # type: ignore + + @distributed_trace + def get_pages_partial_url_operation( + self, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that combines custom url, paging and partial URL with next operation. + + :param account_name: Account Name. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~custombaseurlpaging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_pages_partial_url_operation_request( + template_url=self.get_pages_partial_url_operation.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = rest_paging.build_get_pages_partial_url_operation_next_request( + next_link=next_link, + template_url="/paging/customurl/{nextLink}", + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_pages_partial_url_operation.metadata = {"url": "/paging/customurl/partialnextlinkop"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py new file mode 100644 index 00000000000..56215d24169 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py @@ -0,0 +1,199 @@ +# 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.paging import ItemPaged +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 .. import models as _models +from .._rest import paging as rest_paging + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class PagingOperations(object): + """PagingOperations 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: ~custombaseurlpaging.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 get_pages_partial_url( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that combines custom url, paging and partial URL and expect to concat after + host. + + :param account_name: Account Name. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custombaseurlpaging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_pages_partial_url_request( + template_url=self.get_pages_partial_url.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = rest_paging.build_get_pages_partial_url_request( + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_pages_partial_url.metadata = {"url": "/paging/customurl/partialnextlink"} # type: ignore + + @distributed_trace + def get_pages_partial_url_operation( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that combines custom url, paging and partial URL with next operation. + + :param account_name: Account Name. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~custombaseurlpaging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_pages_partial_url_operation_request( + template_url=self.get_pages_partial_url_operation.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = rest_paging.build_get_pages_partial_url_operation_next_request( + next_link=next_link, + template_url="/paging/customurl/{nextLink}", + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_pages_partial_url_operation.metadata = {"url": "/paging/customurl/partialnextlinkop"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/py.typed b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/setup.py b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/setup.py new file mode 100644 index 00000000000..2c57ff3661d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/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 = "autorestparameterizedhosttestpagingclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedHostTestPagingClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedHostTestPagingClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/_auto_rest_head_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_auto_rest_head_test_service.py new file mode 100644 index 00000000000..e95f9fafc2c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_auto_rest_head_test_service.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHeadTestService(object): + """Test Infrastructure for AutoRest. + + :ivar http_success: HttpSuccessOperations operations + :vartype http_success: head.operations.HttpSuccessOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(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. + + We have helper methods to create requests specific to this service in `head.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from head._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHeadTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_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/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/__init__.py new file mode 100644 index 00000000000..5581e44ff36 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_head204_request", + "build_head404_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/_request_builders.py new file mode 100644 index 00000000000..03bcf67f42e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/_request_builders.py @@ -0,0 +1,93 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..2b0f4175d6e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_rest/http_success/_request_builders_py3.py @@ -0,0 +1,67 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + return HttpRequest(method="HEAD", url=url, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/_version.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/_version.py diff --git a/test/azure/Expected/AcceptanceTests/Head/head/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/_auto_rest_head_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/_auto_rest_head_test_service.py new file mode 100644 index 00000000000..df3f9749fc6 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/_auto_rest_head_test_service.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 Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestHeadTestService: + """Test Infrastructure for AutoRest. + + :ivar http_success: HttpSuccessOperations operations + :vartype http_success: head.aio.operations.HttpSuccessOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(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. + + We have helper methods to create requests specific to this service in `head.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from head._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHeadTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Head/head/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/Head/head/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py new file mode 100644 index 00000000000..2169bcb2f96 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/aio/operations/_http_success_operations.py @@ -0,0 +1,146 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ..._rest import http_success as rest_http_success + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpSuccessOperations: + """HttpSuccessOperations 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 head200(self, **kwargs: Any) -> None: + """Return 200 status code if successful. + + :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", {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def head204(self, **kwargs: Any) -> None: + """Return 204 status code if successful. + + :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", {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def head404(self, **kwargs: Any) -> None: + """Return 404 status code if successful. + + :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", {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Head/head/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py new file mode 100644 index 00000000000..356c7193ea2 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/head/operations/_http_success_operations.py @@ -0,0 +1,153 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .._rest import http_success as rest_http_success + +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]] + + +class HttpSuccessOperations(object): + """HttpSuccessOperations 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 head200( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 200 status code if successful. + + :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", {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def head204( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 204 status code if successful. + + :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", {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def head404( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 404 status code if successful. + + :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", {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Head/head/py.typed b/test/azure/legacy/Expected/AcceptanceTests/Head/head/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/Head/head/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/Head/head/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/Head/setup.py b/test/azure/legacy/Expected/AcceptanceTests/Head/setup.py new file mode 100644 index 00000000000..ba5ee762717 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Head/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 = "autorestheadtestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHeadTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHeadTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_auto_rest_head_exception_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_auto_rest_head_exception_test_service.py new file mode 100644 index 00000000000..22eb6a02cd2 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_auto_rest_head_exception_test_service.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadExceptionTestServiceConfiguration +from .operations import HeadExceptionOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHeadExceptionTestService(object): + """Test Infrastructure for AutoRest. + + :ivar head_exception: HeadExceptionOperations operations + :vartype head_exception: headexceptions.operations.HeadExceptionOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadExceptionTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.head_exception = HeadExceptionOperations(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. + + We have helper methods to create requests specific to this service in `headexceptions.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headexceptions._rest import head_exception + >>> request = head_exception.build_head200_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHeadExceptionTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_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/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/__init__.py new file mode 100644 index 00000000000..5581e44ff36 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_head204_request", + "build_head404_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/_request_builders.py new file mode 100644 index 00000000000..03bcf67f42e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/_request_builders.py @@ -0,0 +1,93 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/_request_builders_py3.py new file mode 100644 index 00000000000..2b0f4175d6e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_rest/head_exception/_request_builders_py3.py @@ -0,0 +1,67 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + return HttpRequest(method="HEAD", url=url, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_version.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_version.py diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_auto_rest_head_exception_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_auto_rest_head_exception_test_service.py new file mode 100644 index 00000000000..82c541a8888 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_auto_rest_head_exception_test_service.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 Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadExceptionTestServiceConfiguration +from .operations import HeadExceptionOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestHeadExceptionTestService: + """Test Infrastructure for AutoRest. + + :ivar head_exception: HeadExceptionOperations operations + :vartype head_exception: headexceptions.aio.operations.HeadExceptionOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadExceptionTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.head_exception = HeadExceptionOperations(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. + + We have helper methods to create requests specific to this service in `headexceptions.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headexceptions._rest import head_exception + >>> request = head_exception.build_head200_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHeadExceptionTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py new file mode 100644 index 00000000000..3fdc61c17d3 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/aio/operations/_head_exception_operations.py @@ -0,0 +1,146 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ..._rest import head_exception as rest_head_exception + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HeadExceptionOperations: + """HeadExceptionOperations 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 head200(self, **kwargs: Any) -> None: + """Return 200 status code if successful. + + :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", {})) + + request = rest_head_exception.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def head204(self, **kwargs: Any) -> None: + """Return 204 status code if successful. + + :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", {})) + + request = rest_head_exception.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def head404(self, **kwargs: Any) -> None: + """Return 404 status code if successful. + + :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", {})) + + request = rest_head_exception.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py new file mode 100644 index 00000000000..58735518931 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/operations/_head_exception_operations.py @@ -0,0 +1,153 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .._rest import head_exception as rest_head_exception + +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]] + + +class HeadExceptionOperations(object): + """HeadExceptionOperations 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 head200( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 200 status code if successful. + + :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", {})) + + request = rest_head_exception.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def head204( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 204 status code if successful. + + :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", {})) + + request = rest_head_exception.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def head404( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 404 status code if successful. + + :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", {})) + + request = rest_head_exception.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/py.typed b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadExceptions/headexceptions/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/setup.py b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/setup.py new file mode 100644 index 00000000000..3d86e1ce5fd --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/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 = "autorestheadexceptiontestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHeadExceptionTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHeadExceptionTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_auto_rest_head_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_auto_rest_head_test_service.py new file mode 100644 index 00000000000..58f485c0848 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_auto_rest_head_test_service.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import AzureKeyCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHeadTestService(object): + """Test Infrastructure for AutoRest. + + :ivar http_success: HttpSuccessOperations operations + :vartype http_success: headwithazurekeycredentialpolicy.operations.HttpSuccessOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.AzureKeyCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: AzureKeyCredential + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(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. + + We have helper methods to create requests specific to this service in `headwithazurekeycredentialpolicy.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headwithazurekeycredentialpolicy._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHeadTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_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/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/__init__.py new file mode 100644 index 00000000000..5581e44ff36 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_head204_request", + "build_head404_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/_request_builders.py new file mode 100644 index 00000000000..03bcf67f42e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/_request_builders.py @@ -0,0 +1,93 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..2b0f4175d6e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_rest/http_success/_request_builders_py3.py @@ -0,0 +1,67 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + return HttpRequest(method="HEAD", url=url, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_version.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_version.py diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_auto_rest_head_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_auto_rest_head_test_service.py new file mode 100644 index 00000000000..dab3c14372a --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_auto_rest_head_test_service.py @@ -0,0 +1,84 @@ +# 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.credentials import AzureKeyCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadTestServiceConfiguration +from .operations import HttpSuccessOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestHeadTestService: + """Test Infrastructure for AutoRest. + + :ivar http_success: HttpSuccessOperations operations + :vartype http_success: headwithazurekeycredentialpolicy.aio.operations.HttpSuccessOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.AzureKeyCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, credential: AzureKeyCredential, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.http_success = HttpSuccessOperations(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. + + We have helper methods to create requests specific to this service in `headwithazurekeycredentialpolicy.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headwithazurekeycredentialpolicy._rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHeadTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py new file mode 100644 index 00000000000..2169bcb2f96 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/aio/operations/_http_success_operations.py @@ -0,0 +1,146 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ..._rest import http_success as rest_http_success + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpSuccessOperations: + """HttpSuccessOperations 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 head200(self, **kwargs: Any) -> None: + """Return 200 status code if successful. + + :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", {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def head204(self, **kwargs: Any) -> None: + """Return 204 status code if successful. + + :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", {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def head404(self, **kwargs: Any) -> None: + """Return 404 status code if successful. + + :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", {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py new file mode 100644 index 00000000000..356c7193ea2 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/operations/_http_success_operations.py @@ -0,0 +1,153 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .._rest import http_success as rest_http_success + +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]] + + +class HttpSuccessOperations(object): + """HttpSuccessOperations 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 head200( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 200 status code if successful. + + :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", {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def head204( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 204 status code if successful. + + :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", {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def head404( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 404 status code if successful. + + :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", {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/py.typed b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/setup.py b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/setup.py new file mode 100644 index 00000000000..ba5ee762717 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/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 = "autorestheadtestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHeadTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHeadTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_auto_rest_long_running_operation_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_auto_rest_long_running_operation_test_service.py new file mode 100644 index 00000000000..1e4850f6a33 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_auto_rest_long_running_operation_test_service.py @@ -0,0 +1,113 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import AutoRestLongRunningOperationTestServiceConfiguration +from .operations import LRORetrysOperations, LROSADsOperations, LROsCustomHeaderOperations, LROsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestLongRunningOperationTestService(object): + """Long-running Operation for AutoRest. + + :ivar lros: LROsOperations operations + :vartype lros: lro.operations.LROsOperations + :ivar lro_retrys: LRORetrysOperations operations + :vartype lro_retrys: lro.operations.LRORetrysOperations + :ivar lrosads: LROSADsOperations operations + :vartype lrosads: lro.operations.LROSADsOperations + :ivar lr_os_custom_header: LROsCustomHeaderOperations operations + :vartype lr_os_custom_header: lro.operations.LROsCustomHeaderOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestLongRunningOperationTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(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.lros = LROsOperations(self._client, self._config, self._serialize, self._deserialize) + self.lro_retrys = LRORetrysOperations(self._client, self._config, self._serialize, self._deserialize) + self.lrosads = LROSADsOperations(self._client, self._config, self._serialize, self._deserialize) + self.lr_os_custom_header = LROsCustomHeaderOperations( + 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. + + We have helper methods to create requests specific to this service in `lro.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lro._rest import lros + >>> request = lros.build_put200_succeeded_request_initial(json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestLongRunningOperationTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_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/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/__init__.py new file mode 100644 index 00000000000..1530fce16f0 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/__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 ._request_builders_py3 import build_put_async_retry_succeeded_request_initial + from ._request_builders_py3 import build_put201_creating_succeeded200_request_initial + from ._request_builders_py3 import build_post202_retry200_request_initial + from ._request_builders_py3 import build_post_async_retry_succeeded_request_initial +except (SyntaxError, ImportError): + from ._request_builders import build_put_async_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_put201_creating_succeeded200_request_initial # type: ignore + from ._request_builders import build_post202_retry200_request_initial # type: ignore + from ._request_builders import build_post_async_retry_succeeded_request_initial # type: ignore + +__all__ = [ + "build_put_async_retry_succeeded_request_initial", + "build_put201_creating_succeeded200_request_initial", + "build_post202_retry200_request_initial", + "build_post_async_retry_succeeded_request_initial", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/_request_builders.py new file mode 100644 index 00000000000..57460903dc9 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/_request_builders.py @@ -0,0 +1,193 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_async_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/putasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_creating_succeeded200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/put/201/creating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/post/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/postasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/_request_builders_py3.py new file mode 100644 index 00000000000..9f9622acb85 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lr_os_custom_header/_request_builders_py3.py @@ -0,0 +1,162 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_async_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/putasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_creating_succeeded200_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/put/201/creating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_retry200_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/post/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/postasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/__init__.py new file mode 100644 index 00000000000..627bb5ff689 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/__init__.py @@ -0,0 +1,34 @@ +# 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_put201_creating_succeeded200_request_initial + from ._request_builders_py3 import build_put_async_relative_retry_succeeded_request_initial + from ._request_builders_py3 import build_delete_provisioning202_accepted200_succeeded_request_initial + from ._request_builders_py3 import build_delete202_retry200_request_initial + from ._request_builders_py3 import build_delete_async_relative_retry_succeeded_request_initial + from ._request_builders_py3 import build_post202_retry200_request_initial + from ._request_builders_py3 import build_post_async_relative_retry_succeeded_request_initial +except (SyntaxError, ImportError): + from ._request_builders import build_put201_creating_succeeded200_request_initial # type: ignore + from ._request_builders import build_put_async_relative_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_delete_provisioning202_accepted200_succeeded_request_initial # type: ignore + from ._request_builders import build_delete202_retry200_request_initial # type: ignore + from ._request_builders import build_delete_async_relative_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_post202_retry200_request_initial # type: ignore + from ._request_builders import build_post_async_relative_retry_succeeded_request_initial # type: ignore + +__all__ = [ + "build_put201_creating_succeeded200_request_initial", + "build_put_async_relative_retry_succeeded_request_initial", + "build_delete_provisioning202_accepted200_succeeded_request_initial", + "build_delete202_retry200_request_initial", + "build_delete_async_relative_retry_succeeded_request_initial", + "build_post202_retry200_request_initial", + "build_post_async_relative_retry_succeeded_request_initial", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/_request_builders.py new file mode 100644 index 00000000000..447625c0701 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/_request_builders.py @@ -0,0 +1,286 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put201_creating_succeeded200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 500, then a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/put/201/creating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 500, then a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/putasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_accepted200_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/delete/provisioning/202/accepted/200/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_retry200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 500, then a 202 to the initial request. Polls + return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/delete/202/retry/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/deleteasync/retry/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 500, then a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/post/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/postasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/_request_builders_py3.py new file mode 100644 index 00000000000..bffb13c58ef --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lro_retrys/_request_builders_py3.py @@ -0,0 +1,231 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put201_creating_succeeded200_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 500, then a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/put/201/creating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 500, then a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/putasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete_provisioning202_accepted200_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_retry200_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 500, then a 202 to the initial request. Polls + return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/delete/202/retry/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/deleteasync/retry/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post202_retry200_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 500, then a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/post/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/postasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/__init__.py new file mode 100644 index 00000000000..5ebaba480a7 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/__init__.py @@ -0,0 +1,136 @@ +# 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_put200_succeeded_request_initial + from ._request_builders_py3 import build_put201_succeeded_request_initial + from ._request_builders_py3 import build_post202_list_request_initial + from ._request_builders_py3 import build_put200_succeeded_no_state_request_initial + from ._request_builders_py3 import build_put202_retry200_request_initial + from ._request_builders_py3 import build_put201_creating_succeeded200_request_initial + from ._request_builders_py3 import build_put200_updating_succeeded204_request_initial + from ._request_builders_py3 import build_put201_creating_failed200_request_initial + from ._request_builders_py3 import build_put200_acceptedcanceled200_request_initial + from ._request_builders_py3 import build_put_no_header_in_retry_request_initial + from ._request_builders_py3 import build_put_async_retry_succeeded_request_initial + from ._request_builders_py3 import build_put_async_no_retry_succeeded_request_initial + from ._request_builders_py3 import build_put_async_retry_failed_request_initial + from ._request_builders_py3 import build_put_async_no_retrycanceled_request_initial + from ._request_builders_py3 import build_put_async_no_header_in_retry_request_initial + from ._request_builders_py3 import build_put_non_resource_request_initial + from ._request_builders_py3 import build_put_async_non_resource_request_initial + from ._request_builders_py3 import build_put_sub_resource_request_initial + from ._request_builders_py3 import build_put_async_sub_resource_request_initial + from ._request_builders_py3 import build_delete_provisioning202_accepted200_succeeded_request_initial + from ._request_builders_py3 import build_delete_provisioning202_deleting_failed200_request_initial + from ._request_builders_py3 import build_delete_provisioning202_deletingcanceled200_request_initial + from ._request_builders_py3 import build_delete204_succeeded_request_initial + from ._request_builders_py3 import build_delete202_retry200_request_initial + from ._request_builders_py3 import build_delete202_no_retry204_request_initial + from ._request_builders_py3 import build_delete_no_header_in_retry_request_initial + from ._request_builders_py3 import build_delete_async_no_header_in_retry_request_initial + from ._request_builders_py3 import build_delete_async_retry_succeeded_request_initial + from ._request_builders_py3 import build_delete_async_no_retry_succeeded_request_initial + from ._request_builders_py3 import build_delete_async_retry_failed_request_initial + from ._request_builders_py3 import build_delete_async_retrycanceled_request_initial + from ._request_builders_py3 import build_post200_with_payload_request_initial + from ._request_builders_py3 import build_post202_retry200_request_initial + from ._request_builders_py3 import build_post202_no_retry204_request_initial + from ._request_builders_py3 import build_post_double_headers_final_location_get_request_initial + from ._request_builders_py3 import build_post_double_headers_final_azure_header_get_request_initial + from ._request_builders_py3 import build_post_double_headers_final_azure_header_get_default_request_initial + from ._request_builders_py3 import build_post_async_retry_succeeded_request_initial + from ._request_builders_py3 import build_post_async_no_retry_succeeded_request_initial + from ._request_builders_py3 import build_post_async_retry_failed_request_initial + from ._request_builders_py3 import build_post_async_retrycanceled_request_initial +except (SyntaxError, ImportError): + from ._request_builders import build_put200_succeeded_request_initial # type: ignore + from ._request_builders import build_put201_succeeded_request_initial # type: ignore + from ._request_builders import build_post202_list_request_initial # type: ignore + from ._request_builders import build_put200_succeeded_no_state_request_initial # type: ignore + from ._request_builders import build_put202_retry200_request_initial # type: ignore + from ._request_builders import build_put201_creating_succeeded200_request_initial # type: ignore + from ._request_builders import build_put200_updating_succeeded204_request_initial # type: ignore + from ._request_builders import build_put201_creating_failed200_request_initial # type: ignore + from ._request_builders import build_put200_acceptedcanceled200_request_initial # type: ignore + from ._request_builders import build_put_no_header_in_retry_request_initial # type: ignore + from ._request_builders import build_put_async_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_put_async_no_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_put_async_retry_failed_request_initial # type: ignore + from ._request_builders import build_put_async_no_retrycanceled_request_initial # type: ignore + from ._request_builders import build_put_async_no_header_in_retry_request_initial # type: ignore + from ._request_builders import build_put_non_resource_request_initial # type: ignore + from ._request_builders import build_put_async_non_resource_request_initial # type: ignore + from ._request_builders import build_put_sub_resource_request_initial # type: ignore + from ._request_builders import build_put_async_sub_resource_request_initial # type: ignore + from ._request_builders import build_delete_provisioning202_accepted200_succeeded_request_initial # type: ignore + from ._request_builders import build_delete_provisioning202_deleting_failed200_request_initial # type: ignore + from ._request_builders import build_delete_provisioning202_deletingcanceled200_request_initial # type: ignore + from ._request_builders import build_delete204_succeeded_request_initial # type: ignore + from ._request_builders import build_delete202_retry200_request_initial # type: ignore + from ._request_builders import build_delete202_no_retry204_request_initial # type: ignore + from ._request_builders import build_delete_no_header_in_retry_request_initial # type: ignore + from ._request_builders import build_delete_async_no_header_in_retry_request_initial # type: ignore + from ._request_builders import build_delete_async_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_delete_async_no_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_delete_async_retry_failed_request_initial # type: ignore + from ._request_builders import build_delete_async_retrycanceled_request_initial # type: ignore + from ._request_builders import build_post200_with_payload_request_initial # type: ignore + from ._request_builders import build_post202_retry200_request_initial # type: ignore + from ._request_builders import build_post202_no_retry204_request_initial # type: ignore + from ._request_builders import build_post_double_headers_final_location_get_request_initial # type: ignore + from ._request_builders import build_post_double_headers_final_azure_header_get_request_initial # type: ignore + from ._request_builders import build_post_double_headers_final_azure_header_get_default_request_initial # type: ignore + from ._request_builders import build_post_async_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_post_async_no_retry_succeeded_request_initial # type: ignore + from ._request_builders import build_post_async_retry_failed_request_initial # type: ignore + from ._request_builders import build_post_async_retrycanceled_request_initial # type: ignore + +__all__ = [ + "build_put200_succeeded_request_initial", + "build_put201_succeeded_request_initial", + "build_post202_list_request_initial", + "build_put200_succeeded_no_state_request_initial", + "build_put202_retry200_request_initial", + "build_put201_creating_succeeded200_request_initial", + "build_put200_updating_succeeded204_request_initial", + "build_put201_creating_failed200_request_initial", + "build_put200_acceptedcanceled200_request_initial", + "build_put_no_header_in_retry_request_initial", + "build_put_async_retry_succeeded_request_initial", + "build_put_async_no_retry_succeeded_request_initial", + "build_put_async_retry_failed_request_initial", + "build_put_async_no_retrycanceled_request_initial", + "build_put_async_no_header_in_retry_request_initial", + "build_put_non_resource_request_initial", + "build_put_async_non_resource_request_initial", + "build_put_sub_resource_request_initial", + "build_put_async_sub_resource_request_initial", + "build_delete_provisioning202_accepted200_succeeded_request_initial", + "build_delete_provisioning202_deleting_failed200_request_initial", + "build_delete_provisioning202_deletingcanceled200_request_initial", + "build_delete204_succeeded_request_initial", + "build_delete202_retry200_request_initial", + "build_delete202_no_retry204_request_initial", + "build_delete_no_header_in_retry_request_initial", + "build_delete_async_no_header_in_retry_request_initial", + "build_delete_async_retry_succeeded_request_initial", + "build_delete_async_no_retry_succeeded_request_initial", + "build_delete_async_retry_failed_request_initial", + "build_delete_async_retrycanceled_request_initial", + "build_post200_with_payload_request_initial", + "build_post202_retry200_request_initial", + "build_post202_no_retry204_request_initial", + "build_post_double_headers_final_location_get_request_initial", + "build_post_double_headers_final_azure_header_get_request_initial", + "build_post_double_headers_final_azure_header_get_default_request_initial", + "build_post_async_retry_succeeded_request_initial", + "build_post_async_no_retry_succeeded_request_initial", + "build_post_async_retry_failed_request_initial", + "build_post_async_retrycanceled_request_initial", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/_request_builders.py new file mode 100644 index 00000000000..58812f97d43 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/_request_builders.py @@ -0,0 +1,1585 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put200_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/201/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_list_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 with empty body to first request, returns a 200 + with body [{ 'id': '100', 'name': 'foo' }]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_succeeded_no_state_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + does not contain ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/succeeded/nostate') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put202_retry200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 to the initial request, with a location header + that points to a polling URL that returns a 200 and an entity that doesn't contains + ProvisioningState. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_creating_succeeded200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/201/creating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_updating_succeeded204_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/updating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_creating_failed200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Created’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/201/created/failed/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_acceptedcanceled200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/accepted/canceled/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_no_header_in_retry_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 to the initial request with location header. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/noheader/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_no_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/noretry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_retry_failed_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/retry/failed') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_no_retrycanceled_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/noretry/canceled') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_no_header_in_retry_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 to the initial request with + Azure-AsyncOperation header. Subsequent calls to operation status do not contain + Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/noheader/201/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_resource_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). sku to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putnonresource/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_non_resource_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sku to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putnonresourceasync/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_sub_resource_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putsubresource/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_sub_resource_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putsubresourceasync/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_accepted200_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/provisioning/202/accepted/200/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_deleting_failed200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/provisioning/202/deleting/200/failed') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_deletingcanceled200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/provisioning/202/deleting/200/canceled') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete204_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete succeeds and returns right away. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/204/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_retry200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/202/retry/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_no_retry204_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/202/noretry/204') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_no_header_in_retry_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a location header in the initial request. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/noheader') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_no_header_in_retry_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns an Azure-AsyncOperation header in the initial + request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/noheader/202/204') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/retry/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_no_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/noretry/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_retry_failed_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/retry/failed') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_retrycanceled_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/retry/canceled') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post200_with_payload_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with 'Location' + header. Poll returns a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/post/payload/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry200_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with 'Location' and + 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/post/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_no_retry204_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with 'Location' + header, 204 with noresponse body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/post/202/noretry/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_double_headers_final_location_get_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final + object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/LROPostDoubleHeadersFinalLocationGet') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_double_headers_final_azure_header_get_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/LROPostDoubleHeadersFinalAzureHeaderGet') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_double_headers_final_azure_header_get_default_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object if you support initial Autorest behavior. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_no_retry_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/noretry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retry_failed_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/retry/failed') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retrycanceled_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/retry/canceled') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/_request_builders_py3.py new file mode 100644 index 00000000000..7a7b2d62449 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lros/_request_builders_py3.py @@ -0,0 +1,1286 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put200_succeeded_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_succeeded_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/201/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_list_request_initial(**kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 202 with empty body to first request, returns a 200 + with body [{ 'id': '100', 'name': 'foo' }]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_put200_succeeded_no_state_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + does not contain ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/succeeded/nostate") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put202_retry200_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 202 to the initial request, with a location header + that points to a polling URL that returns a 200 and an entity that doesn't contains + ProvisioningState. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_creating_succeeded200_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/201/creating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put200_updating_succeeded204_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/updating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_creating_failed200_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Created’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/201/created/failed/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put200_acceptedcanceled200_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/accepted/canceled/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_no_header_in_retry_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 202 to the initial request with location header. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/noheader/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_no_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/noretry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_retry_failed_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/retry/failed") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_no_retrycanceled_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/noretry/canceled") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_no_header_in_retry_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 202 to the initial request with + Azure-AsyncOperation header. Subsequent calls to operation status do not contain + Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/noheader/201/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_non_resource_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). sku to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putnonresource/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_non_resource_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sku to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putnonresourceasync/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_sub_resource_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putsubresource/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_sub_resource_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putsubresourceasync/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete_provisioning202_accepted200_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/provisioning/202/accepted/200/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_provisioning202_deleting_failed200_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/provisioning/202/deleting/200/failed") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_provisioning202_deletingcanceled200_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/provisioning/202/deleting/200/canceled") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete204_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete succeeds and returns right away. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/204/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_retry200_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/202/retry/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_no_retry204_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/202/noretry/204") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_no_header_in_retry_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a location header in the initial request. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/noheader") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_no_header_in_retry_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns an Azure-AsyncOperation header in the initial + request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/noheader/202/204") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_retry_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/retry/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_no_retry_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/noretry/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_retry_failed_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/retry/failed") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_retrycanceled_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/retry/canceled") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post200_with_payload_request_initial(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with 'Location' + header. Poll returns a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/post/payload/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post202_retry200_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with 'Location' and + 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/post/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_no_retry204_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with 'Location' + header, 204 with noresponse body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/post/202/noretry/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_double_headers_final_location_get_request_initial(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final + object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/LROPostDoubleHeadersFinalLocationGet") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_double_headers_final_azure_header_get_request_initial(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/LROPostDoubleHeadersFinalAzureHeaderGet") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_double_headers_final_azure_header_get_default_request_initial(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object if you support initial Autorest behavior. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_async_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_no_retry_succeeded_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/noretry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_retry_failed_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/retry/failed") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_retrycanceled_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/retry/canceled") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/__init__.py new file mode 100644 index 00000000000..2188ce60ebc --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/__init__.py @@ -0,0 +1,91 @@ +# 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_put_non_retry400_request_initial + from ._request_builders_py3 import build_put_non_retry201_creating400_request_initial + from ._request_builders_py3 import build_put_non_retry201_creating400_invalid_json_request_initial + from ._request_builders_py3 import build_put_async_relative_retry400_request_initial + from ._request_builders_py3 import build_delete_non_retry400_request_initial + from ._request_builders_py3 import build_delete202_non_retry400_request_initial + from ._request_builders_py3 import build_delete_async_relative_retry400_request_initial + from ._request_builders_py3 import build_post_non_retry400_request_initial + from ._request_builders_py3 import build_post202_non_retry400_request_initial + from ._request_builders_py3 import build_post_async_relative_retry400_request_initial + from ._request_builders_py3 import build_put_error201_no_provisioning_state_payload_request_initial + from ._request_builders_py3 import build_put_async_relative_retry_no_status_request_initial + from ._request_builders_py3 import build_put_async_relative_retry_no_status_payload_request_initial + from ._request_builders_py3 import build_delete204_succeeded_request_initial + from ._request_builders_py3 import build_delete_async_relative_retry_no_status_request_initial + from ._request_builders_py3 import build_post202_no_location_request_initial + from ._request_builders_py3 import build_post_async_relative_retry_no_payload_request_initial + from ._request_builders_py3 import build_put200_invalid_json_request_initial + from ._request_builders_py3 import build_put_async_relative_retry_invalid_header_request_initial + from ._request_builders_py3 import build_put_async_relative_retry_invalid_json_polling_request_initial + from ._request_builders_py3 import build_delete202_retry_invalid_header_request_initial + from ._request_builders_py3 import build_delete_async_relative_retry_invalid_header_request_initial + from ._request_builders_py3 import build_delete_async_relative_retry_invalid_json_polling_request_initial + from ._request_builders_py3 import build_post202_retry_invalid_header_request_initial + from ._request_builders_py3 import build_post_async_relative_retry_invalid_header_request_initial + from ._request_builders_py3 import build_post_async_relative_retry_invalid_json_polling_request_initial +except (SyntaxError, ImportError): + from ._request_builders import build_put_non_retry400_request_initial # type: ignore + from ._request_builders import build_put_non_retry201_creating400_request_initial # type: ignore + from ._request_builders import build_put_non_retry201_creating400_invalid_json_request_initial # type: ignore + from ._request_builders import build_put_async_relative_retry400_request_initial # type: ignore + from ._request_builders import build_delete_non_retry400_request_initial # type: ignore + from ._request_builders import build_delete202_non_retry400_request_initial # type: ignore + from ._request_builders import build_delete_async_relative_retry400_request_initial # type: ignore + from ._request_builders import build_post_non_retry400_request_initial # type: ignore + from ._request_builders import build_post202_non_retry400_request_initial # type: ignore + from ._request_builders import build_post_async_relative_retry400_request_initial # type: ignore + from ._request_builders import build_put_error201_no_provisioning_state_payload_request_initial # type: ignore + from ._request_builders import build_put_async_relative_retry_no_status_request_initial # type: ignore + from ._request_builders import build_put_async_relative_retry_no_status_payload_request_initial # type: ignore + from ._request_builders import build_delete204_succeeded_request_initial # type: ignore + from ._request_builders import build_delete_async_relative_retry_no_status_request_initial # type: ignore + from ._request_builders import build_post202_no_location_request_initial # type: ignore + from ._request_builders import build_post_async_relative_retry_no_payload_request_initial # type: ignore + from ._request_builders import build_put200_invalid_json_request_initial # type: ignore + from ._request_builders import build_put_async_relative_retry_invalid_header_request_initial # type: ignore + from ._request_builders import build_put_async_relative_retry_invalid_json_polling_request_initial # type: ignore + from ._request_builders import build_delete202_retry_invalid_header_request_initial # type: ignore + from ._request_builders import build_delete_async_relative_retry_invalid_header_request_initial # type: ignore + from ._request_builders import build_delete_async_relative_retry_invalid_json_polling_request_initial # type: ignore + from ._request_builders import build_post202_retry_invalid_header_request_initial # type: ignore + from ._request_builders import build_post_async_relative_retry_invalid_header_request_initial # type: ignore + from ._request_builders import build_post_async_relative_retry_invalid_json_polling_request_initial # type: ignore + +__all__ = [ + "build_put_non_retry400_request_initial", + "build_put_non_retry201_creating400_request_initial", + "build_put_non_retry201_creating400_invalid_json_request_initial", + "build_put_async_relative_retry400_request_initial", + "build_delete_non_retry400_request_initial", + "build_delete202_non_retry400_request_initial", + "build_delete_async_relative_retry400_request_initial", + "build_post_non_retry400_request_initial", + "build_post202_non_retry400_request_initial", + "build_post_async_relative_retry400_request_initial", + "build_put_error201_no_provisioning_state_payload_request_initial", + "build_put_async_relative_retry_no_status_request_initial", + "build_put_async_relative_retry_no_status_payload_request_initial", + "build_delete204_succeeded_request_initial", + "build_delete_async_relative_retry_no_status_request_initial", + "build_post202_no_location_request_initial", + "build_post_async_relative_retry_no_payload_request_initial", + "build_put200_invalid_json_request_initial", + "build_put_async_relative_retry_invalid_header_request_initial", + "build_put_async_relative_retry_invalid_json_polling_request_initial", + "build_delete202_retry_invalid_header_request_initial", + "build_delete_async_relative_retry_invalid_header_request_initial", + "build_delete_async_relative_retry_invalid_json_polling_request_initial", + "build_post202_retry_invalid_header_request_initial", + "build_post_async_relative_retry_invalid_header_request_initial", + "build_post_async_relative_retry_invalid_json_polling_request_initial", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/_request_builders.py new file mode 100644 index 00000000000..03509013516 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/_request_builders.py @@ -0,0 +1,1030 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_non_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 400 to the initial request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/put/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_retry201_creating400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/put/201/creating/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_retry201_creating400_invalid_json_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/put/201/creating/400/invalidjson') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/putasync/retry/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_non_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 400 with an error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/delete/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_non_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/delete/202/retry/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/deleteasync/retry/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_non_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 400 with no error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/post/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_non_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/post/202/retry/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry400_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/postasync/retry/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_error201_no_provisioning_state_payload_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/put/201/noprovisioningstatepayload') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_no_status_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/nostatus') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_no_status_payload_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/nostatuspayload') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete204_succeeded_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 204 to the initial request, indicating success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/delete/204/nolocation') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_no_status_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/deleteasync/retry/nostatus') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_no_location_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, without a location + header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/post/202/nolocation') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_no_payload_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/postasync/retry/nopayload') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_invalid_json_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that is + not a valid json. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/put/200/invalidjson') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_invalid_header_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/invalidheader') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_invalid_json_polling_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/invalidjsonpolling') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_retry_invalid_header_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request receing a reponse + with an invalid 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/delete/202/retry/invalidheader') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_invalid_header_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. The endpoint + indicated in the Azure-AsyncOperation header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/deleteasync/retry/invalidheader') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_invalid_json_polling_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/deleteasync/retry/invalidjsonpolling') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry_invalid_header_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with invalid + 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/post/202/retry/invalidheader') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_invalid_header_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/postasync/retry/invalidheader') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_invalid_json_polling_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/postasync/retry/invalidjsonpolling') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/_request_builders_py3.py new file mode 100644 index 00000000000..6c160ba2f70 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_rest/lrosads/_request_builders_py3.py @@ -0,0 +1,843 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_non_retry400_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 400 to the initial request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/put/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_non_retry201_creating400_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/put/201/creating/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_non_retry201_creating400_invalid_json_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/put/201/creating/400/invalidjson") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry400_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/putasync/retry/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete_non_retry400_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 400 with an error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/delete/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_non_retry400_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/delete/202/retry/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry400_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/deleteasync/retry/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post_non_retry400_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 400 with no error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/post/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_non_retry400_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/post/202/retry/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry400_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/postasync/retry/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_error201_no_provisioning_state_payload_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/put/201/noprovisioningstatepayload") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_no_status_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/nostatus") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_no_status_payload_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/nostatuspayload") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete204_succeeded_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 204 to the initial request, indicating success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/delete/204/nolocation") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_no_status_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/deleteasync/retry/nostatus") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post202_no_location_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, without a location + header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/post/202/nolocation") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_no_payload_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/postasync/retry/nopayload") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put200_invalid_json_request_initial(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that is + not a valid json. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/put/200/invalidjson") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_invalid_header_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/invalidheader") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_invalid_json_polling_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/invalidjsonpolling") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete202_retry_invalid_header_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request receing a reponse + with an invalid 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/delete/202/retry/invalidheader") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_invalid_header_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. The endpoint + indicated in the Azure-AsyncOperation header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/deleteasync/retry/invalidheader") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_invalid_json_polling_request_initial(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/deleteasync/retry/invalidjsonpolling") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post202_retry_invalid_header_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with invalid + 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/post/202/retry/invalidheader") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_invalid_header_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/postasync/retry/invalidheader") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_invalid_json_polling_request_initial( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/postasync/retry/invalidjsonpolling") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/_version.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_version.py diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_auto_rest_long_running_operation_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_auto_rest_long_running_operation_test_service.py new file mode 100644 index 00000000000..8080f9bac2a --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_auto_rest_long_running_operation_test_service.py @@ -0,0 +1,97 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestLongRunningOperationTestServiceConfiguration +from .operations import LRORetrysOperations, LROSADsOperations, LROsCustomHeaderOperations, LROsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestLongRunningOperationTestService: + """Long-running Operation for AutoRest. + + :ivar lros: LROsOperations operations + :vartype lros: lro.aio.operations.LROsOperations + :ivar lro_retrys: LRORetrysOperations operations + :vartype lro_retrys: lro.aio.operations.LRORetrysOperations + :ivar lrosads: LROSADsOperations operations + :vartype lrosads: lro.aio.operations.LROSADsOperations + :ivar lr_os_custom_header: LROsCustomHeaderOperations operations + :vartype lr_os_custom_header: lro.aio.operations.LROsCustomHeaderOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestLongRunningOperationTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(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.lros = LROsOperations(self._client, self._config, self._serialize, self._deserialize) + self.lro_retrys = LRORetrysOperations(self._client, self._config, self._serialize, self._deserialize) + self.lrosads = LROSADsOperations(self._client, self._config, self._serialize, self._deserialize) + self.lr_os_custom_header = LROsCustomHeaderOperations( + 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. + + We have helper methods to create requests specific to this service in `lro.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lro._rest import lros + >>> request = lros.build_put200_succeeded_request_initial(json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestLongRunningOperationTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py new file mode 100644 index 00000000000..786ccfb6263 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lr_os_custom_header_operations.py @@ -0,0 +1,462 @@ +# 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._rest import lr_os_custom_header as rest_lr_os_custom_header + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LROsCustomHeaderOperations: + """LROsCustomHeaderOperations 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: ~lro.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 + + async def _put_async_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_put_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_put_async_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_retry_succeeded.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore + + async def _put201_creating_succeeded200_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_put201_creating_succeeded200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_succeeded200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_succeeded200_initial.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore + + @distributed_trace_async + async def begin_put201_creating_succeeded200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put201_creating_succeeded200_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_succeeded200.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore + + async def _post202_retry200_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_post202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry200_initial.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore + + @distributed_trace_async + async def begin_post202_retry200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry200.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore + + async def _post_async_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_post_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_post_async_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retry_succeeded.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py new file mode 100644 index 00000000000..1261b529aea --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lro_retrys_operations.py @@ -0,0 +1,712 @@ +# 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._rest import lro_retrys as rest_lro_retrys + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LRORetrysOperations: + """LRORetrysOperations 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: ~lro.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 + + async def _put201_creating_succeeded200_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_put201_creating_succeeded200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_succeeded200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_succeeded200_initial.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore + + @distributed_trace_async + async def begin_put201_creating_succeeded200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 500, then a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put201_creating_succeeded200_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_succeeded200.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore + + async def _put_async_relative_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_put_async_relative_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_put_async_relative_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 500, then a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_relative_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore + + async def _delete_provisioning202_accepted200_succeeded_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lro_retrys.build_delete_provisioning202_accepted200_succeeded_request_initial( + template_url=self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_delete_provisioning202_accepted200_succeeded( + self, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running delete request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_provisioning202_accepted200_succeeded_initial( + cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + async def _delete202_retry200_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lro_retrys.build_delete202_retry200_request_initial( + template_url=self._delete202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete202_retry200_initial.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore + + @distributed_trace_async + async def begin_delete202_retry200(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 500, then a 202 to the initial request. Polls + return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_retry200.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore + + async def _delete_async_relative_retry_succeeded_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lro_retrys.build_delete_async_relative_retry_succeeded_request_initial( + template_url=self._delete_async_relative_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_relative_retry_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_relative_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore + + async def _post202_retry200_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_post202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry200_initial.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore + + @distributed_trace_async + async def begin_post202_retry200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 500, then a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry200.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore + + async def _post_async_relative_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_post_async_relative_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_post_async_relative_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_relative_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py new file mode 100644 index 00000000000..35b4efcbcda --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lros_operations.py @@ -0,0 +1,3941 @@ +# 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, List, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._rest import lros as rest_lros + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LROsOperations: + """LROsOperations 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: ~lro.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 + + async def _put200_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> Optional["_models.Product"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_succeeded_initial.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_put200_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put200_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_succeeded.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore + + async def _put201_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put201_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_succeeded_initial.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_put201_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put201_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_succeeded.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore + + async def _post202_list_initial(self, **kwargs: Any) -> Optional[List["_models.Product"]]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional[List["_models.Product"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post202_list_request_initial( + template_url=self._post202_list_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("[Product]", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post202_list_initial.metadata = {"url": "/lro/list"} # type: ignore + + @distributed_trace_async + async def begin_post202_list(self, **kwargs: Any) -> AsyncLROPoller[List["_models.Product"]]: + """Long running put request, service returns a 202 with empty body to first request, returns a 200 + with body [{ 'id': '100', 'name': 'foo' }]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either list of Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[list[~lro.models.Product]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_list_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_list.metadata = {"url": "/lro/list"} # type: ignore + + async def _put200_succeeded_no_state_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_succeeded_no_state_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_succeeded_no_state_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_succeeded_no_state_initial.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore + + @distributed_trace_async + async def begin_put200_succeeded_no_state( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + does not contain ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put200_succeeded_no_state_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_succeeded_no_state.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore + + async def _put202_retry200_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._put202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put202_retry200_initial.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore + + @distributed_trace_async + async def begin_put202_retry200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 202 to the initial request, with a location header + that points to a polling URL that returns a 200 and an entity that doesn't contains + ProvisioningState. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put202_retry200.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore + + async def _put201_creating_succeeded200_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put201_creating_succeeded200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_succeeded200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_succeeded200_initial.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore + + @distributed_trace_async + async def begin_put201_creating_succeeded200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put201_creating_succeeded200_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_succeeded200.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore + + async def _put200_updating_succeeded204_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_updating_succeeded204_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_updating_succeeded204_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_updating_succeeded204_initial.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore + + @distributed_trace_async + async def begin_put200_updating_succeeded204( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put200_updating_succeeded204_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_updating_succeeded204.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore + + async def _put201_creating_failed200_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put201_creating_failed200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_failed200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_failed200_initial.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore + + @distributed_trace_async + async def begin_put201_creating_failed200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Created’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put201_creating_failed200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_failed200.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore + + async def _put200_acceptedcanceled200_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_acceptedcanceled200_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_acceptedcanceled200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_acceptedcanceled200_initial.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore + + @distributed_trace_async + async def begin_put200_acceptedcanceled200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put200_acceptedcanceled200_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_acceptedcanceled200.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore + + async def _put_no_header_in_retry_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_no_header_in_retry_request_initial( + content_type=content_type, + json=json, + template_url=self._put_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_no_header_in_retry_initial.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore + + @distributed_trace_async + async def begin_put_no_header_in_retry( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 202 to the initial request with location header. + Subsequent calls to operation status do not contain location header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_no_header_in_retry_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_no_header_in_retry.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore + + async def _put_async_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_retry_succeeded_initial.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_put_async_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_retry_succeeded.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore + + async def _put_async_no_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_no_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_no_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_no_retry_succeeded_initial.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_put_async_no_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_no_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_no_retry_succeeded.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore + + async def _put_async_retry_failed_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_retry_failed_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_retry_failed_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_retry_failed_initial.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore + + @distributed_trace_async + async def begin_put_async_retry_failed( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_retry_failed.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore + + async def _put_async_no_retrycanceled_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_no_retrycanceled_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_no_retrycanceled_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_no_retrycanceled_initial.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore + + @distributed_trace_async + async def begin_put_async_no_retrycanceled( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_no_retrycanceled_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_no_retrycanceled.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore + + async def _put_async_no_header_in_retry_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_no_header_in_retry_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_no_header_in_retry_initial.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore + + @distributed_trace_async + async def begin_put_async_no_header_in_retry( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 202 to the initial request with + Azure-AsyncOperation header. Subsequent calls to operation status do not contain + Azure-AsyncOperation header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_no_header_in_retry_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_no_header_in_retry.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore + + async def _put_non_resource_initial(self, sku: Optional["_models.Sku"] = None, **kwargs: Any) -> "_models.Sku": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if sku is not None: + json = self._serialize.body(sku, "Sku") + else: + json = None + + request = rest_lros.build_put_non_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_resource_initial.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore + + @distributed_trace_async + async def begin_put_non_resource( + self, sku: Optional["_models.Sku"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Sku"]: + """Long running put request with non resource. + + :param sku: sku to put. + :type sku: ~lro.models.Sku + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Sku or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Sku] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_resource.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore + + async def _put_async_non_resource_initial( + self, sku: Optional["_models.Sku"] = None, **kwargs: Any + ) -> "_models.Sku": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if sku is not None: + json = self._serialize.body(sku, "Sku") + else: + json = None + + request = rest_lros.build_put_async_non_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_non_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_async_non_resource_initial.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore + + @distributed_trace_async + async def begin_put_async_non_resource( + self, sku: Optional["_models.Sku"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Sku"]: + """Long running put request with non resource. + + :param sku: Sku to put. + :type sku: ~lro.models.Sku + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Sku or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Sku] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_non_resource.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore + + async def _put_sub_resource_initial( + self, provisioning_state: Optional[str] = None, **kwargs: Any + ) -> "_models.SubProduct": + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _product = _models.SubProduct(provisioning_state=provisioning_state) + if _product is not None: + json = self._serialize.body(_product, "SubProduct") + else: + json = None + + request = rest_lros.build_put_sub_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_sub_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_sub_resource_initial.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore + + @distributed_trace_async + async def begin_put_sub_resource( + self, provisioning_state: Optional[str] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.SubProduct"]: + """Long running put request with sub resource. + + :param provisioning_state: + :type provisioning_state: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SubProduct or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.SubProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_sub_resource_initial( + provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_sub_resource.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore + + async def _put_async_sub_resource_initial( + self, provisioning_state: Optional[str] = None, **kwargs: Any + ) -> "_models.SubProduct": + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _product = _models.SubProduct(provisioning_state=provisioning_state) + if _product is not None: + json = self._serialize.body(_product, "SubProduct") + else: + json = None + + request = rest_lros.build_put_async_sub_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_sub_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_async_sub_resource_initial.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore + + @distributed_trace_async + async def begin_put_async_sub_resource( + self, provisioning_state: Optional[str] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.SubProduct"]: + """Long running put request with sub resource. + + :param provisioning_state: + :type provisioning_state: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SubProduct or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.SubProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_sub_resource_initial( + provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_sub_resource.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore + + async def _delete_provisioning202_accepted200_succeeded_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_provisioning202_accepted200_succeeded_request_initial( + template_url=self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_delete_provisioning202_accepted200_succeeded( + self, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_provisioning202_accepted200_succeeded_initial( + cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + async def _delete_provisioning202_deleting_failed200_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_provisioning202_deleting_failed200_request_initial( + template_url=self._delete_provisioning202_deleting_failed200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_deleting_failed200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore + + @distributed_trace_async + async def begin_delete_provisioning202_deleting_failed200(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_provisioning202_deleting_failed200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_deleting_failed200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore + + async def _delete_provisioning202_deletingcanceled200_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_provisioning202_deletingcanceled200_request_initial( + template_url=self._delete_provisioning202_deletingcanceled200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_deletingcanceled200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore + + @distributed_trace_async + async def begin_delete_provisioning202_deletingcanceled200( + self, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_provisioning202_deletingcanceled200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_deletingcanceled200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore + + async def _delete204_succeeded_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete204_succeeded_request_initial( + template_url=self._delete204_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete204_succeeded_initial.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_delete204_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete succeeds and returns right away. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete204_succeeded.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore + + async def _delete202_retry200_initial(self, **kwargs: Any) -> Optional["_models.Product"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete202_retry200_request_initial( + template_url=self._delete202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete202_retry200_initial.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore + + @distributed_trace_async + async def begin_delete202_retry200(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_retry200.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore + + async def _delete202_no_retry204_initial(self, **kwargs: Any) -> Optional["_models.Product"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete202_no_retry204_request_initial( + template_url=self._delete202_no_retry204_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete202_no_retry204_initial.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore + + @distributed_trace_async + async def begin_delete202_no_retry204(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete202_no_retry204_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_no_retry204.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore + + async def _delete_no_header_in_retry_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_no_header_in_retry_request_initial( + template_url=self._delete_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_no_header_in_retry_initial.metadata = {"url": "/lro/delete/noheader"} # type: ignore + + @distributed_trace_async + async def begin_delete_no_header_in_retry(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a location header in the initial request. + Subsequent calls to operation status do not contain location header. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_no_header_in_retry.metadata = {"url": "/lro/delete/noheader"} # type: ignore + + async def _delete_async_no_header_in_retry_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_no_header_in_retry_request_initial( + template_url=self._delete_async_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_no_header_in_retry_initial.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_no_header_in_retry(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns an Azure-AsyncOperation header in the initial + request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_no_header_in_retry.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore + + async def _delete_async_retry_succeeded_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_retry_succeeded_request_initial( + template_url=self._delete_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_retry_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_retry_succeeded.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore + + async def _delete_async_no_retry_succeeded_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_no_retry_succeeded_request_initial( + template_url=self._delete_async_no_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_no_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_no_retry_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_no_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_no_retry_succeeded.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore + + async def _delete_async_retry_failed_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_retry_failed_request_initial( + template_url=self._delete_async_retry_failed_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_retry_failed_initial.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_retry_failed(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_retry_failed_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_retry_failed.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore + + async def _delete_async_retrycanceled_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_retrycanceled_request_initial( + template_url=self._delete_async_retrycanceled_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_retrycanceled_initial.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_retrycanceled(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_retrycanceled_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_retrycanceled.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore + + async def _post200_with_payload_initial(self, **kwargs: Any) -> "_models.Sku": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post200_with_payload_request_initial( + template_url=self._post200_with_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Sku", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post200_with_payload_initial.metadata = {"url": "/lro/post/payload/200"} # type: ignore + + @distributed_trace_async + async def begin_post200_with_payload(self, **kwargs: Any) -> AsyncLROPoller["_models.Sku"]: + """Long running post request, service returns a 202 to the initial request, with 'Location' + header. Poll returns a 200 with a response body after success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Sku or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Sku] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post200_with_payload_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post200_with_payload.metadata = {"url": "/lro/post/payload/200"} # type: ignore + + async def _post202_retry200_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry200_initial.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore + + @distributed_trace_async + async def begin_post202_retry200( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with 'Location' and + 'Retry-After' headers, Polls return a 200 with a response body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry200.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore + + async def _post202_no_retry204_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post202_no_retry204_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_no_retry204_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post202_no_retry204_initial.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore + + @distributed_trace_async + async def begin_post202_no_retry204( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running post request, service returns a 202 to the initial request, with 'Location' + header, 204 with noresponse body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_no_retry204_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_no_retry204.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore + + async def _post_double_headers_final_location_get_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post_double_headers_final_location_get_request_initial( + template_url=self._post_double_headers_final_location_get_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post_double_headers_final_location_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore + + @distributed_trace_async + async def begin_post_double_headers_final_location_get(self, **kwargs: Any) -> AsyncLROPoller["_models.Product"]: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final + object. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_double_headers_final_location_get_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_double_headers_final_location_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore + + async def _post_double_headers_final_azure_header_get_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post_double_headers_final_azure_header_get_request_initial( + template_url=self._post_double_headers_final_azure_header_get_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post_double_headers_final_azure_header_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore + + @distributed_trace_async + async def begin_post_double_headers_final_azure_header_get( + self, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_double_headers_final_azure_header_get_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling( + lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs + ) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_double_headers_final_azure_header_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore + + async def _post_double_headers_final_azure_header_get_default_initial(self, **kwargs: Any) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post_double_headers_final_azure_header_get_default_request_initial( + template_url=self._post_double_headers_final_azure_header_get_default_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post_double_headers_final_azure_header_get_default_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore + + @distributed_trace_async + async def begin_post_double_headers_final_azure_header_get_default( + self, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object if you support initial Autorest behavior. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_double_headers_final_azure_header_get_default_initial( + cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_double_headers_final_azure_header_get_default.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore + + async def _post_async_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> Optional["_models.Product"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_async_retry_succeeded_initial.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_post_async_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retry_succeeded.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore + + async def _post_async_no_retry_succeeded_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> Optional["_models.Product"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_no_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_no_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_async_no_retry_succeeded_initial.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore + + @distributed_trace_async + async def begin_post_async_no_retry_succeeded( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_no_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_no_retry_succeeded.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore + + async def _post_async_retry_failed_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_retry_failed_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retry_failed_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_retry_failed_initial.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore + + @distributed_trace_async + async def begin_post_async_retry_failed( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retry_failed.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore + + async def _post_async_retrycanceled_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_retrycanceled_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retrycanceled_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_retrycanceled_initial.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore + + @distributed_trace_async + async def begin_post_async_retrycanceled( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_retrycanceled_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retrycanceled.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py new file mode 100644 index 00000000000..2ceb9c19346 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/operations/_lrosads_operations.py @@ -0,0 +1,2506 @@ +# 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._rest import lrosads as rest_lrosads + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LROSADsOperations: + """LROSADsOperations 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: ~lro.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 + + async def _put_non_retry400_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_non_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore + + @distributed_trace_async + async def begin_put_non_retry400( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 400 to the initial request. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_retry400.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore + + async def _put_non_retry201_creating400_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_non_retry201_creating400_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_retry201_creating400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_retry201_creating400_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore + + @distributed_trace_async + async def begin_put_non_retry201_creating400( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_non_retry201_creating400_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_retry201_creating400.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore + + async def _put_non_retry201_creating400_invalid_json_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_non_retry201_creating400_invalid_json_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_retry201_creating400_invalid_json_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_retry201_creating400_invalid_json_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore + + @distributed_trace_async + async def begin_put_non_retry201_creating400_invalid_json( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_non_retry201_creating400_invalid_json_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_retry201_creating400_invalid_json.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore + + async def _put_async_relative_retry400_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore + + @distributed_trace_async + async def begin_put_async_relative_retry400( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_relative_retry400_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore + + async def _delete_non_retry400_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_non_retry400_request_initial( + template_url=self._delete_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore + + @distributed_trace_async + async def begin_delete_non_retry400(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 400 with an error body. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore + + async def _delete202_non_retry400_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete202_non_retry400_request_initial( + template_url=self._delete202_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore + + @distributed_trace_async + async def begin_delete202_non_retry400(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 with a location header. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete202_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore + + async def _delete_async_relative_retry400_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry400_request_initial( + template_url=self._delete_async_relative_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_relative_retry400(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_relative_retry400_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore + + async def _post_non_retry400_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_non_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._post_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore + + @distributed_trace_async + async def begin_post_non_retry400( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 400 with no error body. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_non_retry400.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore + + async def _post202_non_retry400_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post202_non_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore + + @distributed_trace_async + async def begin_post202_non_retry400( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 with a location header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_non_retry400.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore + + async def _post_async_relative_retry400_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore + + @distributed_trace_async + async def begin_post_async_relative_retry400( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_relative_retry400_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore + + async def _put_error201_no_provisioning_state_payload_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_error201_no_provisioning_state_payload_request_initial( + content_type=content_type, + json=json, + template_url=self._put_error201_no_provisioning_state_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_error201_no_provisioning_state_payload_initial.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore + + @distributed_trace_async + async def begin_put_error201_no_provisioning_state_payload( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 201 to the initial request with no payload. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_error201_no_provisioning_state_payload_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_error201_no_provisioning_state_payload.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore + + async def _put_async_relative_retry_no_status_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_no_status_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_no_status_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore + + @distributed_trace_async + async def begin_put_async_relative_retry_no_status( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_relative_retry_no_status_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_no_status.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore + + async def _put_async_relative_retry_no_status_payload_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_no_status_payload_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_no_status_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_no_status_payload_initial.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore + + @distributed_trace_async + async def begin_put_async_relative_retry_no_status_payload( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_relative_retry_no_status_payload_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_no_status_payload.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore + + async def _delete204_succeeded_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete204_succeeded_request_initial( + template_url=self._delete204_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete204_succeeded_initial.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore + + @distributed_trace_async + async def begin_delete204_succeeded(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 204 to the initial request, indicating success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete204_succeeded.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore + + async def _delete_async_relative_retry_no_status_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry_no_status_request_initial( + template_url=self._delete_async_relative_retry_no_status_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_relative_retry_no_status(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_relative_retry_no_status_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_no_status.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore + + async def _post202_no_location_initial(self, product: Optional["_models.Product"] = None, **kwargs: Any) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post202_no_location_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_no_location_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_no_location_initial.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore + + @distributed_trace_async + async def begin_post202_no_location( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, without a location + header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_no_location_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_no_location.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore + + async def _post_async_relative_retry_no_payload_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry_no_payload_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_no_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_no_payload_initial.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore + + @distributed_trace_async + async def begin_post_async_relative_retry_no_payload( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_relative_retry_no_payload_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_no_payload.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore + + async def _put200_invalid_json_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> Optional["_models.Product"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put200_invalid_json_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_invalid_json_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_invalid_json_initial.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore + + @distributed_trace_async + async def begin_put200_invalid_json( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that is + not a valid json. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put200_invalid_json_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_invalid_json.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore + + async def _put_async_relative_retry_invalid_header_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_invalid_header_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore + + @distributed_trace_async + async def begin_put_async_relative_retry_invalid_header( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_relative_retry_invalid_header_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore + + async def _put_async_relative_retry_invalid_json_polling_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_invalid_json_polling_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_invalid_json_polling_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore + + @distributed_trace_async + async def begin_put_async_relative_retry_invalid_json_polling( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller["_models.Product"]: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._put_async_relative_retry_invalid_json_polling_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore + + async def _delete202_retry_invalid_header_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete202_retry_invalid_header_request_initial( + template_url=self._delete202_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete202_retry_invalid_header_initial.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore + + @distributed_trace_async + async def begin_delete202_retry_invalid_header(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request receing a reponse + with an invalid 'Location' and 'Retry-After' headers. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete202_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_retry_invalid_header.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore + + async def _delete_async_relative_retry_invalid_header_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry_invalid_header_request_initial( + template_url=self._delete_async_relative_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_relative_retry_invalid_header(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. The endpoint + indicated in the Azure-AsyncOperation header is invalid. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_relative_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore + + async def _delete_async_relative_retry_invalid_json_polling_initial(self, **kwargs: Any) -> None: + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry_invalid_json_polling_request_initial( + template_url=self._delete_async_relative_retry_invalid_json_polling_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore + + @distributed_trace_async + async def begin_delete_async_relative_retry_invalid_json_polling(self, **kwargs: Any) -> AsyncLROPoller[None]: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_async_relative_retry_invalid_json_polling_initial( + cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore + + async def _post202_retry_invalid_header_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post202_retry_invalid_header_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry_invalid_header_initial.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore + + @distributed_trace_async + async def begin_post202_retry_invalid_header( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with invalid + 'Location' and 'Retry-After' headers. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post202_retry_invalid_header_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry_invalid_header.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore + + async def _post_async_relative_retry_invalid_header_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry_invalid_header_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore + + @distributed_trace_async + async def begin_post_async_relative_retry_invalid_header( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_relative_retry_invalid_header_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore + + async def _post_async_relative_retry_invalid_json_polling_initial( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry_invalid_json_polling_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_invalid_json_polling_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore + + @distributed_trace_async + async def begin_post_async_relative_retry_invalid_json_polling( + self, product: Optional["_models.Product"] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_async_relative_retry_invalid_json_polling_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/models/_auto_rest_long_running_operation_test_service_enums.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/_auto_rest_long_running_operation_test_service_enums.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/models/_auto_rest_long_running_operation_test_service_enums.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/_auto_rest_long_running_operation_test_service_enums.py diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py new file mode 100644 index 00000000000..fc852325f9a --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py @@ -0,0 +1,478 @@ +# 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._rest import lr_os_custom_header as rest_lr_os_custom_header + +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]] + + +class LROsCustomHeaderOperations(object): + """LROsCustomHeaderOperations 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: ~lro.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 + + def _put_async_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_put_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_put_async_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_retry_succeeded.metadata = {"url": "/lro/customheader/putasync/retry/succeeded"} # type: ignore + + def _put201_creating_succeeded200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_put201_creating_succeeded200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_succeeded200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_succeeded200_initial.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore + + @distributed_trace + def begin_put201_creating_succeeded200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put201_creating_succeeded200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_succeeded200.metadata = {"url": "/lro/customheader/put/201/creating/succeeded/200"} # type: ignore + + def _post202_retry200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_post202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry200_initial.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore + + @distributed_trace + def begin_post202_retry200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry200.metadata = {"url": "/lro/customheader/post/202/retry/200"} # type: ignore + + def _post_async_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lr_os_custom_header.build_post_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_retry_succeeded_initial.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_post_async_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retry_succeeded.metadata = {"url": "/lro/customheader/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py new file mode 100644 index 00000000000..534bfd16bcb --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py @@ -0,0 +1,737 @@ +# 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._rest import lro_retrys as rest_lro_retrys + +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]] + + +class LRORetrysOperations(object): + """LRORetrysOperations 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: ~lro.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 + + def _put201_creating_succeeded200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_put201_creating_succeeded200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_succeeded200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_succeeded200_initial.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore + + @distributed_trace + def begin_put201_creating_succeeded200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 500, then a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put201_creating_succeeded200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_succeeded200.metadata = {"url": "/lro/retryerror/put/201/creating/succeeded/200"} # type: ignore + + def _put_async_relative_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_put_async_relative_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_put_async_relative_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 500, then a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_relative_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/putasync/retry/succeeded"} # type: ignore + + def _delete_provisioning202_accepted200_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lro_retrys.build_delete_provisioning202_accepted200_succeeded_request_initial( + template_url=self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + @distributed_trace + def begin_delete_provisioning202_accepted200_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running delete request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_provisioning202_accepted200_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + def _delete202_retry200_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lro_retrys.build_delete202_retry200_request_initial( + template_url=self._delete202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete202_retry200_initial.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore + + @distributed_trace + def begin_delete202_retry200( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 500, then a 202 to the initial request. Polls + return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_retry200.metadata = {"url": "/lro/retryerror/delete/202/retry/200"} # type: ignore + + def _delete_async_relative_retry_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lro_retrys.build_delete_async_relative_retry_succeeded_request_initial( + template_url=self._delete_async_relative_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_delete_async_relative_retry_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_relative_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/deleteasync/retry/succeeded"} # type: ignore + + def _post202_retry200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_post202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry200_initial.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore + + @distributed_trace + def begin_post202_retry200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 500, then a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry200.metadata = {"url": "/lro/retryerror/post/202/retry/200"} # type: ignore + + def _post_async_relative_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lro_retrys.build_post_async_relative_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_succeeded_initial.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_post_async_relative_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_relative_retry_succeeded_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_succeeded.metadata = {"url": "/lro/retryerror/postasync/retry/succeeded"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py new file mode 100644 index 00000000000..7c7f5811ea7 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py @@ -0,0 +1,4058 @@ +# 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._rest import lros as rest_lros + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class LROsOperations(object): + """LROsOperations 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: ~lro.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 + + def _put200_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Product"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_succeeded_initial.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore + + @distributed_trace + def begin_put200_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put200_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_succeeded.metadata = {"url": "/lro/put/200/succeeded"} # type: ignore + + def _put201_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put201_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_succeeded_initial.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore + + @distributed_trace + def begin_put201_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put201_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_succeeded.metadata = {"url": "/lro/put/201/succeeded"} # type: ignore + + def _post202_list_initial( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[List["_models.Product"]] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[List["_models.Product"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post202_list_request_initial( + template_url=self._post202_list_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("[Product]", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post202_list_initial.metadata = {"url": "/lro/list"} # type: ignore + + @distributed_trace + def begin_post202_list( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[List["_models.Product"]] + """Long running put request, service returns a 202 with empty body to first request, returns a 200 + with body [{ 'id': '100', 'name': 'foo' }]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either list of Product or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[list[~lro.models.Product]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_list_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_list.metadata = {"url": "/lro/list"} # type: ignore + + def _put200_succeeded_no_state_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_succeeded_no_state_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_succeeded_no_state_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_succeeded_no_state_initial.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore + + @distributed_trace + def begin_put200_succeeded_no_state( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + does not contain ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put200_succeeded_no_state_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_succeeded_no_state.metadata = {"url": "/lro/put/200/succeeded/nostate"} # type: ignore + + def _put202_retry200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._put202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put202_retry200_initial.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore + + @distributed_trace + def begin_put202_retry200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 202 to the initial request, with a location header + that points to a polling URL that returns a 200 and an entity that doesn't contains + ProvisioningState. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put202_retry200.metadata = {"url": "/lro/put/202/retry/200"} # type: ignore + + def _put201_creating_succeeded200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put201_creating_succeeded200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_succeeded200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_succeeded200_initial.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore + + @distributed_trace + def begin_put201_creating_succeeded200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put201_creating_succeeded200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_succeeded200.metadata = {"url": "/lro/put/201/creating/succeeded/200"} # type: ignore + + def _put200_updating_succeeded204_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_updating_succeeded204_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_updating_succeeded204_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_updating_succeeded204_initial.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore + + @distributed_trace + def begin_put200_updating_succeeded204( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put200_updating_succeeded204_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_updating_succeeded204.metadata = {"url": "/lro/put/200/updating/succeeded/200"} # type: ignore + + def _put201_creating_failed200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put201_creating_failed200_request_initial( + content_type=content_type, + json=json, + template_url=self._put201_creating_failed200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put201_creating_failed200_initial.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore + + @distributed_trace + def begin_put201_creating_failed200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Created’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put201_creating_failed200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put201_creating_failed200.metadata = {"url": "/lro/put/201/created/failed/200"} # type: ignore + + def _put200_acceptedcanceled200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put200_acceptedcanceled200_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_acceptedcanceled200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_acceptedcanceled200_initial.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore + + @distributed_trace + def begin_put200_acceptedcanceled200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put200_acceptedcanceled200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_acceptedcanceled200.metadata = {"url": "/lro/put/200/accepted/canceled/200"} # type: ignore + + def _put_no_header_in_retry_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_no_header_in_retry_request_initial( + content_type=content_type, + json=json, + template_url=self._put_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_no_header_in_retry_initial.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore + + @distributed_trace + def begin_put_no_header_in_retry( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 202 to the initial request with location header. + Subsequent calls to operation status do not contain location header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_no_header_in_retry_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_no_header_in_retry.metadata = {"url": "/lro/put/noheader/202/200"} # type: ignore + + def _put_async_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_retry_succeeded_initial.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_put_async_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_retry_succeeded.metadata = {"url": "/lro/putasync/retry/succeeded"} # type: ignore + + def _put_async_no_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_no_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_no_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_no_retry_succeeded_initial.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore + + @distributed_trace + def begin_put_async_no_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_no_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_no_retry_succeeded.metadata = {"url": "/lro/putasync/noretry/succeeded"} # type: ignore + + def _put_async_retry_failed_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_retry_failed_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_retry_failed_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_retry_failed_initial.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore + + @distributed_trace + def begin_put_async_retry_failed( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_retry_failed.metadata = {"url": "/lro/putasync/retry/failed"} # type: ignore + + def _put_async_no_retrycanceled_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_no_retrycanceled_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_no_retrycanceled_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_no_retrycanceled_initial.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore + + @distributed_trace + def begin_put_async_no_retrycanceled( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_no_retrycanceled_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_no_retrycanceled.metadata = {"url": "/lro/putasync/noretry/canceled"} # type: ignore + + def _put_async_no_header_in_retry_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_put_async_no_header_in_retry_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_no_header_in_retry_initial.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore + + @distributed_trace + def begin_put_async_no_header_in_retry( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 202 to the initial request with + Azure-AsyncOperation header. Subsequent calls to operation status do not contain + Azure-AsyncOperation header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_no_header_in_retry_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_no_header_in_retry.metadata = {"url": "/lro/putasync/noheader/201/200"} # type: ignore + + def _put_non_resource_initial( + self, + sku=None, # type: Optional["_models.Sku"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Sku" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if sku is not None: + json = self._serialize.body(sku, "Sku") + else: + json = None + + request = rest_lros.build_put_non_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_resource_initial.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore + + @distributed_trace + def begin_put_non_resource( + self, + sku=None, # type: Optional["_models.Sku"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Sku"] + """Long running put request with non resource. + + :param sku: sku to put. + :type sku: ~lro.models.Sku + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Sku or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Sku] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_resource.metadata = {"url": "/lro/putnonresource/202/200"} # type: ignore + + def _put_async_non_resource_initial( + self, + sku=None, # type: Optional["_models.Sku"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Sku" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if sku is not None: + json = self._serialize.body(sku, "Sku") + else: + json = None + + request = rest_lros.build_put_async_non_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_non_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_async_non_resource_initial.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore + + @distributed_trace + def begin_put_async_non_resource( + self, + sku=None, # type: Optional["_models.Sku"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Sku"] + """Long running put request with non resource. + + :param sku: Sku to put. + :type sku: ~lro.models.Sku + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Sku or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Sku] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_non_resource_initial(sku=sku, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_non_resource.metadata = {"url": "/lro/putnonresourceasync/202/200"} # type: ignore + + def _put_sub_resource_initial( + self, + provisioning_state=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.SubProduct" + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _product = _models.SubProduct(provisioning_state=provisioning_state) + if _product is not None: + json = self._serialize.body(_product, "SubProduct") + else: + json = None + + request = rest_lros.build_put_sub_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_sub_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_sub_resource_initial.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore + + @distributed_trace + def begin_put_sub_resource( + self, + provisioning_state=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.SubProduct"] + """Long running put request with sub resource. + + :param provisioning_state: + :type provisioning_state: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SubProduct or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.SubProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_sub_resource_initial( + provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_sub_resource.metadata = {"url": "/lro/putsubresource/202/200"} # type: ignore + + def _put_async_sub_resource_initial( + self, + provisioning_state=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.SubProduct" + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _product = _models.SubProduct(provisioning_state=provisioning_state) + if _product is not None: + json = self._serialize.body(_product, "SubProduct") + else: + json = None + + request = rest_lros.build_put_async_sub_resource_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_sub_resource_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_async_sub_resource_initial.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore + + @distributed_trace + def begin_put_async_sub_resource( + self, + provisioning_state=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.SubProduct"] + """Long running put request with sub resource. + + :param provisioning_state: + :type provisioning_state: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SubProduct or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.SubProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.SubProduct"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_sub_resource_initial( + provisioning_state=provisioning_state, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("SubProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_sub_resource.metadata = {"url": "/lro/putsubresourceasync/202/200"} # type: ignore + + def _delete_provisioning202_accepted200_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_provisioning202_accepted200_succeeded_request_initial( + template_url=self._delete_provisioning202_accepted200_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_accepted200_succeeded_initial.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + @distributed_trace + def begin_delete_provisioning202_accepted200_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_provisioning202_accepted200_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_accepted200_succeeded.metadata = {"url": "/lro/delete/provisioning/202/accepted/200/succeeded"} # type: ignore + + def _delete_provisioning202_deleting_failed200_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_provisioning202_deleting_failed200_request_initial( + template_url=self._delete_provisioning202_deleting_failed200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_deleting_failed200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore + + @distributed_trace + def begin_delete_provisioning202_deleting_failed200( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_provisioning202_deleting_failed200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_deleting_failed200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/failed"} # type: ignore + + def _delete_provisioning202_deletingcanceled200_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_provisioning202_deletingcanceled200_request_initial( + template_url=self._delete_provisioning202_deletingcanceled200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_provisioning202_deletingcanceled200_initial.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore + + @distributed_trace + def begin_delete_provisioning202_deletingcanceled200( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_provisioning202_deletingcanceled200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_provisioning202_deletingcanceled200.metadata = {"url": "/lro/delete/provisioning/202/deleting/200/canceled"} # type: ignore + + def _delete204_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete204_succeeded_request_initial( + template_url=self._delete204_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete204_succeeded_initial.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore + + @distributed_trace + def begin_delete204_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete succeeds and returns right away. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete204_succeeded.metadata = {"url": "/lro/delete/204/succeeded"} # type: ignore + + def _delete202_retry200_initial( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Product"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete202_retry200_request_initial( + template_url=self._delete202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete202_retry200_initial.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore + + @distributed_trace + def begin_delete202_retry200( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete202_retry200_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_retry200.metadata = {"url": "/lro/delete/202/retry/200"} # type: ignore + + def _delete202_no_retry204_initial( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Product"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete202_no_retry204_request_initial( + template_url=self._delete202_no_retry204_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete202_no_retry204_initial.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore + + @distributed_trace + def begin_delete202_no_retry204( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete202_no_retry204_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_no_retry204.metadata = {"url": "/lro/delete/202/noretry/204"} # type: ignore + + def _delete_no_header_in_retry_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_no_header_in_retry_request_initial( + template_url=self._delete_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_no_header_in_retry_initial.metadata = {"url": "/lro/delete/noheader"} # type: ignore + + @distributed_trace + def begin_delete_no_header_in_retry( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a location header in the initial request. + Subsequent calls to operation status do not contain location header. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_no_header_in_retry.metadata = {"url": "/lro/delete/noheader"} # type: ignore + + def _delete_async_no_header_in_retry_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_no_header_in_retry_request_initial( + template_url=self._delete_async_no_header_in_retry_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_no_header_in_retry_initial.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore + + @distributed_trace + def begin_delete_async_no_header_in_retry( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns an Azure-AsyncOperation header in the initial + request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_no_header_in_retry_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_no_header_in_retry.metadata = {"url": "/lro/deleteasync/noheader/202/204"} # type: ignore + + def _delete_async_retry_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_retry_succeeded_request_initial( + template_url=self._delete_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_delete_async_retry_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_retry_succeeded.metadata = {"url": "/lro/deleteasync/retry/succeeded"} # type: ignore + + def _delete_async_no_retry_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_no_retry_succeeded_request_initial( + template_url=self._delete_async_no_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_no_retry_succeeded_initial.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore + + @distributed_trace + def begin_delete_async_no_retry_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_no_retry_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_no_retry_succeeded.metadata = {"url": "/lro/deleteasync/noretry/succeeded"} # type: ignore + + def _delete_async_retry_failed_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_retry_failed_request_initial( + template_url=self._delete_async_retry_failed_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_retry_failed_initial.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore + + @distributed_trace + def begin_delete_async_retry_failed( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_retry_failed_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_retry_failed.metadata = {"url": "/lro/deleteasync/retry/failed"} # type: ignore + + def _delete_async_retrycanceled_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_delete_async_retrycanceled_request_initial( + template_url=self._delete_async_retrycanceled_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_retrycanceled_initial.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore + + @distributed_trace + def begin_delete_async_retrycanceled( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_retrycanceled_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_retrycanceled.metadata = {"url": "/lro/deleteasync/retry/canceled"} # type: ignore + + def _post200_with_payload_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Sku" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post200_with_payload_request_initial( + template_url=self._post200_with_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Sku", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post200_with_payload_initial.metadata = {"url": "/lro/post/payload/200"} # type: ignore + + @distributed_trace + def begin_post200_with_payload( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Sku"] + """Long running post request, service returns a 202 to the initial request, with 'Location' + header. Poll returns a 200 with a response body after success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Sku or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Sku] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Sku"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post200_with_payload_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Sku", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post200_with_payload.metadata = {"url": "/lro/post/payload/200"} # type: ignore + + def _post202_retry200_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post202_retry200_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry200_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry200_initial.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore + + @distributed_trace + def begin_post202_retry200( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with 'Location' and + 'Retry-After' headers, Polls return a 200 with a response body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_retry200_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry200.metadata = {"url": "/lro/post/202/retry/200"} # type: ignore + + def _post202_no_retry204_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post202_no_retry204_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_no_retry204_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post202_no_retry204_initial.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore + + @distributed_trace + def begin_post202_no_retry204( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running post request, service returns a 202 to the initial request, with 'Location' + header, 204 with noresponse body after success. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_no_retry204_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_no_retry204.metadata = {"url": "/lro/post/202/noretry/204"} # type: ignore + + def _post_double_headers_final_location_get_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post_double_headers_final_location_get_request_initial( + template_url=self._post_double_headers_final_location_get_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post_double_headers_final_location_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore + + @distributed_trace + def begin_post_double_headers_final_location_get( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final + object. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_double_headers_final_location_get_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_double_headers_final_location_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalLocationGet"} # type: ignore + + def _post_double_headers_final_azure_header_get_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post_double_headers_final_azure_header_get_request_initial( + template_url=self._post_double_headers_final_azure_header_get_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post_double_headers_final_azure_header_get_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore + + @distributed_trace + def begin_post_double_headers_final_azure_header_get( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_double_headers_final_azure_header_get_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_double_headers_final_azure_header_get.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGet"} # type: ignore + + def _post_double_headers_final_azure_header_get_default_initial( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lros.build_post_double_headers_final_azure_header_get_default_request_initial( + template_url=self._post_double_headers_final_azure_header_get_default_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _post_double_headers_final_azure_header_get_default_initial.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore + + @distributed_trace + def begin_post_double_headers_final_azure_header_get_default( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object if you support initial Autorest behavior. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_double_headers_final_azure_header_get_default_initial( + cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_double_headers_final_azure_header_get_default.metadata = {"url": "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault"} # type: ignore + + def _post_async_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Product"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_async_retry_succeeded_initial.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore + + @distributed_trace + def begin_post_async_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retry_succeeded.metadata = {"url": "/lro/postasync/retry/succeeded"} # type: ignore + + def _post_async_no_retry_succeeded_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Product"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_no_retry_succeeded_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_no_retry_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_async_no_retry_succeeded_initial.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore + + @distributed_trace + def begin_post_async_no_retry_succeeded( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_no_retry_succeeded_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_no_retry_succeeded.metadata = {"url": "/lro/postasync/noretry/succeeded"} # type: ignore + + def _post_async_retry_failed_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_retry_failed_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retry_failed_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_retry_failed_initial.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore + + @distributed_trace + def begin_post_async_retry_failed( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_retry_failed_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retry_failed.metadata = {"url": "/lro/postasync/retry/failed"} # type: ignore + + def _post_async_retrycanceled_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lros.build_post_async_retrycanceled_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_retrycanceled_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_retrycanceled_initial.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore + + @distributed_trace + def begin_post_async_retrycanceled( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_retrycanceled_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_retrycanceled.metadata = {"url": "/lro/postasync/retry/canceled"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py new file mode 100644 index 00000000000..0d07d584363 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py @@ -0,0 +1,2600 @@ +# 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._rest import lrosads as rest_lrosads + +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]] + + +class LROSADsOperations(object): + """LROSADsOperations 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: ~lro.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 + + def _put_non_retry400_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_non_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore + + @distributed_trace + def begin_put_non_retry400( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 400 to the initial request. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_retry400.metadata = {"url": "/lro/nonretryerror/put/400"} # type: ignore + + def _put_non_retry201_creating400_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_non_retry201_creating400_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_retry201_creating400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_retry201_creating400_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore + + @distributed_trace + def begin_put_non_retry201_creating400( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_non_retry201_creating400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_retry201_creating400.metadata = {"url": "/lro/nonretryerror/put/201/creating/400"} # type: ignore + + def _put_non_retry201_creating400_invalid_json_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_non_retry201_creating400_invalid_json_request_initial( + content_type=content_type, + json=json, + template_url=self._put_non_retry201_creating400_invalid_json_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_non_retry201_creating400_invalid_json_initial.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore + + @distributed_trace + def begin_put_non_retry201_creating400_invalid_json( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_non_retry201_creating400_invalid_json_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_non_retry201_creating400_invalid_json.metadata = {"url": "/lro/nonretryerror/put/201/creating/400/invalidjson"} # type: ignore + + def _put_async_relative_retry400_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore + + @distributed_trace + def begin_put_async_relative_retry400( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_relative_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/putasync/retry/400"} # type: ignore + + def _delete_non_retry400_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_non_retry400_request_initial( + template_url=self._delete_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore + + @distributed_trace + def begin_delete_non_retry400( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 400 with an error body. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/400"} # type: ignore + + def _delete202_non_retry400_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete202_non_retry400_request_initial( + template_url=self._delete202_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore + + @distributed_trace + def begin_delete202_non_retry400( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 with a location header. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete202_non_retry400_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_non_retry400.metadata = {"url": "/lro/nonretryerror/delete/202/retry/400"} # type: ignore + + def _delete_async_relative_retry400_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry400_request_initial( + template_url=self._delete_async_relative_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore + + @distributed_trace + def begin_delete_async_relative_retry400( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_relative_retry400_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/deleteasync/retry/400"} # type: ignore + + def _post_non_retry400_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_non_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._post_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore + + @distributed_trace + def begin_post_non_retry400( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 400 with no error body. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_non_retry400.metadata = {"url": "/lro/nonretryerror/post/400"} # type: ignore + + def _post202_non_retry400_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post202_non_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_non_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_non_retry400_initial.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore + + @distributed_trace + def begin_post202_non_retry400( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 with a location header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_non_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_non_retry400.metadata = {"url": "/lro/nonretryerror/post/202/retry/400"} # type: ignore + + def _post_async_relative_retry400_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry400_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry400_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry400_initial.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore + + @distributed_trace + def begin_post_async_relative_retry400( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_relative_retry400_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry400.metadata = {"url": "/lro/nonretryerror/postasync/retry/400"} # type: ignore + + def _put_error201_no_provisioning_state_payload_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_error201_no_provisioning_state_payload_request_initial( + content_type=content_type, + json=json, + template_url=self._put_error201_no_provisioning_state_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put_error201_no_provisioning_state_payload_initial.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore + + @distributed_trace + def begin_put_error201_no_provisioning_state_payload( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 201 to the initial request with no payload. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_error201_no_provisioning_state_payload_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_error201_no_provisioning_state_payload.metadata = {"url": "/lro/error/put/201/noprovisioningstatepayload"} # type: ignore + + def _put_async_relative_retry_no_status_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_no_status_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_no_status_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore + + @distributed_trace + def begin_put_async_relative_retry_no_status( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_relative_retry_no_status_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_no_status.metadata = {"url": "/lro/error/putasync/retry/nostatus"} # type: ignore + + def _put_async_relative_retry_no_status_payload_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_no_status_payload_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_no_status_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_no_status_payload_initial.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore + + @distributed_trace + def begin_put_async_relative_retry_no_status_payload( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_relative_retry_no_status_payload_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_no_status_payload.metadata = {"url": "/lro/error/putasync/retry/nostatuspayload"} # type: ignore + + def _delete204_succeeded_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete204_succeeded_request_initial( + template_url=self._delete204_succeeded_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete204_succeeded_initial.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore + + @distributed_trace + def begin_delete204_succeeded( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 204 to the initial request, indicating success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete204_succeeded_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete204_succeeded.metadata = {"url": "/lro/error/delete/204/nolocation"} # type: ignore + + def _delete_async_relative_retry_no_status_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry_no_status_request_initial( + template_url=self._delete_async_relative_retry_no_status_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_no_status_initial.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore + + @distributed_trace + def begin_delete_async_relative_retry_no_status( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_relative_retry_no_status_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_no_status.metadata = {"url": "/lro/error/deleteasync/retry/nostatus"} # type: ignore + + def _post202_no_location_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post202_no_location_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_no_location_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_no_location_initial.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore + + @distributed_trace + def begin_post202_no_location( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, without a location + header. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_no_location_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_no_location.metadata = {"url": "/lro/error/post/202/nolocation"} # type: ignore + + def _post_async_relative_retry_no_payload_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry_no_payload_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_no_payload_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_no_payload_initial.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore + + @distributed_trace + def begin_post_async_relative_retry_no_payload( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_relative_retry_no_payload_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_no_payload.metadata = {"url": "/lro/error/postasync/retry/nopayload"} # type: ignore + + def _put200_invalid_json_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Product"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put200_invalid_json_request_initial( + content_type=content_type, + json=json, + template_url=self._put200_invalid_json_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _put200_invalid_json_initial.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore + + @distributed_trace + def begin_put200_invalid_json( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that is + not a valid json. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put200_invalid_json_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put200_invalid_json.metadata = {"url": "/lro/error/put/200/invalidjson"} # type: ignore + + def _put_async_relative_retry_invalid_header_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_invalid_header_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore + + @distributed_trace + def begin_put_async_relative_retry_invalid_header( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_relative_retry_invalid_header_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/putasync/retry/invalidheader"} # type: ignore + + def _put_async_relative_retry_invalid_json_polling_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_put_async_relative_retry_invalid_json_polling_request_initial( + content_type=content_type, + json=json, + template_url=self._put_async_relative_retry_invalid_json_polling_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _put_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore + + @distributed_trace + def begin_put_async_relative_retry_invalid_json_polling( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Product"] + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Product or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~lro.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._put_async_relative_retry_invalid_json_polling_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_put_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/putasync/retry/invalidjsonpolling"} # type: ignore + + def _delete202_retry_invalid_header_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete202_retry_invalid_header_request_initial( + template_url=self._delete202_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete202_retry_invalid_header_initial.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore + + @distributed_trace + def begin_delete202_retry_invalid_header( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request receing a reponse + with an invalid 'Location' and 'Retry-After' headers. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete202_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete202_retry_invalid_header.metadata = {"url": "/lro/error/delete/202/retry/invalidheader"} # type: ignore + + def _delete_async_relative_retry_invalid_header_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry_invalid_header_request_initial( + template_url=self._delete_async_relative_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore + + @distributed_trace + def begin_delete_async_relative_retry_invalid_header( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. The endpoint + indicated in the Azure-AsyncOperation header is invalid. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_relative_retry_invalid_header_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/deleteasync/retry/invalidheader"} # type: ignore + + def _delete_async_relative_retry_invalid_json_polling_initial( + self, **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_lrosads.build_delete_async_relative_retry_invalid_json_polling_request_initial( + template_url=self._delete_async_relative_retry_invalid_json_polling_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore + + @distributed_trace + def begin_delete_async_relative_retry_invalid_json_polling( + self, **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_async_relative_retry_invalid_json_polling_initial(cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/deleteasync/retry/invalidjsonpolling"} # type: ignore + + def _post202_retry_invalid_header_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post202_retry_invalid_header_request_initial( + content_type=content_type, + json=json, + template_url=self._post202_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post202_retry_invalid_header_initial.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore + + @distributed_trace + def begin_post202_retry_invalid_header( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with invalid + 'Location' and 'Retry-After' headers. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post202_retry_invalid_header_initial(product=product, cls=lambda x, y, z: x, **kwargs) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post202_retry_invalid_header.metadata = {"url": "/lro/error/post/202/retry/invalidheader"} # type: ignore + + def _post_async_relative_retry_invalid_header_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry_invalid_header_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_invalid_header_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_invalid_header_initial.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore + + @distributed_trace + def begin_post_async_relative_retry_invalid_header( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_relative_retry_invalid_header_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_invalid_header.metadata = {"url": "/lro/error/postasync/retry/invalidheader"} # type: ignore + + def _post_async_relative_retry_invalid_json_polling_initial( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + 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/json") # type: Optional[str] + + if product is not None: + json = self._serialize.body(product, "Product") + else: + json = None + + request = rest_lrosads.build_post_async_relative_retry_invalid_json_polling_request_initial( + content_type=content_type, + json=json, + template_url=self._post_async_relative_retry_invalid_json_polling_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _post_async_relative_retry_invalid_json_polling_initial.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore + + @distributed_trace + def begin_post_async_relative_retry_invalid_json_polling( + self, + product=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + :param product: Product to put. + :type product: ~lro.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[None] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_async_relative_retry_invalid_json_polling_initial( + product=product, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_async_relative_retry_invalid_json_polling.metadata = {"url": "/lro/error/postasync/retry/invalidjsonpolling"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/py.typed b/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/Lro/lro/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/Lro/lro/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/Lro/setup.py b/test/azure/legacy/Expected/AcceptanceTests/Lro/setup.py new file mode 100644 index 00000000000..caf94faf8e9 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Lro/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 = "autorestlongrunningoperationtestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestLongRunningOperationTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestLongRunningOperationTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Long-running Operation for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_lro_with_paramaterized_endpoints.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_lro_with_paramaterized_endpoints.py new file mode 100644 index 00000000000..92f11d3c9da --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_lro_with_paramaterized_endpoints.py @@ -0,0 +1,98 @@ +# 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 LROWithParamaterizedEndpointsConfiguration +from .operations import LROWithParamaterizedEndpointsOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.rest import HttpRequest, HttpResponse + + +class LROWithParamaterizedEndpoints(LROWithParamaterizedEndpointsOperationsMixin): + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. Pass in + 'host:3000' to pass test. + :type host: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = LROWithParamaterizedEndpointsConfiguration(host, **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 + + 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 `lrowithparameterizedendpoints.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lrowithparameterizedendpoints._rest import build_poll_with_parameterized_endpoints_request_initial + >>> request = build_poll_with_parameterized_endpoints_request_initial(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> LROWithParamaterizedEndpoints + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/__init__.py new file mode 100644 index 00000000000..6000ce96f19 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_poll_with_parameterized_endpoints_request_initial + from ._request_builders_py3 import build_poll_with_constant_parameterized_endpoints_request_initial +except (SyntaxError, ImportError): + from ._request_builders import build_poll_with_parameterized_endpoints_request_initial # type: ignore + from ._request_builders import build_poll_with_constant_parameterized_endpoints_request_initial # type: ignore + +__all__ = [ + "build_poll_with_parameterized_endpoints_request_initial", + "build_poll_with_constant_parameterized_endpoints_request_initial", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/_request_builders.py new file mode 100644 index 00000000000..f96c17a5c67 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/_request_builders.py @@ -0,0 +1,86 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_poll_with_parameterized_endpoints_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Poll with method and client level parameters in endpoint. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lroParameterizedEndpoints') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_poll_with_constant_parameterized_endpoints_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Poll with method and client level parameters in endpoint, with a constant value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + constant_parameter = "iAmConstant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lroConstantParameterizedEndpoints/{constantParameter}') + path_format_arguments = { + 'constantParameter': _SERIALIZER.url("constant_parameter", constant_parameter, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..14dae0ca67c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_rest/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_poll_with_parameterized_endpoints_request_initial(**kwargs: Any) -> HttpRequest: + """Poll with method and client level parameters in endpoint. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lroParameterizedEndpoints") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_poll_with_constant_parameterized_endpoints_request_initial(**kwargs: Any) -> HttpRequest: + """Poll with method and client level parameters in endpoint, with a constant value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + constant_parameter = "iAmConstant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lroConstantParameterizedEndpoints/{constantParameter}") + path_format_arguments = { + "constantParameter": _SERIALIZER.url("constant_parameter", constant_parameter, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_version.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_version.py diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_lro_with_paramaterized_endpoints.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_lro_with_paramaterized_endpoints.py new file mode 100644 index 00000000000..e93367ccc05 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/_lro_with_paramaterized_endpoints.py @@ -0,0 +1,80 @@ +# 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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import LROWithParamaterizedEndpointsConfiguration +from .operations import LROWithParamaterizedEndpointsOperationsMixin + + +class LROWithParamaterizedEndpoints(LROWithParamaterizedEndpointsOperationsMixin): + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. Pass in + 'host:3000' to pass test. + :type host: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = LROWithParamaterizedEndpointsConfiguration(host, **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 + + 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 `lrowithparameterizedendpoints.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lrowithparameterizedendpoints._rest import build_poll_with_parameterized_endpoints_request_initial + >>> request = build_poll_with_parameterized_endpoints_request_initial(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "LROWithParamaterizedEndpoints": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py new file mode 100644 index 00000000000..5695c27e2cc --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py @@ -0,0 +1,238 @@ +# 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LROWithParamaterizedEndpointsOperationsMixin: + async def _poll_with_parameterized_endpoints_initial(self, account_name: str, **kwargs: Any) -> Optional[str]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_poll_with_parameterized_endpoints_request_initial( + template_url=self._poll_with_parameterized_endpoints_initial.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("str", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _poll_with_parameterized_endpoints_initial.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore + + @distributed_trace_async + async def begin_poll_with_parameterized_endpoints(self, account_name: str, **kwargs: Any) -> AsyncLROPoller[str]: + """Poll with method and client level parameters in endpoint. + + :param account_name: Account Name. Pass in 'local' to pass test. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either str or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[str] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._poll_with_parameterized_endpoints_initial( + account_name=account_name, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + + if polling is True: + polling_method = AsyncLROBasePolling( + lro_delay, + lro_options={"final-state-via": "location"}, + path_format_arguments=path_format_arguments, + **kwargs + ) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_poll_with_parameterized_endpoints.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore + + async def _poll_with_constant_parameterized_endpoints_initial( + self, account_name: str, **kwargs: Any + ) -> Optional[str]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_poll_with_constant_parameterized_endpoints_request_initial( + template_url=self._poll_with_constant_parameterized_endpoints_initial.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("str", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _poll_with_constant_parameterized_endpoints_initial.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore + + @distributed_trace_async + async def begin_poll_with_constant_parameterized_endpoints( + self, account_name: str, **kwargs: Any + ) -> AsyncLROPoller[str]: + """Poll with method and client level parameters in endpoint, with a constant value. + + :param account_name: Account Name. Pass in 'local' to pass test. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either str or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[str] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._poll_with_constant_parameterized_endpoints_initial( + account_name=account_name, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + + if polling is True: + polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_poll_with_constant_parameterized_endpoints.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py new file mode 100644 index 00000000000..59c4ba416b2 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/operations/_lro_with_paramaterized_endpoints_operations.py @@ -0,0 +1,254 @@ +# 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace + +from .. import _rest as rest, models as _models + +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]] + + +class LROWithParamaterizedEndpointsOperationsMixin(object): + def _poll_with_parameterized_endpoints_initial( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_poll_with_parameterized_endpoints_request_initial( + template_url=self._poll_with_parameterized_endpoints_initial.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("str", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _poll_with_parameterized_endpoints_initial.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore + + @distributed_trace + def begin_poll_with_parameterized_endpoints( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[str] + """Poll with method and client level parameters in endpoint. + + :param account_name: Account Name. Pass in 'local' to pass test. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either str or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[str] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._poll_with_parameterized_endpoints_initial( + account_name=account_name, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + + if polling is True: + polling_method = LROBasePolling( + lro_delay, + lro_options={"final-state-via": "location"}, + path_format_arguments=path_format_arguments, + **kwargs + ) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_poll_with_parameterized_endpoints.metadata = {"url": "/lroParameterizedEndpoints"} # type: ignore + + def _poll_with_constant_parameterized_endpoints_initial( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_poll_with_constant_parameterized_endpoints_request_initial( + template_url=self._poll_with_constant_parameterized_endpoints_initial.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("str", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _poll_with_constant_parameterized_endpoints_initial.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore + + @distributed_trace + def begin_poll_with_constant_parameterized_endpoints( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[str] + """Poll with method and client level parameters in endpoint, with a constant value. + + :param account_name: Account Name. Pass in 'local' to pass test. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either str or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType[str] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._poll_with_constant_parameterized_endpoints_initial( + account_name=account_name, cls=lambda x, y, z: x, **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + + if polling is True: + polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_poll_with_constant_parameterized_endpoints.metadata = {"url": "/lroConstantParameterizedEndpoints/{constantParameter}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/py.typed b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/setup.py b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/setup.py new file mode 100644 index 00000000000..46be9af6e00 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/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 = "lrowithparamaterizedendpoints" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="LROWithParamaterizedEndpoints", + author_email="", + url="", + keywords=["Swagger", "LROWithParamaterizedEndpoints"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py new file mode 100644 index 00000000000..8633a1fb82b --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py @@ -0,0 +1,98 @@ +# 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 AutoRestPagingTestServiceConfiguration +from .operations import PagingOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestPagingTestService(object): + """Long-running Operation for AutoRest. + + :ivar paging: PagingOperations operations + :vartype paging: paging.operations.PagingOperations + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestPagingTestServiceConfiguration(**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.paging = PagingOperations(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. + + We have helper methods to create requests specific to this service in `paging.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from paging._rest import paging + >>> request = paging.build_get_no_item_name_pages_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestPagingTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_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/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/__init__.py new file mode 100644 index 00000000000..d49b2fb529e --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/__init__.py @@ -0,0 +1,73 @@ +# 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_get_no_item_name_pages_request + from ._request_builders_py3 import build_get_null_next_link_name_pages_request + from ._request_builders_py3 import build_get_single_pages_request + from ._request_builders_py3 import build_first_response_empty_request + from ._request_builders_py3 import build_get_multiple_pages_request + from ._request_builders_py3 import build_get_with_query_params_request + from ._request_builders_py3 import build_next_operation_with_query_params_request + from ._request_builders_py3 import build_get_odata_multiple_pages_request + from ._request_builders_py3 import build_get_multiple_pages_with_offset_request + from ._request_builders_py3 import build_get_multiple_pages_retry_first_request + from ._request_builders_py3 import build_get_multiple_pages_retry_second_request + from ._request_builders_py3 import build_get_single_pages_failure_request + from ._request_builders_py3 import build_get_multiple_pages_failure_request + from ._request_builders_py3 import build_get_multiple_pages_failure_uri_request + from ._request_builders_py3 import build_get_multiple_pages_fragment_next_link_request + from ._request_builders_py3 import build_get_multiple_pages_fragment_with_grouping_next_link_request + from ._request_builders_py3 import build_get_multiple_pages_lro_request_initial + from ._request_builders_py3 import build_next_fragment_request + from ._request_builders_py3 import build_next_fragment_with_grouping_request + from ._request_builders_py3 import build_get_paging_model_with_item_name_with_xms_client_name_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_no_item_name_pages_request # type: ignore + from ._request_builders import build_get_null_next_link_name_pages_request # type: ignore + from ._request_builders import build_get_single_pages_request # type: ignore + from ._request_builders import build_first_response_empty_request # type: ignore + from ._request_builders import build_get_multiple_pages_request # type: ignore + from ._request_builders import build_get_with_query_params_request # type: ignore + from ._request_builders import build_next_operation_with_query_params_request # type: ignore + from ._request_builders import build_get_odata_multiple_pages_request # type: ignore + from ._request_builders import build_get_multiple_pages_with_offset_request # type: ignore + from ._request_builders import build_get_multiple_pages_retry_first_request # type: ignore + from ._request_builders import build_get_multiple_pages_retry_second_request # type: ignore + from ._request_builders import build_get_single_pages_failure_request # type: ignore + from ._request_builders import build_get_multiple_pages_failure_request # type: ignore + from ._request_builders import build_get_multiple_pages_failure_uri_request # type: ignore + from ._request_builders import build_get_multiple_pages_fragment_next_link_request # type: ignore + from ._request_builders import build_get_multiple_pages_fragment_with_grouping_next_link_request # type: ignore + from ._request_builders import build_get_multiple_pages_lro_request_initial # type: ignore + from ._request_builders import build_next_fragment_request # type: ignore + from ._request_builders import build_next_fragment_with_grouping_request # type: ignore + from ._request_builders import build_get_paging_model_with_item_name_with_xms_client_name_request # type: ignore + +__all__ = [ + "build_get_no_item_name_pages_request", + "build_get_null_next_link_name_pages_request", + "build_get_single_pages_request", + "build_first_response_empty_request", + "build_get_multiple_pages_request", + "build_get_with_query_params_request", + "build_next_operation_with_query_params_request", + "build_get_odata_multiple_pages_request", + "build_get_multiple_pages_with_offset_request", + "build_get_multiple_pages_retry_first_request", + "build_get_multiple_pages_retry_second_request", + "build_get_single_pages_failure_request", + "build_get_multiple_pages_failure_request", + "build_get_multiple_pages_failure_uri_request", + "build_get_multiple_pages_fragment_next_link_request", + "build_get_multiple_pages_fragment_with_grouping_next_link_request", + "build_get_multiple_pages_lro_request_initial", + "build_next_fragment_request", + "build_next_fragment_with_grouping_request", + "build_get_paging_model_with_item_name_with_xms_client_name_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/_request_builders.py new file mode 100644 index 00000000000..8baaa47c8be --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/_request_builders.py @@ -0,0 +1,809 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_no_item_name_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that must return result of the default 'value' node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/noitemname') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_next_link_name_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/nullnextlink') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that finishes on the first call without a nextlink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_first_response_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/firstResponseEmpty/1') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_with_query_params_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_query_parameter: A required integer query parameter. Put in value '100' to + pass test. + :paramtype required_query_parameter: int + :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 + """ + + required_query_parameter = kwargs.pop('required_query_parameter') # type: int + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/getWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['requiredQueryParameter'] = _SERIALIZER.query("required_query_parameter", required_query_parameter, 'int') + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_operation_with_query_params_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/nextOperationWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_odata_multiple_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink in odata format that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/odata') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_with_offset_request( + offset, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param offset: Offset of return value. + :type offset: int + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/withpath/{offset}') + path_format_arguments = { + 'offset': _SERIALIZER.url("offset", offset, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_first_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retryfirst') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_second_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retrysecond') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_failure_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives a 400 on the first call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives a 400 on the second call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives an invalid nextLink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failureuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_next_link_request( + tenant, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/lro') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_request( + tenant, # type: str + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_with_grouping_request( + tenant, # type: str + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_paging_model_with_item_name_with_xms_client_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/itemNameWithXMSClientName') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/_request_builders_py3.py new file mode 100644 index 00000000000..839a8122547 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_rest/paging/_request_builders_py3.py @@ -0,0 +1,636 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_no_item_name_pages_request(**kwargs: Any) -> HttpRequest: + """A paging operation that must return result of the default 'value' node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/noitemname") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_next_link_name_pages_request(**kwargs: Any) -> HttpRequest: + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/nullnextlink") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_single_pages_request(**kwargs: Any) -> HttpRequest: + """A paging operation that finishes on the first call without a nextlink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/single") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_first_response_empty_request(**kwargs: Any) -> HttpRequest: + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/firstResponseEmpty/1") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_with_query_params_request(*, required_query_parameter: int, **kwargs: Any) -> HttpRequest: + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_query_parameter: A required integer query parameter. Put in value '100' to + pass test. + :paramtype required_query_parameter: int + :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 + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/getWithQueryParams") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["requiredQueryParameter"] = _SERIALIZER.query( + "required_query_parameter", required_query_parameter, "int" + ) + query_parameters["queryConstant"] = _SERIALIZER.query("query_constant", query_constant, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_next_operation_with_query_params_request(**kwargs: Any) -> HttpRequest: + """Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/nextOperationWithQueryParams") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["queryConstant"] = _SERIALIZER.query("query_constant", query_constant, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_odata_multiple_pages_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink in odata format that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/odata") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_with_offset_request( + offset: int, + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param offset: Offset of return value. + :type offset: int + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/withpath/{offset}") + path_format_arguments = { + "offset": _SERIALIZER.url("offset", offset, "int"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_retry_first_request(**kwargs: Any) -> HttpRequest: + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/retryfirst") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_retry_second_request(**kwargs: Any) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/retrysecond") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_single_pages_failure_request(**kwargs: Any) -> HttpRequest: + """A paging operation that receives a 400 on the first call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/single/failure") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_failure_request(**kwargs: Any) -> HttpRequest: + """A paging operation that receives a 400 on the second call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/failure") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_failure_uri_request(**kwargs: Any) -> HttpRequest: + """A paging operation that receives an invalid nextLink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/failureuri") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_fragment_next_link_request(tenant: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragment/{tenant}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant: str, *, api_version: str, **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragmentwithgrouping/{tenant}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_lro_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/lro") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_next_fragment_request(tenant: str, next_link: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragment/{tenant}/{nextLink}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_next_fragment_with_grouping_request( + tenant: str, next_link: str, *, api_version: str, **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_paging_model_with_item_name_with_xms_client_name_request(**kwargs: Any) -> HttpRequest: + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/itemNameWithXMSClientName") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/_version.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_version.py diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py new file mode 100644 index 00000000000..91473dc9c69 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py @@ -0,0 +1,80 @@ +# 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 AutoRestPagingTestServiceConfiguration +from .operations import PagingOperations + + +class AutoRestPagingTestService: + """Long-running Operation for AutoRest. + + :ivar paging: PagingOperations operations + :vartype paging: paging.aio.operations.PagingOperations + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestPagingTestServiceConfiguration(**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.paging = PagingOperations(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. + + We have helper methods to create requests specific to this service in `paging.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from paging._rest import paging + >>> request = paging.build_get_no_item_name_pages_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestPagingTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py new file mode 100644 index 00000000000..f6f9a2ff922 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py @@ -0,0 +1,1211 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async + +from ... import models as _models +from ..._rest import paging as rest_paging + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PagingOperations: + """PagingOperations 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: ~paging.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 + def get_no_item_name_pages(self, **kwargs: Any) -> AsyncIterable["_models.ProductResultValue"]: + """A paging operation that must return result of the default 'value' node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=self.get_no_item_name_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResultValue", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_no_item_name_pages.metadata = {"url": "/paging/noitemname"} # type: ignore + + @distributed_trace + def get_null_next_link_name_pages(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=self.get_null_next_link_name_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_null_next_link_name_pages.metadata = {"url": "/paging/nullnextlink"} # type: ignore + + @distributed_trace + def get_single_pages(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that finishes on the first call without a nextlink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_request( + template_url=self.get_single_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_single_pages.metadata = {"url": "/paging/single"} # type: ignore + + @distributed_trace + def first_response_empty(self, **kwargs: Any) -> AsyncIterable["_models.ProductResultValue"]: + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_first_response_empty_request( + template_url=self.first_response_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_first_response_empty_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResultValue", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + first_response_empty.metadata = {"url": "/paging/firstResponseEmpty/1"} # type: ignore + + @distributed_trace + def get_multiple_pages( + self, + client_request_id: Optional[str] = None, + paging_get_multiple_pages_options: Optional["_models.PagingGetMultiplePagesOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_options: Parameter group. + :type paging_get_multiple_pages_options: ~paging.models.PagingGetMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages.metadata = {"url": "/paging/multiple"} # type: ignore + + @distributed_trace + def get_with_query_params( + self, required_query_parameter: int, **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + :param required_query_parameter: A required integer query parameter. Put in value '100' to pass + test. + :type required_query_parameter: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_with_query_params_request( + required_query_parameter=required_query_parameter, + template_url=self.get_with_query_params.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_operation_with_query_params_request( + template_url="/paging/multiple/nextOperationWithQueryParams", + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_with_query_params.metadata = {"url": "/paging/multiple/getWithQueryParams"} # type: ignore + + @distributed_trace + def get_odata_multiple_pages( + self, + client_request_id: Optional[str] = None, + paging_get_odata_multiple_pages_options: Optional["_models.PagingGetOdataMultiplePagesOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.OdataProductResult"]: + """A paging operation that includes a nextLink in odata format that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_odata_multiple_pages_options: Parameter group. + :type paging_get_odata_multiple_pages_options: + ~paging.models.PagingGetOdataMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_odata_multiple_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OdataProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_odata_multiple_pages.metadata = {"url": "/paging/multiple/odata"} # type: ignore + + @distributed_trace + def get_multiple_pages_with_offset( + self, + paging_get_multiple_pages_with_offset_options: "_models.PagingGetMultiplePagesWithOffsetOptions", + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a nextLink that has 10 pages. + + :param paging_get_multiple_pages_with_offset_options: Parameter group. + :type paging_get_multiple_pages_with_offset_options: + ~paging.models.PagingGetMultiplePagesWithOffsetOptions + :param client_request_id: + :type client_request_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages_with_offset.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_with_offset.metadata = {"url": "/paging/multiple/withpath/{offset}"} # type: ignore + + @distributed_trace + def get_multiple_pages_retry_first(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=self.get_multiple_pages_retry_first.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_retry_first.metadata = {"url": "/paging/multiple/retryfirst"} # type: ignore + + @distributed_trace + def get_multiple_pages_retry_second(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=self.get_multiple_pages_retry_second.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_retry_second.metadata = {"url": "/paging/multiple/retrysecond"} # type: ignore + + @distributed_trace + def get_single_pages_failure(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that receives a 400 on the first call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=self.get_single_pages_failure.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_single_pages_failure.metadata = {"url": "/paging/single/failure"} # type: ignore + + @distributed_trace + def get_multiple_pages_failure(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that receives a 400 on the second call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=self.get_multiple_pages_failure.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_failure.metadata = {"url": "/paging/multiple/failure"} # type: ignore + + @distributed_trace + def get_multiple_pages_failure_uri(self, **kwargs: Any) -> AsyncIterable["_models.ProductResult"]: + """A paging operation that receives an invalid nextLink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=self.get_multiple_pages_failure_uri.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_failure_uri.metadata = {"url": "/paging/multiple/failureuri"} # type: ignore + + @distributed_trace + def get_multiple_pages_fragment_next_link( + self, api_version: str, tenant: str, **kwargs: Any + ) -> AsyncIterable["_models.OdataProductResult"]: + """A paging operation that doesn't return a full URL, just a fragment. + + :param api_version: Sets the api version to use. + :type api_version: str + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_fragment_next_link_request( + tenant=tenant, + api_version=api_version, + template_url=self.get_multiple_pages_fragment_next_link.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_fragment_request( + tenant=tenant, + next_link=next_link, + api_version=api_version, + template_url="/paging/multiple/fragment/{tenant}/{nextLink}", + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OdataProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_fragment_next_link.metadata = {"url": "/paging/multiple/fragment/{tenant}"} # type: ignore + + @distributed_trace + def get_multiple_pages_fragment_with_grouping_next_link( + self, custom_parameter_group: "_models.CustomParameterGroup", **kwargs: Any + ) -> AsyncIterable["_models.OdataProductResult"]: + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + :param custom_parameter_group: Parameter group. + :type custom_parameter_group: ~paging.models.CustomParameterGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant=_tenant, + api_version=_api_version, + template_url=self.get_multiple_pages_fragment_with_grouping_next_link.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_next_fragment_with_grouping_request( + tenant=_tenant, + next_link=next_link, + api_version=_api_version, + template_url="/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}", + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OdataProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_multiple_pages_fragment_with_grouping_next_link.metadata = {"url": "/paging/multiple/fragmentwithgrouping/{tenant}"} # type: ignore + + async def _get_multiple_pages_lro_initial( + self, + client_request_id: Optional[str] = None, + paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, + **kwargs: Any + ) -> "_models.ProductResult": + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._get_multiple_pages_lro_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ProductResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _get_multiple_pages_lro_initial.metadata = {"url": "/paging/multiple/lro"} # type: ignore + + @distributed_trace_async + async def begin_get_multiple_pages_lro( + self, + client_request_id: Optional[str] = None, + paging_get_multiple_pages_lro_options: Optional["_models.PagingGetMultiplePagesLroOptions"] = None, + **kwargs: Any + ) -> AsyncLROPoller[AsyncItemPaged["_models.ProductResult"]]: + """A long-running paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_lro_options: Parameter group. + :type paging_get_multiple_pages_lro_options: ~paging.models.PagingGetMultiplePagesLroOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + ProductResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResult]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_get_multiple_pages_lro.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._get_multiple_pages_lro_initial( + client_request_id=client_request_id, + paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, + cls=lambda x, y, z: x, + **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + async def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + else: + return await get_next(next_link) + + return AsyncItemPaged(internal_get_next, extract_data) + + if polling is True: + polling_method = AsyncLROBasePolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_get_multiple_pages_lro.metadata = {"url": "/paging/multiple/lro"} # type: ignore + + @distributed_trace + def get_paging_model_with_item_name_with_xms_client_name( + self, **kwargs: Any + ) -> AsyncIterable["_models.ProductResultValueWithXMSClientName"]: + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValueWithXMSClientName] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=self.get_paging_model_with_item_name_with_xms_client_name.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResultValueWithXMSClientName", pipeline_response) + list_of_elem = deserialized.indexes + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_paging_model_with_item_name_with_xms_client_name.metadata = {"url": "/paging/itemNameWithXMSClientName"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/models/_auto_rest_paging_test_service_enums.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/_auto_rest_paging_test_service_enums.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/models/_auto_rest_paging_test_service_enums.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/_auto_rest_paging_test_service_enums.py diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py new file mode 100644 index 00000000000..e2429f0f292 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py @@ -0,0 +1,1254 @@ +# 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.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace + +from .. import models as _models +from .._rest import paging as rest_paging + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class PagingOperations(object): + """PagingOperations 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: ~paging.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 get_no_item_name_pages( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResultValue"] + """A paging operation that must return result of the default 'value' node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=self.get_no_item_name_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_no_item_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResultValue", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_no_item_name_pages.metadata = {"url": "/paging/noitemname"} # type: ignore + + @distributed_trace + def get_null_next_link_name_pages( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=self.get_null_next_link_name_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_null_next_link_name_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_null_next_link_name_pages.metadata = {"url": "/paging/nullnextlink"} # type: ignore + + @distributed_trace + def get_single_pages( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that finishes on the first call without a nextlink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_request( + template_url=self.get_single_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_single_pages.metadata = {"url": "/paging/single"} # type: ignore + + @distributed_trace + def first_response_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResultValue"] + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValue] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_first_response_empty_request( + template_url=self.first_response_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_first_response_empty_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResultValue", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + first_response_empty.metadata = {"url": "/paging/firstResponseEmpty/1"} # type: ignore + + @distributed_trace + def get_multiple_pages( + self, + client_request_id=None, # type: Optional[str] + paging_get_multiple_pages_options=None, # type: Optional["_models.PagingGetMultiplePagesOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_options: Parameter group. + :type paging_get_multiple_pages_options: ~paging.models.PagingGetMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_options is not None: + _maxresults = paging_get_multiple_pages_options.maxresults + _timeout = paging_get_multiple_pages_options.timeout + + request = rest_paging.build_get_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages.metadata = {"url": "/paging/multiple"} # type: ignore + + @distributed_trace + def get_with_query_params( + self, + required_query_parameter, # type: int + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + :param required_query_parameter: A required integer query parameter. Put in value '100' to pass + test. + :type required_query_parameter: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_with_query_params_request( + required_query_parameter=required_query_parameter, + template_url=self.get_with_query_params.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_operation_with_query_params_request( + template_url="/paging/multiple/nextOperationWithQueryParams", + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_with_query_params.metadata = {"url": "/paging/multiple/getWithQueryParams"} # type: ignore + + @distributed_trace + def get_odata_multiple_pages( + self, + client_request_id=None, # type: Optional[str] + paging_get_odata_multiple_pages_options=None, # type: Optional["_models.PagingGetOdataMultiplePagesOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OdataProductResult"] + """A paging operation that includes a nextLink in odata format that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_odata_multiple_pages_options: Parameter group. + :type paging_get_odata_multiple_pages_options: + ~paging.models.PagingGetOdataMultiplePagesOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_odata_multiple_pages.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_odata_multiple_pages_options is not None: + _maxresults = paging_get_odata_multiple_pages_options.maxresults + _timeout = paging_get_odata_multiple_pages_options.timeout + + request = rest_paging.build_get_odata_multiple_pages_request( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OdataProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_odata_multiple_pages.metadata = {"url": "/paging/multiple/odata"} # type: ignore + + @distributed_trace + def get_multiple_pages_with_offset( + self, + paging_get_multiple_pages_with_offset_options, # type: "_models.PagingGetMultiplePagesWithOffsetOptions" + client_request_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a nextLink that has 10 pages. + + :param paging_get_multiple_pages_with_offset_options: Parameter group. + :type paging_get_multiple_pages_with_offset_options: + ~paging.models.PagingGetMultiplePagesWithOffsetOptions + :param client_request_id: + :type client_request_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.get_multiple_pages_with_offset.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _offset = None + _timeout = None + if paging_get_multiple_pages_with_offset_options is not None: + _maxresults = paging_get_multiple_pages_with_offset_options.maxresults + _offset = paging_get_multiple_pages_with_offset_options.offset + _timeout = paging_get_multiple_pages_with_offset_options.timeout + + request = rest_paging.build_get_multiple_pages_with_offset_request( + offset=_offset, + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_with_offset.metadata = {"url": "/paging/multiple/withpath/{offset}"} # type: ignore + + @distributed_trace + def get_multiple_pages_retry_first( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=self.get_multiple_pages_retry_first.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_first_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_retry_first.metadata = {"url": "/paging/multiple/retryfirst"} # type: ignore + + @distributed_trace + def get_multiple_pages_retry_second( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=self.get_multiple_pages_retry_second.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_retry_second_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_retry_second.metadata = {"url": "/paging/multiple/retrysecond"} # type: ignore + + @distributed_trace + def get_single_pages_failure( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that receives a 400 on the first call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=self.get_single_pages_failure.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_single_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_single_pages_failure.metadata = {"url": "/paging/single/failure"} # type: ignore + + @distributed_trace + def get_multiple_pages_failure( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that receives a 400 on the second call. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=self.get_multiple_pages_failure.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_failure.metadata = {"url": "/paging/multiple/failure"} # type: ignore + + @distributed_trace + def get_multiple_pages_failure_uri( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResult"] + """A paging operation that receives an invalid nextLink. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=self.get_multiple_pages_failure_uri.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_multiple_pages_failure_uri_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_failure_uri.metadata = {"url": "/paging/multiple/failureuri"} # type: ignore + + @distributed_trace + def get_multiple_pages_fragment_next_link( + self, + api_version, # type: str + tenant, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OdataProductResult"] + """A paging operation that doesn't return a full URL, just a fragment. + + :param api_version: Sets the api version to use. + :type api_version: str + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_multiple_pages_fragment_next_link_request( + tenant=tenant, + api_version=api_version, + template_url=self.get_multiple_pages_fragment_next_link.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_next_fragment_request( + tenant=tenant, + next_link=next_link, + api_version=api_version, + template_url="/paging/multiple/fragment/{tenant}/{nextLink}", + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OdataProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_fragment_next_link.metadata = {"url": "/paging/multiple/fragment/{tenant}"} # type: ignore + + @distributed_trace + def get_multiple_pages_fragment_with_grouping_next_link( + self, + custom_parameter_group, # type: "_models.CustomParameterGroup" + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OdataProductResult"] + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + :param custom_parameter_group: Parameter group. + :type custom_parameter_group: ~paging.models.CustomParameterGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OdataProductResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.OdataProductResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.OdataProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant=_tenant, + api_version=_api_version, + template_url=self.get_multiple_pages_fragment_with_grouping_next_link.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _api_version = None + _tenant = None + if custom_parameter_group is not None: + _api_version = custom_parameter_group.api_version + _tenant = custom_parameter_group.tenant + + request = rest_paging.build_next_fragment_with_grouping_request( + tenant=_tenant, + next_link=next_link, + api_version=_api_version, + template_url="/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}", + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OdataProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.odata_next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_multiple_pages_fragment_with_grouping_next_link.metadata = {"url": "/paging/multiple/fragmentwithgrouping/{tenant}"} # type: ignore + + def _get_multiple_pages_lro_initial( + self, + client_request_id=None, # type: Optional[str] + paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] + **kwargs # type: Any + ): + # type: (...) -> "_models.ProductResult" + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._get_multiple_pages_lro_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ProductResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _get_multiple_pages_lro_initial.metadata = {"url": "/paging/multiple/lro"} # type: ignore + + @distributed_trace + def begin_get_multiple_pages_lro( + self, + client_request_id=None, # type: Optional[str] + paging_get_multiple_pages_lro_options=None, # type: Optional["_models.PagingGetMultiplePagesLroOptions"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[ItemPaged["_models.ProductResult"]] + """A long-running paging operation that includes a nextLink that has 10 pages. + + :param client_request_id: + :type client_request_id: str + :param paging_get_multiple_pages_lro_options: Parameter group. + :type paging_get_multiple_pages_lro_options: ~paging.models.PagingGetMultiplePagesLroOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either + ProductResult or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~paging.models.ProductResult]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_get_multiple_pages_lro.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + _maxresults = None + _timeout = None + if paging_get_multiple_pages_lro_options is not None: + _maxresults = paging_get_multiple_pages_lro_options.maxresults + _timeout = paging_get_multiple_pages_lro_options.timeout + + request = rest_paging.build_get_multiple_pages_lro_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResult", pipeline_response) + list_of_elem = deserialized.values + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResult"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._get_multiple_pages_lro_initial( + client_request_id=client_request_id, + paging_get_multiple_pages_lro_options=paging_get_multiple_pages_lro_options, + cls=lambda x, y, z: x, + **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + + def get_long_running_output(pipeline_response): + def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + else: + return get_next(next_link) + + return ItemPaged(internal_get_next, extract_data) + + if polling is True: + polling_method = LROBasePolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_get_multiple_pages_lro.metadata = {"url": "/paging/multiple/lro"} # type: ignore + + @distributed_trace + def get_paging_model_with_item_name_with_xms_client_name( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProductResultValueWithXMSClientName"] + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductResultValueWithXMSClientName or the result + of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValueWithXMSClientName] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ProductResultValueWithXMSClientName"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=self.get_paging_model_with_item_name_with_xms_client_name.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_paging.build_get_paging_model_with_item_name_with_xms_client_name_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductResultValueWithXMSClientName", pipeline_response) + list_of_elem = deserialized.indexes + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_paging_model_with_item_name_with_xms_client_name.metadata = {"url": "/paging/itemNameWithXMSClientName"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/py.typed b/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/Paging/paging/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/Paging/paging/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/Paging/setup.py b/test/azure/legacy/Expected/AcceptanceTests/Paging/setup.py new file mode 100644 index 00000000000..fa06e332afe --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/Paging/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 = "autorestpagingtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestPagingTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestPagingTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Long-running Operation for AutoRest. + """, +) diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/setup.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/setup.py new file mode 100644 index 00000000000..ebf00958336 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/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 = "storagemanagementclient" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="StorageManagementClient", + author_email="", + url="", + keywords=["Swagger", "StorageManagementClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + StorageManagementClient. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_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/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/__init__.py new file mode 100644 index 00000000000..ca5620eb668 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/__init__.py @@ -0,0 +1,40 @@ +# 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_check_name_availability_request + from ._request_builders_py3 import build_create_request_initial + from ._request_builders_py3 import build_delete_request + from ._request_builders_py3 import build_get_properties_request + from ._request_builders_py3 import build_update_request + from ._request_builders_py3 import build_list_keys_request + from ._request_builders_py3 import build_list_request + from ._request_builders_py3 import build_list_by_resource_group_request + from ._request_builders_py3 import build_regenerate_key_request +except (SyntaxError, ImportError): + from ._request_builders import build_check_name_availability_request # type: ignore + from ._request_builders import build_create_request_initial # type: ignore + from ._request_builders import build_delete_request # type: ignore + from ._request_builders import build_get_properties_request # type: ignore + from ._request_builders import build_update_request # type: ignore + from ._request_builders import build_list_keys_request # type: ignore + from ._request_builders import build_list_request # type: ignore + from ._request_builders import build_list_by_resource_group_request # type: ignore + from ._request_builders import build_regenerate_key_request # type: ignore + +__all__ = [ + "build_check_name_availability_request", + "build_create_request_initial", + "build_delete_request", + "build_get_properties_request", + "build_update_request", + "build_list_keys_request", + "build_list_request", + "build_list_by_resource_group_request", + "build_regenerate_key_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/_request_builders.py new file mode 100644 index 00000000000..6f655404653 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/_request_builders.py @@ -0,0 +1,539 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_check_name_availability_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Checks that account name is valid and is not in use. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Asynchronously creates a new storage account with the specified parameters. Existing accounts + cannot be updated with this API and should instead use the Update Storage Account API. If an + account is already created and subsequent PUT request is issued with exact same set of + properties, then HTTP 200 would be returned. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to provide for the created account. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to provide for the created account. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Deletes a storage account in Microsoft Azure. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_properties_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns the properties for the specified storage account including but not limited to name, + account type, location, and account status. The ListKeys operation should be used to retrieve + storage keys. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Updates the account type or tags for a storage account. It can also be used to add a custom + domain (note that custom domains cannot be added via the Create operation). Only one custom + domain is supported per storage account. This API can only be used to update one of tags, + accountType, or customDomain per call. To update multiple of these properties, call the API + multiple times with one change per call. This call does not change the storage keys for the + account. If you want to change storage account keys, use the RegenerateKey operation. The + location and name of the storage account cannot be changed after creation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to update on the account. Note that only + one property can be changed at a time using this API. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to update on the account. Note that only one + property can be changed at a time using this API. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_key_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Regenerates the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Specifies name of the key which should be regenerated. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Specifies name of the key which should be regenerated. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/_request_builders_py3.py new file mode 100644 index 00000000000..6a630d9358d --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/storage_accounts/_request_builders_py3.py @@ -0,0 +1,501 @@ +# 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, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_check_name_availability_request( + subscription_id: str, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Checks that account name is valid and is not in use. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_create_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Asynchronously creates a new storage account with the specified parameters. Existing accounts + cannot be updated with this API and should instead use the Update Storage Account API. If an + account is already created and subsequent PUT request is issued with exact same set of + properties, then HTTP 200 would be returned. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to provide for the created account. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to provide for the created account. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_delete_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + """Deletes a storage account in Microsoft Azure. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=url, params=query_parameters, **kwargs) + + +def build_get_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + """Returns the properties for the specified storage account including but not limited to name, + account type, location, and account status. The ListKeys operation should be used to retrieve + storage keys. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Updates the account type or tags for a storage account. It can also be used to add a custom + domain (note that custom domains cannot be added via the Create operation). Only one custom + domain is supported per storage account. This API can only be used to update one of tags, + accountType, or customDomain per call. To update multiple of these properties, call the API + multiple times with one change per call. This call does not change the storage keys for the + account. If you want to change storage account keys, use the RegenerateKey operation. The + location and name of the storage account cannot be changed after creation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to update on the account. Note that only + one property can be changed at a time using this API. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to update on the account. Note that only one + property can be changed at a time using this API. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + """Lists the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_regenerate_key_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Regenerates the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Specifies name of the key which should be regenerated. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Specifies name of the key which should be regenerated. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/__init__.py new file mode 100644 index 00000000000..fbe313bf81a --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/__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_list_request +except (SyntaxError, ImportError): + from ._request_builders import build_list_request # type: ignore + +__all__ = [ + "build_list_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/_request_builders.py new file mode 100644 index 00000000000..76e27617754 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/_request_builders.py @@ -0,0 +1,64 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets the current usage count and the limit for the resources under the subscription. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/_request_builders_py3.py new file mode 100644 index 00000000000..b57a7965bb7 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_rest/usage/_request_builders_py3.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 Any, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """Gets the current usage count and the limit for the resources under the subscription. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_storage_management_client.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_storage_management_client.py new file mode 100644 index 00000000000..97a659154c5 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_storage_management_client.py @@ -0,0 +1,111 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import StorageManagementClientConfiguration +from .operations import StorageAccountsOperations, UsageOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class StorageManagementClient(object): + """StorageManagementClient. + + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: storage.operations.StorageAccountsOperations + :ivar usage: UsageOperations operations + :vartype usage: storage.operations.UsageOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "https://management.azure.com" + self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(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.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations(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. + + We have helper methods to create requests specific to this service in `storage.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from storage._rest import storage_accounts + >>> request = storage_accounts.build_check_name_availability_request(subscription_id, json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> StorageManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_version.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_version.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_storage_management_client.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_storage_management_client.py new file mode 100644 index 00000000000..76fd35a224c --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/_storage_management_client.py @@ -0,0 +1,96 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import StorageManagementClientConfiguration +from .operations import StorageAccountsOperations, UsageOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClient: + """StorageManagementClient. + + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: storage.aio.operations.StorageAccountsOperations + :ivar usage: UsageOperations operations + :vartype usage: storage.aio.operations.UsageOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + if not base_url: + base_url = "https://management.azure.com" + self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(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.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations(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. + + We have helper methods to create requests specific to this service in `storage.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from storage._rest import storage_accounts + >>> request = storage_accounts.build_check_name_availability_request(subscription_id, json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "StorageManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py new file mode 100644 index 00000000000..0f01392c441 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_storage_accounts_operations.py @@ -0,0 +1,606 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._rest import storage_accounts as rest_storage_accounts + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StorageAccountsOperations: + """StorageAccountsOperations 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: ~storage.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 check_name_availability( + self, account_name: "_models.StorageAccountCheckNameAvailabilityParameters", **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": + """Checks that account name is valid and is not in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: ~storage.models.StorageAccountCheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult, or the result of cls(response) + :rtype: ~storage.models.CheckNameAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.CheckNameAvailabilityResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") + + request = rest_storage_accounts.build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self.check_name_availability.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: "_models.StorageAccountCreateParameters", + **kwargs: Any + ) -> Optional["_models.StorageAccount"]: + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.StorageAccount"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = rest_storage_accounts.build_create_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self._create_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: "_models.StorageAccountCreateParameters", + **kwargs: Any + ) -> AsyncLROPoller["_models.StorageAccount"]: + """Asynchronously creates a new storage account with the specified parameters. Existing accounts + cannot be updated with this API and should instead use the Update Storage Account API. If an + account is already created and subsequent PUT request is issued with exact same set of + properties, then HTTP 200 would be returned. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for the created account. + :type parameters: ~storage.models.StorageAccountCreateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~storage.models.StorageAccount] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + cls=lambda x, y, z: x, + **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = AsyncNoPolling() + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: 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", {})) + + request = rest_storage_accounts.build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def get_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> "_models.StorageAccount": + """Returns the properties for the specified storage account including but not limited to name, + account type, location, and account status. The ListKeys operation should be used to retrieve + storage keys. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~storage.models.StorageAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_storage_accounts.build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.get_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: "_models.StorageAccountUpdateParameters", + **kwargs: Any + ) -> "_models.StorageAccount": + """Updates the account type or tags for a storage account. It can also be used to add a custom + domain (note that custom domains cannot be added via the Create operation). Only one custom + domain is supported per storage account. This API can only be used to update one of tags, + accountType, or customDomain per call. To update multiple of these properties, call the API + multiple times with one change per call. This call does not change the storage keys for the + account. If you want to change storage account keys, use the RegenerateKey operation. The + location and name of the storage account cannot be changed after creation. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to update on the account. Note that only one property can be + changed at a time using this API. + :type parameters: ~storage.models.StorageAccountUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~storage.models.StorageAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(parameters, "StorageAccountUpdateParameters") + + request = rest_storage_accounts.build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self.update.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> "_models.StorageAccountKeys": + """Lists the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountKeys, or the result of cls(response) + :rtype: ~storage.models.StorageAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_storage_accounts.build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_keys.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccountListResult"]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccountListResult or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_storage_accounts.build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_storage_accounts.build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountListResult"]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccountListResult or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_storage_accounts.build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_storage_accounts.build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + key_name: Optional[Union[str, "_models.KeyName"]] = None, + **kwargs: Any + ) -> "_models.StorageAccountKeys": + """Regenerates the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param key_name: + :type key_name: str or ~storage.models.KeyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountKeys, or the result of cls(response) + :rtype: ~storage.models.StorageAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _regenerate_key = _models.StorageAccountRegenerateKeyParameters(key_name=key_name) + json = self._serialize.body(_regenerate_key, "StorageAccountRegenerateKeyParameters") + + request = rest_storage_accounts.build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self.regenerate_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.py new file mode 100644 index 00000000000..be9c7b255f7 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations/_usage_operations.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. +# -------------------------------------------------------------------------- +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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import usage as rest_usage + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UsageOperations: + """UsageOperations 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: ~storage.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 list(self, **kwargs: Any) -> "_models.UsageListResult": + """Gets the current usage count and the limit for the resources under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UsageListResult, or the result of cls(response) + :rtype: ~storage.models.UsageListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.UsageListResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_usage.build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UsageListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/_storage_management_client_enums.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/_storage_management_client_enums.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/models/_storage_management_client_enums.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/models/_storage_management_client_enums.py diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py new file mode 100644 index 00000000000..de04018f691 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py @@ -0,0 +1,622 @@ +# 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.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._rest import storage_accounts as rest_storage_accounts + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class StorageAccountsOperations(object): + """StorageAccountsOperations 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: ~storage.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 check_name_availability( + self, + account_name, # type: "_models.StorageAccountCheckNameAvailabilityParameters" + **kwargs # type: Any + ): + # type: (...) -> "_models.CheckNameAvailabilityResult" + """Checks that account name is valid and is not in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: ~storage.models.StorageAccountCheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult, or the result of cls(response) + :rtype: ~storage.models.CheckNameAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.CheckNameAvailabilityResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") + + request = rest_storage_accounts.build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self.check_name_availability.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore + + def _create_initial( + self, + resource_group_name, # type: str + account_name, # type: str + parameters, # type: "_models.StorageAccountCreateParameters" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.StorageAccount"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.StorageAccount"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = rest_storage_accounts.build_create_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self._create_initial.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def begin_create( + self, + resource_group_name, # type: str + account_name, # type: str + parameters, # type: "_models.StorageAccountCreateParameters" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.StorageAccount"] + """Asynchronously creates a new storage account with the specified parameters. Existing accounts + cannot be updated with this API and should instead use the Update Storage Account API. If an + account is already created and subsequent PUT request is issued with exact same set of + properties, then HTTP 200 would be returned. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for the created account. + :type parameters: ~storage.models.StorageAccountCreateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~storage.models.StorageAccount] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + cls=lambda x, y, z: x, + **kwargs + ) + + kwargs.pop("error_map", None) + kwargs.pop("content_type", None) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: + polling_method = NoPolling() + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def delete( + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: 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", {})) + + request = rest_storage_accounts.build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def get_properties( + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.StorageAccount" + """Returns the properties for the specified storage account including but not limited to name, + account type, location, and account status. The ListKeys operation should be used to retrieve + storage keys. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~storage.models.StorageAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_storage_accounts.build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.get_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name, # type: str + account_name, # type: str + parameters, # type: "_models.StorageAccountUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "_models.StorageAccount" + """Updates the account type or tags for a storage account. It can also be used to add a custom + domain (note that custom domains cannot be added via the Create operation). Only one custom + domain is supported per storage account. This API can only be used to update one of tags, + accountType, or customDomain per call. To update multiple of these properties, call the API + multiple times with one change per call. This call does not change the storage keys for the + account. If you want to change storage account keys, use the RegenerateKey operation. The + location and name of the storage account cannot be changed after creation. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to update on the account. Note that only one property can be + changed at a time using this API. + :type parameters: ~storage.models.StorageAccountUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~storage.models.StorageAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccount"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(parameters, "StorageAccountUpdateParameters") + + request = rest_storage_accounts.build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self.update.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def list_keys( + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.StorageAccountKeys" + """Lists the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountKeys, or the result of cls(response) + :rtype: ~storage.models.StorageAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_storage_accounts.build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_keys.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + + @distributed_trace + def list( + self, **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.StorageAccountListResult"] + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccountListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~storage.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_storage_accounts.build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_storage_accounts.build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.StorageAccountListResult"] + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccountListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~storage.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountListResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + def prepare_request(next_link=None): + if not next_link: + + request = rest_storage_accounts.build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + else: + + request = rest_storage_accounts.build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def regenerate_key( + self, + resource_group_name, # type: str + account_name, # type: str + key_name=None, # type: Optional[Union[str, "_models.KeyName"]] + **kwargs # type: Any + ): + # type: (...) -> "_models.StorageAccountKeys" + """Regenerates the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param key_name: + :type key_name: str or ~storage.models.KeyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountKeys, or the result of cls(response) + :rtype: ~storage.models.StorageAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageAccountKeys"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _regenerate_key = _models.StorageAccountRegenerateKeyParameters(key_name=key_name) + json = self._serialize.body(_regenerate_key, "StorageAccountRegenerateKeyParameters") + + request = rest_storage_accounts.build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=json, + template_url=self.regenerate_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py new file mode 100644 index 00000000000..200c5d74da0 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_usage_operations.py @@ -0,0 +1,94 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import usage as rest_usage + +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]] + + +class UsageOperations(object): + """UsageOperations 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: ~storage.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 list( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.UsageListResult" + """Gets the current usage count and the limit for the resources under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UsageListResult, or the result of cls(response) + :rtype: ~storage.models.UsageListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.UsageListResult"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_usage.build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UsageListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/py.typed b/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/py.typed diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py new file mode 100644 index 00000000000..eadaad6a419 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/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 = "microsoftazuretesturl" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="MicrosoftAzureTestUrl", + author_email="", + url="", + keywords=["Swagger", "MicrosoftAzureTestUrl"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Some cool documentation. + """, +) diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_microsoft_azure_test_url.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_microsoft_azure_test_url.py new file mode 100644 index 00000000000..2ff27413866 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_microsoft_azure_test_url.py @@ -0,0 +1,103 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import MicrosoftAzureTestUrlConfiguration +from .operations import GroupOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class MicrosoftAzureTestUrl(object): + """Some cool documentation. + + :ivar group: GroupOperations operations + :vartype group: subscriptionidapiversion.operations.GroupOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription Id. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = MicrosoftAzureTestUrlConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(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.group = GroupOperations(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. + + We have helper methods to create requests specific to this service in `subscriptionidapiversion.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from subscriptionidapiversion._rest import group + >>> request = group.build_get_sample_resource_group_request(subscription_id, resource_group_name, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> MicrosoftAzureTestUrl + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_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/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/__init__.py new file mode 100644 index 00000000000..8b64bc9508a --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/__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_get_sample_resource_group_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_sample_resource_group_request # type: ignore + +__all__ = [ + "build_get_sample_resource_group_request", +] diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/_request_builders.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/_request_builders.py new file mode 100644 index 00000000000..04d2905b561 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/_request_builders.py @@ -0,0 +1,67 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_sample_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Provides a resouce group with name 'testgroup101' and location 'West US'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param resource_group_name: Resource Group name 'testgroup101'. + :type resource_group_name: str + :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 + """ + + api_version = "2014-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/_request_builders_py3.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/_request_builders_py3.py new file mode 100644 index 00000000000..206cac0eaf6 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_rest/group/_request_builders_py3.py @@ -0,0 +1,53 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_sample_resource_group_request( + subscription_id: str, resource_group_name: str, **kwargs: Any +) -> HttpRequest: + """Provides a resouce group with name 'testgroup101' and location 'West US'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param resource_group_name: Resource Group name 'testgroup101'. + :type resource_group_name: str + :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 + """ + + api_version = "2014-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_version.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_version.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_version.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_version.py diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_configuration.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_configuration.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_configuration.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_configuration.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_microsoft_azure_test_url.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_microsoft_azure_test_url.py new file mode 100644 index 00000000000..1b8caa28e7f --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/_microsoft_azure_test_url.py @@ -0,0 +1,88 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import MicrosoftAzureTestUrlConfiguration +from .operations import GroupOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MicrosoftAzureTestUrl: + """Some cool documentation. + + :ivar group: GroupOperations operations + :vartype group: subscriptionidapiversion.aio.operations.GroupOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription Id. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = MicrosoftAzureTestUrlConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(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.group = GroupOperations(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. + + We have helper methods to create requests specific to this service in `subscriptionidapiversion.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from subscriptionidapiversion._rest import group + >>> request = group.build_get_sample_resource_group_request(subscription_id, resource_group_name, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "MicrosoftAzureTestUrl": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py new file mode 100644 index 00000000000..440c83d7242 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/aio/operations/_group_operations.py @@ -0,0 +1,93 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._rest import group as rest_group + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GroupOperations: + """GroupOperations 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: ~subscriptionidapiversion.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 get_sample_resource_group(self, resource_group_name: str, **kwargs: Any) -> "_models.SampleResourceGroup": + """Provides a resouce group with name 'testgroup101' and location 'West US'. + + :param resource_group_name: Resource Group name 'testgroup101'. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SampleResourceGroup, or the result of cls(response) + :rtype: ~subscriptionidapiversion.models.SampleResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SampleResourceGroup"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_group.build_get_sample_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get_sample_resource_group.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SampleResourceGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_sample_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/__init__.py diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models.py diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models_py3.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models_py3.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models_py3.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/models/_models_py3.py diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/__init__.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/__init__.py similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/__init__.py rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/__init__.py diff --git a/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py new file mode 100644 index 00000000000..b28e4de9604 --- /dev/null +++ b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/operations/_group_operations.py @@ -0,0 +1,100 @@ +# 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._rest import group as rest_group + +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]] + + +class GroupOperations(object): + """GroupOperations 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: ~subscriptionidapiversion.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 get_sample_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SampleResourceGroup" + """Provides a resouce group with name 'testgroup101' and location 'West US'. + + :param resource_group_name: Resource Group name 'testgroup101'. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SampleResourceGroup, or the result of cls(response) + :rtype: ~subscriptionidapiversion.models.SampleResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SampleResourceGroup"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_group.build_get_sample_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get_sample_resource_group.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SampleResourceGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_sample_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore diff --git a/test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/py.typed b/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/py.typed similarity index 100% rename from test/azure/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/py.typed rename to test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/py.typed diff --git a/test/azure/legacy/coverage/report-optional.json b/test/azure/legacy/coverage/report-optional.json new file mode 100644 index 00000000000..8415d8ce31b --- /dev/null +++ b/test/azure/legacy/coverage/report-optional.json @@ -0,0 +1,48 @@ +{ + "StreamUploadFile": 20, + "UpdatePetWithForm": 0, + "getDecimalInvalid": 4, + "getDecimalBig": 4, + "getDecimalSmall": 4, + "getDecimalBigPositiveDecimal": 4, + "getDecimalBigNegativeDecimal": 4, + "putDecimalBig": 4, + "putDecimalSmall": 4, + "putDecimalBigPositiveDecimal": 4, + "putDecimalBigNegativeDecimal": 2, + "putDateTimeMaxUtc7MS": 0, + "getDateTimeMaxUtc7MSUppercase": 4, + "putDateTimeMaxLocalPositiveOffset": 4, + "putDateTimeMaxLocalNegativeOffset": 0, + "putDateTimeMinLocalPositiveOffset": 0, + "putDateTimeMinLocalNegativeOffset": 4, + "HeaderParameterProtectedKey": 1, + "CustomHeaderInRequest": 2, + "FormdataStreamUploadFile": 12, + "HttpSuccess200Options": 0, + "HttpRedirect307Options": 0, + "HttpRetry502Options": 0, + "HttpClientFailure400Options": 0, + "HttpClientFailure403Options": 0, + "HttpClientFailure412Options": 0, + "ResponsesScenarioNoModelEmptyBody": 4, + "sendErrorWithParamNameModels": 7, + "MultiapiPutTestOneApiVersionOne": 0, + "MultiapiPutTestOneApiVersionTwo": 0, + "MultiapiGetTestTwoApiVersionOne": 0, + "MultiapiGetTestTwoApiVersionTwo": 0, + "MultiapiGetTestTwoApiVersionThree": 0, + "MultiapiPutTestThreeApiVersionTwo": 0, + "MultiapiPostTestFourApiVersionTwo": 0, + "MultiapiPostTestFourApiVersionThreeJSON": 0, + "MultiapiPostTestFourApiVersionThreePDF": 0, + "MultiapiPutTestFiveApiVersionThree": 0, + "MultiapiLRO": 0, + "MultiapiPaging": 0, + "MultiapiLROAndPaging": 0, + "MultiapiDifferentCallsApiVersionOne": 0, + "MultiapiDifferentCallsApiVersionTwo": 0, + "MultiapiDifferentCallsApiVersionThree": 0, + "MultiapiCustomBaseUrlApiVersionOne": 0, + "MultiapiCustomBaseUrlApiVersionTwo": 0 +} \ No newline at end of file diff --git a/test/azure/legacy/coverage/report-vanilla.json b/test/azure/legacy/coverage/report-vanilla.json new file mode 100644 index 00000000000..337882dfa94 --- /dev/null +++ b/test/azure/legacy/coverage/report-vanilla.json @@ -0,0 +1,618 @@ +{ + "GetStringAsAnything": 4, + "PutStringAsAnything": 4, + "GetObjectAsAnything": 4, + "PutObjectAsAnything": 4, + "GetArrayAsAnything": 4, + "PutArrayAsAnything": 4, + "verifyIncorrectErrorParsing": 2, + "LLCRequiredToOptional": 6, + "MediaTypesAnalyzeBodyNoAcceptHeader": 0, + "verifyHost": 0, + "ImplicitOptionalBinaryBody": 2, + "ExplicitOptionalBinaryBody": 6, + "ExplicitRequiredBinaryBody": 3, + "OptionalImplicitBody": 4, + "GeneralOptional": 44, + "OptionalImplicitHeader": 4, + "OptionalImplicitQuery": 4, + "OptionalGlobalQuery": 4, + "getStringNull": 4, + "putStringNull": 4, + "getStringEmpty": 4, + "putStringEmpty": 4, + "getStringNotProvided": 4, + "getStringWithLeadingAndTrailingWhitespace": 4, + "putStringWithLeadingAndTrailingWhitespace": 4, + "getStringBase64UrlEncoded": 4, + "putStringBase64UrlEncoded": 4, + "getStringBase64Encoded": 4, + "getStringNullBase64UrlEncoding": 4, + "getStringMultiByteCharacters": 4, + "putStringMultiByteCharacters": 4, + "getEnumNotExpandable": 4, + "putEnumNotExpandable": 8, + "getEnumReferenced": 4, + "putEnumReferenced": 10, + "getEnumReferencedConstant": 4, + "putEnumReferencedConstant": 2, + "XmlGetBytes": 4, + "XmlPutBytes": 4, + "XmlGetUrl": 4, + "XmlPutUrl": 4, + "additionalPropertiesTrue": 4, + "additionalPropertiesSubclass": 4, + "additionalPropertiesTypeObject": 4, + "additionalPropertiesTypeString": 4, + "additionalPropertiesInProperties": 4, + "additionalPropertiesInPropertiesWithAPTypeString": 4, + "getArrayNull": 4, + "getArrayEmpty": 4, + "putArrayEmpty": 4, + "getArrayInvalid": 4, + "getArrayBooleanValid": 4, + "putArrayBooleanValid": 4, + "getArrayBooleanWithNull": 4, + "getArrayBooleanWithString": 4, + "getArrayIntegerValid": 4, + "putArrayIntegerValid": 4, + "getArrayIntegerWithNull": 4, + "getArrayIntegerWithString": 4, + "getArrayLongValid": 4, + "putArrayLongValid": 4, + "getArrayLongWithNull": 4, + "getArrayLongWithString": 4, + "getArrayFloatValid": 4, + "putArrayFloatValid": 4, + "getArrayFloatWithNull": 4, + "getArrayFloatWithString": 4, + "getArrayDoubleValid": 4, + "putArrayDoubleValid": 4, + "getArrayDoubleWithNull": 4, + "getArrayDoubleWithString": 4, + "getArrayStringValid": 4, + "putArrayStringValid": 4, + "getArrayEnumValid": 4, + "putArrayEnumValid": 4, + "getArrayStringEnumValid": 4, + "putArrayStringEnumValid": 4, + "getArrayStringWithNull": 4, + "getArrayStringWithNumber": 8, + "getArrayDateValid": 4, + "putArrayDateValid": 4, + "getArrayDateWithNull": 4, + "getArrayDateWithInvalidChars": 4, + "getArrayDateTimeValid": 4, + "putArrayDateTimeValid": 4, + "getArrayDateTimeWithNull": 4, + "getArrayDateTimeWithInvalidChars": 4, + "getArrayDateTimeRfc1123Valid": 4, + "putArrayDateTimeRfc1123Valid": 4, + "getArrayDurationValid": 4, + "putArrayDurationValid": 4, + "getArrayUuidValid": 4, + "getArrayUuidWithInvalidChars": 4, + "putArrayUuidValid": 4, + "getArrayByteValid": 4, + "putArrayByteValid": 4, + "getArrayByteWithNull": 4, + "getArrayArrayNull": 4, + "getArrayArrayEmpty": 4, + "getArrayArrayItemNull": 4, + "getArrayArrayItemEmpty": 4, + "getArrayArrayValid": 4, + "putArrayArrayValid": 4, + "getArrayComplexNull": 4, + "getArrayComplexEmpty": 4, + "getArrayComplexItemNull": 4, + "getArrayComplexItemEmpty": 4, + "getArrayComplexValid": 4, + "putArrayComplexValid": 4, + "getArrayDictionaryNull": 4, + "getArrayDictionaryEmpty": 4, + "getArrayDictionaryItemNull": 4, + "getArrayDictionaryItemEmpty": 4, + "getArrayDictionaryValid": 4, + "putArrayDictionaryValid": 4, + "getBoolTrue": 4, + "putBoolTrue": 4, + "getBoolFalse": 4, + "putBoolFalse": 4, + "getBoolInvalid": 4, + "getBoolNull": 4, + "getByteNull": 4, + "getByteEmpty": 4, + "getByteNonAscii": 4, + "putByteNonAscii": 4, + "getByteInvalid": 4, + "getDateNull": 4, + "getDateInvalid": 4, + "getDateOverflow": 4, + "getDateUnderflow": 4, + "getDateMax": 4, + "putDateMax": 4, + "getDateMin": 4, + "putDateMin": 4, + "getDateTimeNull": 4, + "getDateTimeInvalid": 4, + "getDateTimeOverflow": 4, + "getDateTimeUnderflow": 4, + "putDateTimeMaxUtc": 4, + "getDateTimeMaxUtcLowercase": 4, + "getDateTimeMaxUtcUppercase": 4, + "getDateTimeMaxLocalPositiveOffsetLowercase": 4, + "getDateTimeMaxLocalPositiveOffsetUppercase": 4, + "getDateTimeMaxLocalNegativeOffsetLowercase": 4, + "getDateTimeMaxLocalNegativeOffsetUppercase": 4, + "getDateTimeMinUtc": 4, + "putDateTimeMinUtc": 4, + "getDateTimeMinLocalPositiveOffset": 4, + "getDateTimeMinLocalNegativeOffset": 4, + "getDateTimeRfc1123Null": 4, + "getDateTimeRfc1123Invalid": 4, + "getDateTimeRfc1123Overflow": 4, + "getDateTimeRfc1123Underflow": 4, + "getDateTimeRfc1123MinUtc": 4, + "putDateTimeRfc1123Max": 4, + "putDateTimeRfc1123Min": 4, + "getDateTimeRfc1123MaxUtcLowercase": 4, + "getDateTimeRfc1123MaxUtcUppercase": 4, + "getIntegerNull": 4, + "getIntegerInvalid": 4, + "getIntegerOverflow": 4, + "getIntegerUnderflow": 4, + "getLongOverflow": 4, + "getLongUnderflow": 4, + "putIntegerMax": 4, + "putLongMax": 4, + "putIntegerMin": 4, + "putLongMin": 4, + "getNumberNull": 4, + "getFloatInvalid": 4, + "getDoubleInvalid": 4, + "getFloatBigScientificNotation": 4, + "putFloatBigScientificNotation": 4, + "getDoubleBigScientificNotation": 4, + "putDoubleBigScientificNotation": 4, + "getDoubleBigPositiveDecimal": 4, + "putDoubleBigPositiveDecimal": 4, + "getDoubleBigNegativeDecimal": 6, + "putDoubleBigNegativeDecimal": 2, + "getFloatSmallScientificNotation": 4, + "putFloatSmallScientificNotation": 4, + "getDoubleSmallScientificNotation": 4, + "putDoubleSmallScientificNotation": 4, + "putComplexBasicValid": 8, + "getComplexBasicValid": 4, + "getComplexBasicEmpty": 4, + "getComplexBasicNotProvided": 4, + "getComplexBasicNull": 4, + "getComplexBasicInvalid": 4, + "putComplexPrimitiveInteger": 4, + "putComplexPrimitiveLong": 4, + "putComplexPrimitiveFloat": 4, + "putComplexPrimitiveDouble": 4, + "putComplexPrimitiveBool": 4, + "putComplexPrimitiveString": 4, + "putComplexPrimitiveDate": 4, + "putComplexPrimitiveDateTime": 4, + "putComplexPrimitiveDateTimeRfc1123": 4, + "putComplexPrimitiveDuration": 4, + "putComplexPrimitiveByte": 4, + "getComplexPrimitiveInteger": 4, + "getComplexPrimitiveLong": 4, + "getComplexPrimitiveFloat": 4, + "getComplexPrimitiveDouble": 4, + "getComplexPrimitiveBool": 4, + "getComplexPrimitiveString": 4, + "getComplexPrimitiveDate": 4, + "getComplexPrimitiveDateTime": 4, + "getComplexPrimitiveDateTimeRfc1123": 4, + "getComplexPrimitiveDuration": 4, + "getComplexPrimitiveByte": 4, + "putComplexArrayValid": 4, + "putComplexArrayEmpty": 4, + "getComplexArrayValid": 4, + "getComplexArrayEmpty": 4, + "getComplexArrayNotProvided": 4, + "putComplexDictionaryValid": 4, + "putComplexDictionaryEmpty": 4, + "getComplexDictionaryValid": 4, + "getComplexDictionaryEmpty": 4, + "getComplexDictionaryNull": 4, + "getComplexDictionaryNotProvided": 4, + "putComplexInheritanceValid": 10, + "getComplexInheritanceValid": 16, + "putComplexPolymorphismValid": 4, + "getComplexPolymorphismValid": 4, + "putComplexPolymorphismComplicated": 4, + "getComplexPolymorphismComplicated": 4, + "putComplexPolymorphismNoDiscriminator": 4, + "putComplexPolymorphicRecursiveValid": 4, + "getComplexPolymorphicRecursiveValid": 4, + "putComplexReadOnlyPropertyValid": 4, + "getComplexReadOnlyPropertyValid": 4, + "UrlPathsBoolFalse": 4, + "UrlPathsBoolTrue": 4, + "UrlPathsIntPositive": 4, + "UrlPathsIntNegative": 4, + "UrlPathsLongPositive": 4, + "UrlPathsLongNegative": 4, + "UrlPathsFloatPositive": 4, + "UrlPathsFloatNegative": 4, + "UrlPathsDoublePositive": 4, + "UrlPathsDoubleNegative": 4, + "UrlPathsStringUrlEncoded": 4, + "UrlPathsStringUrlNonEncoded": 4, + "UrlPathsStringEmpty": 4, + "UrlPathsStringUnicode": 4, + "UrlPathsEnumValid": 4, + "UrlPathsByteMultiByte": 4, + "UrlPathsByteEmpty": 4, + "UrlPathsDateValid": 4, + "UrlPathsDateTimeValid": 4, + "UrlQueriesBoolFalse": 4, + "UrlQueriesBoolTrue": 4, + "UrlQueriesBoolNull": 4, + "UrlQueriesIntPositive": 4, + "UrlQueriesIntNegative": 4, + "UrlQueriesIntNull": 4, + "UrlQueriesLongPositive": 4, + "UrlQueriesLongNegative": 4, + "UrlQueriesLongNull": 4, + "UrlQueriesFloatPositive": 4, + "UrlQueriesFloatNegative": 4, + "UrlQueriesFloatNull": 4, + "UrlQueriesDoublePositive": 4, + "UrlQueriesDoubleNegative": 4, + "UrlQueriesDoubleNull": 4, + "UrlQueriesStringUrlEncoded": 4, + "UrlQueriesStringEmpty": 4, + "UrlQueriesStringNull": 4, + "UrlQueriesStringUnicode": 4, + "UrlQueriesEnumValid": 4, + "UrlQueriesEnumNull": 4, + "UrlQueriesByteMultiByte": 4, + "UrlQueriesByteEmpty": 4, + "UrlQueriesByteNull": 4, + "UrlQueriesDateValid": 4, + "UrlQueriesDateNull": 4, + "UrlQueriesDateTimeValid": 4, + "UrlQueriesDateTimeNull": 4, + "UrlQueriesArrayCsvNull": 4, + "UrlQueriesArrayCsvEmpty": 4, + "UrlQueriesArrayCsvValid": 4, + "UrlQueriesArrayMultiNull": 4, + "UrlQueriesArrayMultiEmpty": 4, + "UrlQueriesArrayMultiValid": 4, + "UrlQueriesArraySsvValid": 2, + "UrlQueriesArrayPipesValid": 2, + "UrlQueriesArrayTsvValid": 2, + "UrlQueriesArrayNoCollectionFormatValid": 4, + "UrlPathItemGetAll": 4, + "UrlPathItemGetGlobalNull": 4, + "UrlPathItemGetGlobalAndLocalNull": 4, + "UrlPathItemGetPathItemAndLocalNull": 4, + "putDictionaryEmpty": 4, + "getDictionaryNull": 4, + "getDictionaryEmpty": 4, + "getDictionaryInvalid": 4, + "getDictionaryNullValue": 4, + "getDictionaryNullkey": 4, + "getDictionaryKeyEmptyString": 4, + "getDictionaryBooleanValid": 4, + "getDictionaryBooleanWithNull": 4, + "getDictionaryBooleanWithString": 4, + "getDictionaryIntegerValid": 4, + "getDictionaryIntegerWithNull": 4, + "getDictionaryIntegerWithString": 4, + "getDictionaryLongValid": 4, + "getDictionaryLongWithNull": 4, + "getDictionaryLongWithString": 4, + "getDictionaryFloatValid": 4, + "getDictionaryFloatWithNull": 4, + "getDictionaryFloatWithString": 4, + "getDictionaryDoubleValid": 4, + "getDictionaryDoubleWithNull": 4, + "getDictionaryDoubleWithString": 4, + "getDictionaryStringValid": 4, + "getDictionaryStringWithNull": 4, + "getDictionaryStringWithNumber": 4, + "getDictionaryDateValid": 4, + "getDictionaryDateWithNull": 4, + "getDictionaryDateWithInvalidChars": 4, + "getDictionaryDateTimeValid": 4, + "getDictionaryDateTimeWithNull": 4, + "getDictionaryDateTimeWithInvalidChars": 4, + "getDictionaryDateTimeRfc1123Valid": 4, + "getDictionaryDurationValid": 4, + "getDictionaryByteValid": 4, + "getDictionaryByteWithNull": 4, + "putDictionaryBooleanValid": 4, + "putDictionaryIntegerValid": 4, + "putDictionaryLongValid": 4, + "putDictionaryFloatValid": 4, + "putDictionaryDoubleValid": 4, + "putDictionaryStringValid": 4, + "putDictionaryDateValid": 4, + "putDictionaryDateTimeValid": 4, + "putDictionaryDateTimeRfc1123Valid": 4, + "putDictionaryDurationValid": 4, + "putDictionaryByteValid": 4, + "getDictionaryComplexNull": 4, + "getDictionaryComplexEmpty": 4, + "getDictionaryComplexItemNull": 4, + "getDictionaryComplexItemEmpty": 4, + "getDictionaryComplexValid": 4, + "putDictionaryComplexValid": 4, + "getDictionaryArrayNull": 4, + "getDictionaryArrayEmpty": 4, + "getDictionaryArrayItemNull": 6, + "getDictionaryArrayItemEmpty": 2, + "getDictionaryArrayValid": 4, + "putDictionaryArrayValid": 4, + "getDictionaryDictionaryNull": 4, + "getDictionaryDictionaryEmpty": 4, + "getDictionaryDictionaryItemNull": 4, + "getDictionaryDictionaryItemEmpty": 4, + "getDictionaryDictionaryValid": 4, + "putDictionaryDictionaryValid": 4, + "putDurationPositive": 4, + "getDurationNull": 4, + "getDurationInvalid": 4, + "getDurationPositive": 4, + "HeaderParameterExistingKey": 4, + "HeaderResponseExistingKey": 4, + "HeaderResponseProtectedKey": 4, + "HeaderParameterIntegerPositive": 4, + "HeaderParameterIntegerNegative": 4, + "HeaderParameterLongPositive": 4, + "HeaderParameterLongNegative": 4, + "HeaderParameterFloatPositive": 4, + "HeaderParameterFloatNegative": 4, + "HeaderParameterDoublePositive": 4, + "HeaderParameterDoubleNegative": 4, + "HeaderParameterBoolTrue": 4, + "HeaderParameterBoolFalse": 4, + "HeaderParameterStringValid": 4, + "HeaderParameterStringNull": 4, + "HeaderParameterStringEmpty": 4, + "HeaderParameterDateValid": 4, + "HeaderParameterDateMin": 4, + "HeaderParameterDateTimeValid": 4, + "HeaderParameterDateTimeMin": 4, + "HeaderParameterDateTimeRfc1123Valid": 4, + "HeaderParameterDateTimeRfc1123Min": 4, + "HeaderParameterBytesValid": 4, + "HeaderParameterDurationValid": 4, + "HeaderResponseIntegerPositive": 4, + "HeaderResponseIntegerNegative": 4, + "HeaderResponseLongPositive": 4, + "HeaderResponseLongNegative": 4, + "HeaderResponseFloatPositive": 4, + "HeaderResponseFloatNegative": 4, + "HeaderResponseDoublePositive": 4, + "HeaderResponseDoubleNegative": 4, + "HeaderResponseBoolTrue": 4, + "HeaderResponseBoolFalse": 4, + "HeaderResponseStringValid": 4, + "HeaderResponseStringNull": 4, + "HeaderResponseStringEmpty": 4, + "HeaderParameterEnumValid": 8, + "HeaderParameterEnumNull": 4, + "HeaderResponseEnumValid": 4, + "HeaderResponseEnumNull": 4, + "HeaderResponseDateValid": 4, + "HeaderResponseDateMin": 4, + "HeaderResponseDateTimeValid": 4, + "HeaderResponseDateTimeMin": 4, + "HeaderResponseDateTimeRfc1123Valid": 4, + "HeaderResponseDateTimeRfc1123Min": 4, + "HeaderResponseBytesValid": 4, + "HeaderResponseDurationValid": 4, + "ConstantsInPath": 4, + "ConstantsInBody": 4, + "CustomBaseUri": 2, + "CustomBaseUriMoreOptions": 2, + "getModelFlattenArray": 16, + "putModelFlattenArray": 9, + "getModelFlattenDictionary": 15, + "putModelFlattenDictionary": 10, + "getModelFlattenResourceCollection": 17, + "putModelFlattenResourceCollection": 14, + "putModelFlattenCustomBase": 14, + "postModelFlattenCustomParameter": 13, + "putModelFlattenCustomGroupedParameter": 11, + "getArrayBase64Url": 6, + "getDictionaryBase64Url": 4, + "UrlPathsStringBase64Url": 4, + "UrlPathsArrayCSVInPath": 4, + "getUnixTime": 4, + "getInvalidUnixTime": 4, + "getNullUnixTime": 4, + "putUnixTime": 4, + "UrlPathsIntUnixTime": 4, + "expectedEnum": 4, + "unexpectedEnum": 4, + "allowedValueEnum": 4, + "roundTripEnum": 4, + "expectedNoErrors": 4, + "expectedPetSadError": 8, + "expectedPetHungryError": 2, + "intError": 2, + "stringError": 2, + "animalNotFoundError": 2, + "linkNotFoundError": 2, + "getDateTimeMinLocalNoOffset": 4, + "getComplexPolymorphismDotSyntax": 4, + "getComposedWithDiscriminator": 4, + "getComposedWithoutDiscriminator": 4, + "FileStreamNonempty": 10, + "FileStreamVeryLarge": 4, + "FileStreamEmpty": 6, + "HttpSuccess200Head": 4, + "HttpSuccess200Get": 4, + "HttpSuccess200Put": 4, + "HttpSuccess200Post": 4, + "HttpSuccess200Patch": 4, + "HttpSuccess200Delete": 4, + "HttpSuccess201Put": 4, + "HttpSuccess201Post": 4, + "HttpSuccess202Put": 4, + "HttpSuccess202Post": 4, + "HttpSuccess202Patch": 4, + "HttpSuccess202Delete": 4, + "HttpSuccess204Head": 4, + "HttpSuccess404Head": 4, + "HttpSuccess204Put": 4, + "HttpSuccess204Post": 4, + "HttpSuccess204Patch": 4, + "HttpSuccess204Delete": 4, + "HttpRedirect300Head": 4, + "HttpRedirect300Get": 4, + "HttpRedirect301Put": 4, + "HttpRedirect301Get": 4, + "HttpRedirect302Head": 4, + "HttpRedirect302Get": 4, + "HttpRedirect302Patch": 4, + "HttpRedirect303Post": 4, + "HttpRedirect307Head": 4, + "HttpRedirect307Get": 4, + "HttpRedirect307Put": 4, + "HttpRedirect307Post": 4, + "HttpRedirect307Patch": 4, + "HttpRedirect307Delete": 4, + "HttpRetry408Head": 4, + "HttpRetry500Put": 4, + "HttpRetry500Patch": 4, + "HttpRetry502Get": 4, + "HttpRetry503Post": 4, + "HttpRetry503Delete": 4, + "HttpRetry504Put": 4, + "HttpRetry504Patch": 4, + "HttpClientFailure400Head": 4, + "HttpClientFailure400Get": 4, + "HttpClientFailure400Put": 4, + "HttpClientFailure400Post": 4, + "HttpClientFailure400Patch": 4, + "HttpClientFailure400Delete": 4, + "HttpClientFailure401Head": 4, + "HttpClientFailure402Get": 4, + "HttpClientFailure403Get": 4, + "HttpClientFailure404Put": 4, + "HttpClientFailure405Patch": 4, + "HttpClientFailure406Post": 4, + "HttpClientFailure407Delete": 4, + "HttpClientFailure409Put": 4, + "HttpClientFailure410Head": 4, + "HttpClientFailure411Get": 4, + "HttpClientFailure412Get": 4, + "HttpClientFailure413Put": 4, + "HttpClientFailure414Patch": 4, + "HttpClientFailure415Post": 4, + "HttpClientFailure416Get": 4, + "HttpClientFailure417Delete": 4, + "HttpClientFailure429Head": 16, + "HttpServerFailure501Head": 4, + "HttpServerFailure501Get": 4, + "HttpServerFailure505Post": 4, + "HttpServerFailure505Delete": 4, + "ResponsesScenarioA200MatchingModel": 4, + "ResponsesScenarioA204MatchingNoModel": 4, + "ResponsesScenarioA201DefaultNoModel": 4, + "ResponsesScenarioA202DefaultNoModel": 4, + "ResponsesScenarioA400DefaultModel": 4, + "ResponsesScenarioB200MatchingModel": 4, + "ResponsesScenarioB201MatchingModel": 4, + "ResponsesScenarioB400DefaultModel": 4, + "ResponsesScenarioC200MatchingModel": 4, + "ResponsesScenarioC201MatchingModel": 4, + "ResponsesScenarioC404MatchingModel": 4, + "ResponsesScenarioC400DefaultModel": 4, + "ResponsesScenarioD202MatchingNoModel": 4, + "ResponsesScenarioD204MatchingNoModel": 4, + "ResponsesScenarioD400DefaultModel": 4, + "ResponsesScenarioE202MatchingInvalid": 4, + "ResponsesScenarioE204MatchingNoModel": 4, + "ResponsesScenarioE400DefaultNoModel": 4, + "ResponsesScenarioE400DefaultInvalid": 4, + "ResponsesScenarioF200DefaultModel": 8, + "ResponsesScenarioF200DefaultNone": 8, + "ResponsesScenarioF400DefaultModel": 2, + "ResponsesScenarioF400DefaultNone": 2, + "ResponsesScenarioG200DefaultInvalid": 6, + "ResponsesScenarioG200DefaultNoModel": 2, + "ResponsesScenarioG400DefaultInvalid": 4, + "ResponsesScenarioG400DefaultNoModel": 4, + "ResponsesScenarioH200MatchingNone": 4, + "ResponsesScenarioH200MatchingModel": 4, + "ResponsesScenarioH200MatchingInvalid": 4, + "ResponsesScenarioH400NonMatchingNone": 4, + "ResponsesScenarioH400NonMatchingModel": 4, + "ResponsesScenarioH400NonMatchingInvalid": 4, + "ResponsesScenarioH202NonMatchingModel": 4, + "ResponsesScenarioEmptyErrorBody": 4, + "ResponsesScenarioNoModelErrorBody": 4, + "MediaTypeJson": 4, + "MediaTypePdf": 4, + "MediaTypeWithEncoding": 4, + "StorageListContainersXML": 4, + "StorageGetServicePropertiesXML": 4, + "StoragePutServicePropertiesXML": 4, + "StorageGetContainerACLXML": 4, + "StorageListBlobsXML": 4, + "StoragePutContainerACLXML": 4, + "GetSimpleXML": 4, + "PutSimpleXML": 4, + "GetWrappedXMLList": 4, + "PutWrappedXMLList": 4, + "GetEmptyXMLList": 4, + "PutEmptyXMLList": 4, + "GetEmptyWrappedXMLList": 4, + "PutEmptyWrappedXMLList": 4, + "GetXMLListAtRoot": 4, + "PutXMLListAtRoot": 4, + "GetXMLListAtRootSingle": 4, + "PutXMLListAtRootSingle": 4, + "GetEmptyXMLListAtRoot": 6, + "PutEmptyXMLListAtRoot": 4, + "GetXMLEmptyNode": 4, + "PutXMLEmptyNode": 4, + "GetRootWithRefAndNoMetaXML": 4, + "PutRootWithRefAndNoMetaXML": 4, + "GetRootWithRefAndMetaXML": 4, + "PutRootWithRefAndMetaXML": 4, + "jsonInputInXMLSwagger": 4, + "jsonOutputInXMLSwagger": 4, + "GetWithXMsText": 4, + "ObjectTypeResponse": 4, + "ObjectTypePut": 4, + "ObjectTypeErrorResponse": 4, + "NonStringEnumsPostInt": 4, + "NonStringEnumsGetInt": 4, + "NonStringEnumsPostFloat": 4, + "NonStringEnumsGetFloat": 4, + "BodyTimeGet": 4, + "BodyTimePut": 4, + "MultipleInheritancePetGet": 4, + "MultipleInheritancePetPut": 4, + "MultipleInheritanceHorseGet": 4, + "MultipleInheritanceHorsePut": 4, + "MultipleInheritanceFelineGet": 4, + "MultipleInheritanceFelinePut": 4, + "MultipleInheritanceCatGet": 4, + "MultipleInheritanceCatPut": 4, + "MultipleInheritanceKittenGet": 4, + "MultipleInheritanceKittenPut": 4, + "OptionalIntegerParameter": 4, + "OptionalIntegerProperty": 4, + "OptionalIntegerHeader": 4, + "OptionalStringParameter": 4, + "OptionalStringProperty": 4, + "OptionalStringHeader": 4, + "OptionalClassParameter": 4, + "OptionalClassProperty": 4, + "OptionalArrayParameter": 4, + "OptionalArrayProperty": 4, + "OptionalArrayHeader": 4 +} \ No newline at end of file diff --git a/test/azure/requirements.txt b/test/azure/legacy/requirements.txt similarity index 100% rename from test/azure/requirements.txt rename to test/azure/legacy/requirements.txt diff --git a/test/azure/legacy/specification/custompollerpager/README.md b/test/azure/legacy/specification/custompollerpager/README.md new file mode 100644 index 00000000000..aca0dad2817 --- /dev/null +++ b/test/azure/legacy/specification/custompollerpager/README.md @@ -0,0 +1,38 @@ +# Testing adding a custom poller and pager + +### Settings + +``` yaml +input-file: ../../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/paging.json +namespace: custompollerpager +output-folder: $(python-sdks-folder)/azure/legacy/Expected/AcceptanceTests/CustomPollerPager +package-name: custompollerpager +license-header: MICROSOFT_MIT_NO_VERSION +azure-arm: true +add-credentials: true +package-version: 0.1.0 +basic-setup-py: true +output-artifact: code-model-v4-no-tags +payload-flattening-threshold: 1 +clear-output-folder: true +``` + +### Override ItemPaged to custom Pager +``` yaml +directive: + - from: swagger-document + where: '$.paths["/paging/single"].get' + transform: > + $["x-python-custom-pager-sync"] = "custompollerpagerdefinitions.CustomPager"; + $["x-python-custom-pager-async"] = "custompollerpagerdefinitions.aio.AsyncCustomPager" +``` + +### Override LROPoller to custom Poller +``` yaml +directive: + - from: swagger-document + where: '$.paths["/paging/multiple/lro"].post' + transform: > + $["x-python-custom-poller-sync"] = "custompollerpagerdefinitions.CustomPoller"; + $["x-python-custom-poller-async"] = "custompollerpagerdefinitions.aio.AsyncCustomPoller" +``` diff --git a/test/azure/legacy/tox.ini b/test/azure/legacy/tox.ini new file mode 100644 index 00000000000..067f256495a --- /dev/null +++ b/test/azure/legacy/tox.ini @@ -0,0 +1,18 @@ +[tox] +envlist=py27, py36 +skipsdist=True + +[testenv] +deps= + -rrequirements.txt + coverage +commands= + pytest --cov=Expected + +[testenv:ci] +deps= + -rrequirements.txt + coverage==4.5.4 + pytest-cov +commands = + pytest --cov=Expected diff --git a/test/vanilla/AcceptanceTests/__init__.py b/test/azure/low-level/AcceptanceTests/__init__.py similarity index 100% rename from test/vanilla/AcceptanceTests/__init__.py rename to test/azure/low-level/AcceptanceTests/__init__.py diff --git a/test/azure/low-level/AcceptanceTests/asynctests/__init__.py b/test/azure/low-level/AcceptanceTests/asynctests/__init__.py new file mode 100644 index 00000000000..44607faec39 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/__init__.py @@ -0,0 +1,31 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +import pytest + +pytestmark = pytest.mark.skipif(sys.version_info < (3,6), + reason="requires python3.6") \ No newline at end of file diff --git a/test/azure/low-level/AcceptanceTests/asynctests/conftest.py b/test/azure/low-level/AcceptanceTests/asynctests/conftest.py new file mode 100644 index 00000000000..2cca5243a79 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/conftest.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------- +# +# 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 + +@pytest.fixture() +def base_send_request(): + async def send_request(client, request, **kwargs): + response = await client.send_request(request, **kwargs) + response.raise_for_status() + return response + return send_request + +@pytest.fixture() +def base_send_request_json_response(): + async def send_request_json_response(client, request): + response = await client.send_request(request) + response.raise_for_status() + return response.json() + return send_request_json_response \ No newline at end of file diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_azure_url.py b/test/azure/low-level/AcceptanceTests/asynctests/test_azure_url.py new file mode 100644 index 00000000000..bc0d8664d55 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_azure_url.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from uuid import uuid4 +import pytest + +from subscriptionidapiversionlowlevel.aio import MicrosoftAzureTestUrl +from subscriptionidapiversionlowlevel.rest import group + + +@pytest.mark.asyncio +async def test_azure_url(credential, authentication_policy): + + sub_id = str(uuid4()) + + async with MicrosoftAzureTestUrl(credential, sub_id, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + request = group.build_get_sample_resource_group_request(subscription_id=sub_id, resource_group_name="testgroup101") + response = await client.send_request(request) + response.raise_for_status() + response_json = response.json() + assert response_json['name'] == 'testgroup101' + assert response_json['location'] == "West US" diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_config.py b/test/azure/low-level/AcceptanceTests/asynctests/test_config.py new file mode 100644 index 00000000000..42f874670f3 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_config.py @@ -0,0 +1,56 @@ +# -------------------------------------------------------------------------- +# +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy +# Head is azure-arm +from headlowlevel.aio import AutoRestHeadTestService + +@pytest.mark.asyncio +async def test_arm_http_logging_policy_default(credential): + async with AutoRestHeadTestService(credential, base_url="http://localhost:3000") as client: + assert isinstance(client._config.http_logging_policy, ARMHttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == ARMHttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST + +@pytest.mark.asyncio +async def test_arm_http_logging_policy_custom(credential): + http_logging_policy = ARMHttpLoggingPolicy(base_url="test") + http_logging_policy = ARMHttpLoggingPolicy() + http_logging_policy.allowed_header_names.update( + {"x-ms-added-header"} + ) + async with AutoRestHeadTestService(credential, base_url="http://localhost:3000", http_logging_policy=http_logging_policy) as client: + assert isinstance(client._config.http_logging_policy, ARMHttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == ARMHttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST.union({"x-ms-added-header"}) + +@pytest.mark.asyncio +async def test_credential_scopes_default(credential): + async with AutoRestHeadTestService(credential) as client: + assert client._config.credential_scopes == ['https://management.azure.com/.default'] + +@pytest.mark.asyncio +async def test_credential_scopes_override(credential): + async with AutoRestHeadTestService(credential, credential_scopes=["http://i-should-be-the-only-credential"]) as client: + assert client._config.credential_scopes == ["http://i-should-be-the-only-credential"] diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_duration.py b/test/azure/low-level/AcceptanceTests/asynctests/test_duration.py new file mode 100644 index 00000000000..7fe51056fae --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_duration.py @@ -0,0 +1,71 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +from datetime import timedelta +import pytest + +import isodate +from bodydurationlowlevel.aio import AutoRestDurationTestService +from bodydurationlowlevel.rest import duration + + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestDurationTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_get_null_and_invalid(send_request, send_request_json_response): + request = duration.build_get_null_request() + assert (await send_request(request)).text == '' + + # in llc, we don't raise deserialization error + request = duration.build_get_invalid_request() + with pytest.raises(isodate.ISO8601Error): + isodate.parse_duration(await send_request_json_response(request)) + +@pytest.mark.asyncio +async def test_positive_duration(send_request, send_request_json_response): + request = duration.build_get_positive_duration_request() + response = isodate.parse_duration(await send_request_json_response(request)) + assert response == isodate.Duration(4, 45005, 0, years=3, months=6) + delta = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + request = duration.build_put_positive_duration_request(json=isodate.duration_isoformat(delta)) + await send_request(request) diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_head.py b/test/azure/low-level/AcceptanceTests/asynctests/test_head.py new file mode 100644 index 00000000000..e8c92566deb --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_head.py @@ -0,0 +1,65 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from headlowlevel.aio import AutoRestHeadTestService +from headlowlevel.rest import http_success +from headexceptionslowlevel.aio import AutoRestHeadExceptionTestService +from headexceptionslowlevel.rest import head_exception +from azure.core.exceptions import HttpResponseError + +import pytest + +@pytest.mark.asyncio +async def test_head(credential, authentication_policy): + async with AutoRestHeadTestService(credential, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + request = http_success.build_head200_request() + response = await client.send_request(request) + response.raise_for_status() + + request = http_success.build_head204_request() + response = await client.send_request(request) + response.raise_for_status() + + request = http_success.build_head404_request() + response = await client.send_request(request) + with pytest.raises(HttpResponseError): + response.raise_for_status() + +@pytest.mark.asyncio +async def test_head_exception(credential, authentication_policy): + async with AutoRestHeadExceptionTestService(credential, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + request = head_exception.build_head200_request() + response = await client.send_request(request) + response.raise_for_status() + + request = head_exception.build_head204_request() + response = await client.send_request(request) + response.raise_for_status() + + request = head_exception.build_head404_request() + response = await client.send_request(request) + with pytest.raises(HttpResponseError): + response.raise_for_status() diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_lro.py b/test/azure/low-level/AcceptanceTests/asynctests/test_lro.py new file mode 100644 index 00000000000..6344afc0589 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_lro.py @@ -0,0 +1,591 @@ +# -------------------------------------------------------------------------- +# +# 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 time +from async_generator import yield_, async_generator + + +from azure.core.exceptions import DecodeError, HttpResponseError +from azure.core.pipeline.policies import ContentDecodePolicy, AsyncRetryPolicy, HeadersPolicy, RequestIdPolicy +from azure.core.polling import AsyncLROPoller, AsyncNoPolling + +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from lrolowlevel.aio import AutoRestLongRunningOperationTestService +from lrolowlevel.rest import lr_os_custom_header, lro_retrys, lros, lrosads + +try: + from urlparse import urlparse +except ImportError: + from urllib.parse import urlparse + +import pytest + +POLLING_INTERVAL = 0 + +class AutorestTestARMPolling(AsyncARMPolling): + + def _polling_cookie(self, response): + """Collect retry cookie - we only want to do this for the test server + at this point, unless we implement a proper cookie policy. + + :returns: Dictionary containing a cookie header if required, + otherwise an empty dictionary. + """ + parsed_url = urlparse(response.request.url) + host = parsed_url.hostname.strip('.') + if host == 'localhost': + return {'cookie': response.headers.get('set-cookie', '')} + return {} + + async def request_status(self, status_link): + request = self._client.get(status_link, headers=self._polling_cookie(self._pipeline_response.http_response)) + # ARM requires to re-inject 'x-ms-client-request-id' while polling + if 'request_id' not in self._operation_config: + self._operation_config['request_id'] = self._get_request_id() + return (await self._client._pipeline.run(request, stream=False, **self._operation_config)) + +@pytest.fixture +@async_generator +async def client(cookie_policy, credential): + """Create a AutoRestLongRunningOperationTestService client with test server credentials.""" + policies = [ + RequestIdPolicy(), + HeadersPolicy(), + ContentDecodePolicy(), + AsyncRetryPolicy(), + cookie_policy + ] + async with AutoRestLongRunningOperationTestService(credential, base_url="http://localhost:3000", policies=policies, polling_interval=POLLING_INTERVAL) as client: + await yield_(client) + +@pytest.fixture() +def product(): + return {"location": "West US"} + +@pytest.fixture() +def custom_headers(): + return {"x-ms-client-request-id": '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'} + +@pytest.fixture +def get_long_running_output(deserializer): + # this is the default deserializer, just returns deserialized object + def _callback(pipeline_response): + return deserializer("object", pipeline_response.http_response) + return _callback + +@pytest.fixture +def get_long_running_output_return_none(): + # for use if the swagger has no defined return object, so we + # follow the convenience layer, and just return none + def _callback(pipeline_response): + return None + return _callback + +@pytest.fixture +def get_poller(get_long_running_output, client): + + async def _callback(request, **kwargs): + pipeline_response = await client.send_request( + request._to_pipeline_transport_request(), + _return_pipeline_response=True + ) + pipeline_response.http_response.raise_for_status() + polling = kwargs.pop("polling", True) + deserializer = kwargs.pop("get_long_running_output", get_long_running_output) + polling_method = kwargs.pop("polling_method", None) + if not polling_method: + polling_method = AutorestTestARMPolling(kwargs.pop("polling_interval", 0)) if polling else AsyncNoPolling() + return AsyncLROPoller(client._client, pipeline_response, deserializer, polling_method) + return _callback + +def _check_message_in_error(ex, message): + try: + assert ex.value.message.lower() == message.lower() + except AssertionError: + assert message.lower() in ex.value.message.lower() + +@pytest.fixture +def assert_polling_raises_with_message(get_poller): + async def _callback(request, message, **kwargs): + poller = await get_poller(request, **kwargs) + with pytest.raises(HttpResponseError) as ex: + await poller.wait() + _check_message_in_error(ex, message) + return _callback + +@pytest.fixture +def assert_initial_call_raises_with_message(get_poller): + async def _callback(request, message, **kwargs): + with pytest.raises(HttpResponseError) as ex: + await get_poller(request, **kwargs) # this makes the initial call + _check_message_in_error(ex, message) + return _callback + +@pytest.mark.asyncio +async def test_post_double_headers_final_continuation_token(client, get_poller, get_long_running_output): + request = lros.build_post_double_headers_final_location_get_request() + + poller = await get_poller(request) + continuation_token = poller.continuation_token() + + poller = AsyncLROPoller.from_continuation_token( + polling_method=AsyncARMPolling(0), + continuation_token=continuation_token, + client=client._client, + deserialization_callback=get_long_running_output, + ) + product = await poller.result() + assert product['id'] == "100" + +@pytest.mark.asyncio +async def test_post_double_headers_final(get_poller): + request = lros.build_post_double_headers_final_location_get_request() + poller = await get_poller(request) + product = await poller.result() + assert product['id'] == "100" + + polling_method = AutorestTestARMPolling(0, lro_options={"final-state-via": "azure-async-operation"}) + request = lros.build_post_double_headers_final_azure_header_get_request() + product = await (await get_poller(request, polling_method=polling_method)).result() + assert product['id'] == "100" + +@pytest.mark.asyncio +async def test_post_double_headers_default(get_poller): + # This test will work as long as the default is Location + request = lros.build_post_double_headers_final_azure_header_get_default_request() + product = await (await get_poller(request)).result() + assert product['id'] == "100" + +@pytest.mark.asyncio +async def test_happy_put201_creating_succeeded200(get_poller): + request = lros.build_put201_creating_succeeded200_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + # Testing AsyncNoPolling + request = lros.build_put201_creating_succeeded200_request() + process = await (await get_poller(request, polling=False)).result() + assert "Creating" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put201_creating_failed200(assert_polling_raises_with_message, get_poller): + request = lros.build_put201_creating_failed200_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_put201_creating_failed200_request() + process = await (await get_poller(request, polling=False)).result() + assert "Created" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put200_updating_succeeded204(get_poller): + request = lros.build_put200_updating_succeeded204_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + process = await (await get_poller(request, polling=False)).result() + assert "Updating" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put200_acceptedcanceled200(get_poller, assert_polling_raises_with_message): + request = lros.build_put200_acceptedcanceled200_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_put200_acceptedcanceled200_request() + process = await (await get_poller(request, polling=False)).result() + assert "Accepted" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put_no_header_in_retry(get_poller): + request = lros.build_put_no_header_in_retry_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put_async_no_header_in_retry_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put_sub_resource(get_poller): + request = lros.build_put_sub_resource_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put_async_sub_resource_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put_non_resource(get_poller): + request = lros.build_put_non_resource_request() + process = await (await get_poller(request)).result() + assert "100" == process['id'] + + request = lros.build_put_async_non_resource_request() + process = await (await get_poller(request)).result() + assert "100" == process['id'] + +@pytest.mark.asyncio +async def test_happy_put200_succeeded(get_poller): + request = lros.build_put200_succeeded_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put200_succeeded_no_state_request() + process = await (await get_poller(request)).result() + assert "100" == process['id'] + +@pytest.mark.asyncio +async def test_put201_succeeded(get_poller): + request = lros.build_put201_succeeded_request() + process = await (await get_poller(request)).result() + + assert "Succeeded" == process['properties']['provisioningState'] + assert "100" == process['id'] + assert "foo" == process['name'] + +@pytest.mark.asyncio +async def test_happy_put202_retry200(get_poller): + request = lros.build_put202_retry200_request() + process = await (await get_poller(request)).result() + assert "100" == process['id'] + +@pytest.mark.asyncio +async def test_happy_put_retry_succeeded(get_poller): + request = lros.build_put_async_retry_succeeded_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put_async_no_retry_succeeded_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_happy_put_retry_failed_canceled(get_poller, assert_polling_raises_with_message): + request = lros.build_put_async_retry_failed_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_put_async_no_retrycanceled_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + +@pytest.mark.asyncio +async def test_post202_retry200(get_poller, get_long_running_output_return_none): + request = lros.build_post202_retry200_request() + process = await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() + assert process is None + +@pytest.mark.asyncio +async def test_happy_delete(get_poller): + request = lros.build_delete204_succeeded_request() + assert await (await get_poller(request)).result() is None + + request = lros.build_delete202_retry200_request() + assert await (await get_poller(request)).result() is None + + request = lros.build_delete202_no_retry204_request() + assert await (await get_poller(request)).result() is None + +@pytest.mark.asyncio +async def test_happy_delete_no_header_in_retry(get_poller, get_long_running_output_return_none): + request = lros.build_delete_no_header_in_retry_request() + assert await (await get_poller(request)).result() is None + + request = lros.build_delete_async_no_header_in_retry_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + +@pytest.mark.asyncio +async def test_happy_delete_async_retry_failed_canceled(assert_polling_raises_with_message): + request = lros.build_delete_async_retrycanceled_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_delete_async_retry_failed_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + +@pytest.mark.asyncio +async def test_happy_delete_async_succeeded(get_poller, get_long_running_output_return_none): + request = lros.build_delete_async_no_retry_succeeded_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + + request = lros.build_delete_async_retry_succeeded_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + +@pytest.mark.asyncio +async def test_happy_delete_provisioning(get_poller): + request = lros.build_delete_provisioning202_accepted200_succeeded_request() + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_delete_provisioning202_deletingcanceled200_request() + result = await (await get_poller(request)).result() + assert result['properties']['provisioningState'] == 'Canceled' + + request = lros.build_delete_provisioning202_deleting_failed200_request() + result = await (await get_poller(request)).result() + assert result['properties']['provisioningState'] == 'Failed' + +@pytest.mark.asyncio +async def test_happy_post(get_poller): + request = lros.build_post202_no_retry204_request() + assert await (await get_poller(request)).result() is None + + request = lros.build_post200_with_payload_request() + + sku = await (await get_poller(request)).result() + assert sku['id'] == '1' + +@pytest.mark.asyncio +async def test_happy_post_async_retry_failed_canceled(assert_polling_raises_with_message): + request = lros.build_post_async_retry_failed_request() + await assert_polling_raises_with_message(request, "Internal Server Error") + + request = lros.build_post_async_retrycanceled_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + +@pytest.mark.asyncio +async def test_happy_post_async_succeeded(get_poller): + request = lros.build_post_async_retry_succeeded_request() + prod = await (await get_poller(request)).result() + assert prod['id'] == "100" + + request = lros.build_post_async_no_retry_succeeded_request() + prod = await (await get_poller(request)).result() + assert prod['id'] == "100" + +@pytest.mark.asyncio +async def test_retrys_put(get_poller): + request = lro_retrys.build_put201_creating_succeeded200_request() + process = await (await get_poller(request)).result() + assert 'Succeeded' == process['properties']['provisioningState'] + + request = lro_retrys.build_put_async_relative_retry_succeeded_request() + process = await (await get_poller(request)).result() + assert 'Succeeded' == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_retrys_delete(get_poller, get_long_running_output_return_none): + request = lro_retrys.build_delete_provisioning202_accepted200_succeeded_request() + process = await (await get_poller(request)).result() + assert 'Succeeded' == process['properties']['provisioningState'] + + request = lro_retrys.build_delete202_retry200_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + + request = lro_retrys.build_delete_async_relative_retry_succeeded_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + +@pytest.mark.asyncio +async def test_retrys_post(get_poller, get_long_running_output_return_none): + request = lro_retrys.build_post202_retry200_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + + request = lro_retrys.build_post_async_relative_retry_succeeded_request() + assert await (await get_poller(request, get_long_running_output=get_long_running_output_return_none)).result() is None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +@pytest.mark.asyncio +async def test_custom_headers_put_async_retry_succeeded(get_poller, custom_headers): + request = lr_os_custom_header.build_put_async_retry_succeeded_request(headers=custom_headers) + assert await (await get_poller(request)).result() is not None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +@pytest.mark.asyncio +async def test_custom_headers_post_async_retry_succeeded(get_poller, custom_headers): + request = lr_os_custom_header.build_post_async_retry_succeeded_request(headers=custom_headers) + assert await (await get_poller(request)).result() is None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +@pytest.mark.asyncio +async def test_custom_headers_put201_creating_succeeded200(get_poller, custom_headers): + request = lr_os_custom_header.build_put201_creating_succeeded200_request(headers=custom_headers) + assert await (await get_poller(request)).result() is not None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +@pytest.mark.asyncio +async def test_custom_headers_post202_retry200(get_poller, custom_headers): + request = lr_os_custom_header.build_post202_retry200_request(headers=custom_headers) + assert await (await get_poller(request)).result() is None + +@pytest.mark.asyncio +async def test_sads_put_non_retry(assert_initial_call_raises_with_message, assert_polling_raises_with_message): + request = lrosads.build_put_non_retry400_request() + await assert_initial_call_raises_with_message(request, "Bad Request") + + request = lrosads.build_put_non_retry201_creating400_request() + await assert_polling_raises_with_message(request, "Error from the server") + +@pytest.mark.asyncio +async def test_sads_put_async_relative(assert_polling_raises_with_message): + request = lrosads.build_put_async_relative_retry400_request() + await assert_polling_raises_with_message(request, "Operation returned an invalid status 'Bad Request'") + + request = lrosads.build_put_async_relative_retry_no_status_request() + await assert_polling_raises_with_message(request, "no status found in body") + + request = lrosads.build_put_async_relative_retry_no_status_payload_request() + await assert_polling_raises_with_message(request, "The response from long running operation does not contain a body.") + +@pytest.mark.asyncio +async def test_sads_put_error201_no_provisioning_state_payload(assert_polling_raises_with_message): + request = lrosads.build_put_error201_no_provisioning_state_payload_request() + await assert_polling_raises_with_message(request, "The response from long running operation does not contain a body.") + +@pytest.mark.asyncio +async def test_sads_put200_invalid_json_with_exception(get_poller): + request = lrosads.build_put200_invalid_json_request() + with pytest.raises(DecodeError): + await (await get_poller(request)).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the response headers. LLC doesn't do that, so skipping") +@pytest.mark.asyncio +async def test_sads_put_async_relative_with_exception(get_poller): + request = lrosads.build_put_async_relative_retry_invalid_json_polling_request() + with pytest.raises(DecodeError): + await (await get_poller(request)).wait() + + request = lrosads.build_put_async_relative_retry_invalid_header_request() + with pytest.raises(Exception): + await (await get_poller(request)).wait() + +@pytest.mark.asyncio +async def test_sads_put_non_retry201_creating400_invalid_json_with_exception(get_poller): + request = lrosads.build_put_non_retry201_creating400_invalid_json_request() + with pytest.raises(DecodeError): + await (await get_poller(request)).wait() + +@pytest.mark.asyncio +async def tests_lro_sads_delete_non_retry(assert_initial_call_raises_with_message, assert_polling_raises_with_message): + request = lrosads.build_delete_non_retry400_request() + await assert_initial_call_raises_with_message(request, "Bad Request") + + request = lrosads.build_delete202_non_retry400_request() + await assert_polling_raises_with_message(request, "Bad Request") + +@pytest.mark.asyncio +async def test_sads_delete_async_relative(assert_polling_raises_with_message): + request = lrosads.build_delete_async_relative_retry400_request() + await assert_polling_raises_with_message(request, "Bad Request") + + request = lrosads.build_delete_async_relative_retry_no_status_request() + await assert_polling_raises_with_message(request, "no status found in body") + +@pytest.mark.asyncio +async def test_sads_delete204_succeeded(get_poller): + request = lrosads.build_delete204_succeeded_request() + await (await get_poller(request)).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +@pytest.mark.asyncio +async def test_sads_delete_async_relative_with_exception(get_poller): + request = lrosads.build_delete_async_relative_retry_invalid_header_request() + with pytest.raises(Exception): + await (await get_poller(request)).wait() + + request = lrosads.build_delete_async_relative_retry_invalid_json_polling_request() + with pytest.raises(DecodeError): + await (await get_poller(request)).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +@pytest.mark.asyncio +async def test_sads_delete202_retry_invalid_header_with_exception(get_poller): + request = lrosads.build_delete202_retry_invalid_header_request() + with pytest.raises(Exception): + await (await get_poller(request)).wait() + +@pytest.mark.asyncio +async def test_sads_post_non_retry(assert_initial_call_raises_with_message, assert_polling_raises_with_message): + request = lrosads.build_post_non_retry400_request() + await assert_initial_call_raises_with_message(request, "Bad Request") + + request = lrosads.build_post202_non_retry400_request() + await assert_polling_raises_with_message(request, "Bad Request") + +@pytest.mark.asyncio +async def test_sads_post_async_relative(assert_polling_raises_with_message): + request = lrosads.build_post_async_relative_retry400_request() + await assert_polling_raises_with_message(request, "Bad Request") + + request = lrosads.build_post_async_relative_retry_no_payload_request() + await assert_polling_raises_with_message(request, "The response from long running operation does not contain a body.") + +@pytest.mark.asyncio +async def test_sads_post202_no_location(get_poller): + # Testserver wants us to fail (coverage name is LROErrorPostNoLocation) + # Actually, Python will NOT, and consider any kind of success 2xx on the initial call + # is an actual success + request = lrosads.build_post202_no_location_request() + process = await (await get_poller(request)).result() + assert process is None + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +@pytest.mark.asyncio +async def test_sads_post_async_relative_with_exception(get_poller): + request = lrosads.build_post_async_relative_retry_invalid_header_request() + with pytest.raises(Exception): + await (await get_poller(request)).wait() + + request = lrosads.build_post_async_relative_retry_invalid_json_polling_request() + + with pytest.raises(DecodeError): + await (await get_poller(request)).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +@pytest.mark.asyncio +async def test_post202_retry_invalid_header_with_exception(get_poller): + request = lrosads.build_post202_retry_invalid_header_request() + with pytest.raises(Exception): + await (await get_poller(request)).wait() + +@pytest.mark.asyncio +async def test_polling_interval_operation(get_poller): + default_polling_interval_start_time = time.time() + request = lros.build_post_double_headers_final_azure_header_get_default_request() + product1 = await (await get_poller(request)).result() + default_polling_interval_duration = time.time() - default_polling_interval_start_time + assert abs(default_polling_interval_duration - 0) < 0.1 + + one_second_polling_interval_start_time = time.time() + request = lros.build_post_double_headers_final_azure_header_get_default_request() + + product2 = await (await get_poller(request, polling_interval=1)).result() + one_second_polling_interval_duration = time.time() - one_second_polling_interval_start_time + assert abs(one_second_polling_interval_duration - 1) < 0.1 + + assert product1 == product2 + +@pytest.mark.asyncio +async def test_passing_kwargs(get_poller): + request = lros.build_put200_succeeded_request(headers={"Content-Type": "application/json"}) + process = await (await get_poller(request)).result() + assert "Succeeded" == process['properties']['provisioningState'] + +@pytest.mark.asyncio +async def test_lro_list(get_poller): + request = lros.build_post202_list_request() + products = await (await get_poller(request)).result() + assert len(products) == 1 + product = products[0] + assert product['id'] == "100" + assert product['name'] == "foo" diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_paging.py b/test/azure/low-level/AcceptanceTests/asynctests/test_paging.py new file mode 100644 index 00000000000..96622262ad4 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_paging.py @@ -0,0 +1,332 @@ +# -------------------------------------------------------------------------- +# +# 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 functools +from async_generator import yield_, async_generator + +from paginglowlevel.aio import AutoRestPagingTestService +from paginglowlevel.rest import paging +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError +from azure.core.pipeline.policies import ContentDecodePolicy, AsyncRetryPolicy, HeadersPolicy, RequestIdPolicy + +import pytest + +@pytest.fixture +@async_generator +async def client(cookie_policy): + policies = [ + RequestIdPolicy(), + HeadersPolicy(), + ContentDecodePolicy(), + AsyncRetryPolicy(), + cookie_policy + ] + async with AutoRestPagingTestService(base_url="http://localhost:3000", policies=policies) as client: + await yield_(client) + +@pytest.fixture +def extract_data_fixture(deserializer): + async def _callback(pipeline_response, **kwargs): + item_name = kwargs.pop("item_name", "value") + next_link_name = kwargs.pop("next_link_name", "nextLink") + try: + deserialized = pipeline_response.http_response.json() # in the case of LRO + paging, the LRO returns an old response to us + except AttributeError: + deserialized = deserializer("object", pipeline_response.http_response) + list_of_elem = deserialized[item_name] + return deserialized.get(next_link_name, None), AsyncList(list_of_elem) + return _callback + +@pytest.fixture +def get_next_fixture(client): + async def _callback(prepare_request, next_link=None): + request = prepare_request(next_link) + + pipeline_response = await client.send_request( + request, + _return_pipeline_response=True + ) + pipeline_response.http_response.raise_for_status() + + return pipeline_response + return _callback + +def default_prepare_request(next_link=None, **kwargs): + initial_request = kwargs.pop("initial_request") + next_request = kwargs.pop("next_request", None) + if not next_link: + request = initial_request() + elif next_request: + try: + request = next_request(next_link) + except TypeError: + request = next_request() # the query one doesn't take next link + else: + request = initial_request(template_url=next_link) + return request + +@pytest.fixture +def get_pager(get_next_fixture, extract_data_fixture): + def _callback(initial_request, **kwargs): + prepare_request = functools.partial( + default_prepare_request, + initial_request=initial_request, + **kwargs + ) + get_next = functools.partial( + get_next_fixture, + prepare_request, + ) + extract_data = kwargs.pop("extract_data", None) + if not extract_data: + extract_data = functools.partial( + extract_data_fixture, + **kwargs + ) + + return AsyncItemPaged(get_next, extract_data) + return _callback + +@pytest.mark.asyncio +async def test_get_no_item_name_pages(get_pager): + pages = get_pager(initial_request=paging.build_get_no_item_name_pages_request) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 1 + assert items[0]['properties']['id'] == 1 + assert items[0]['properties']['name'] == "Product" + +@pytest.mark.asyncio +async def test_get_null_next_link_name_pages(get_pager): + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized['values'] + # defined as None next link in swagger + return None, AsyncList(list_of_elem) + pages = get_pager( + initial_request=paging.build_get_null_next_link_name_pages_request, + item_name="values", + extract_data=extract_data + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 1 + assert items[0]['properties']['id'] == 1 + assert items[0]['properties']['name'] == "Product" + +@pytest.mark.asyncio +async def test_get_single_pages(get_pager): + pages = get_pager(initial_request=paging.build_get_single_pages_request, item_name="values") + items = [] + async for page in pages: + items.append(page) + assert len(items) == 1 + assert items[0]['properties']['id'] == 1 + assert items[0]['properties']['name'] == "Product" + +@pytest.mark.asyncio +async def test_get_multiple_pages(get_pager): + pages = get_pager(initial_request=paging.build_get_multiple_pages_request, item_name="values") + items = [] + async for page in pages: + items.append(page) + assert len(items) == 10 + +@pytest.mark.asyncio +async def test_query_params(get_pager): + initial_request = functools.partial( + paging.build_get_with_query_params_request, + required_query_parameter='100' + ) + pages = get_pager( + initial_request=initial_request, + next_request=paging.build_next_operation_with_query_params_request, + item_name="values" + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 2 + +@pytest.mark.asyncio +async def test_get_odata_multiple_pages(get_pager): + pages = get_pager( + initial_request=paging.build_get_odata_multiple_pages_request, + item_name="values", + next_link_name="odata.nextLink", + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 10 + +@pytest.mark.asyncio +async def test_get_multiple_pages_retry_first(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_retry_first_request, + item_name="values", + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 10 + +@pytest.mark.asyncio +async def test_get_multiple_pages_retry_second(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_retry_second_request, + item_name="values", + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 10 + +@pytest.mark.asyncio +async def test_get_multiple_pages_with_offset(get_pager): + initial_request = functools.partial( + paging.build_get_multiple_pages_with_offset_request, + 100, + ) + pages = get_pager( + initial_request=initial_request, + item_name="values" + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 10 + assert items[-1]['properties']['id'] == 110 + + +@pytest.mark.asyncio +async def test_get_single_pages_failure(get_pager): + pages = get_pager( + initial_request=paging.build_get_single_pages_failure_request, + item_name="values" + ) + with pytest.raises(HttpResponseError): + async for page in pages: + print(page) + +@pytest.mark.asyncio +async def test_get_multiple_pages_failure(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_failure_request, + item_name="values" + ) + with pytest.raises(HttpResponseError): + async for page in pages: + print(page) + +@pytest.mark.asyncio +async def test_get_multiple_pages_failure_uri(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_failure_uri_request, + item_name="values" + ) + with pytest.raises(HttpResponseError): + async for page in pages: + print(page) + +@pytest.mark.asyncio +async def test_paging_fragment_path(get_pager): + initial_request = functools.partial( + paging.build_get_multiple_pages_fragment_next_link_request, + "test_user", + api_version="1.6" + ) + next_request = functools.partial( + paging.build_next_fragment_request, + "test_user", + api_version="1.6" + ) + pages = get_pager( + initial_request=initial_request, + next_request=next_request, + item_name="values", + next_link_name="odata.nextLink", + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 10 + + with pytest.raises(AttributeError): + # Be sure this method is not generated (Transform work) + paging.build_get_multiple_pages_fragment_next_link_next_request + +@pytest.mark.skip(reason="Can't figure this out yet, going to add later") +@pytest.mark.asyncio +async def test_get_multiple_pages_lro(client, get_next_fixture, extract_data_fixture): + """LRO + Paging at the same time. + """ + from azure.mgmt.core.polling.arm_polling import ARMPolling + from azure.core.polling import LROPoller + # initial LRO call + pipeline_response = await client.send_request( + paging.build_get_multiple_pages_lro_request(), + _return_pipeline_response=True + ) + pipeline_response.http_response.raise_for_status() + prepare_request = functools.partial( + default_prepare_request, + initial_request=paging.build_get_multiple_pages_lro_request, + ) + def get_long_running_output(pipeline_response): + def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + else: + return get_next_fixture(prepare_request, next_link) + extract_data = functools.partial( + extract_data_fixture, + item_name="values" + ) + return AsyncItemPaged(internal_get_next, extract_data) + + polling_method = ARMPolling(timeout=0) + poller = LROPoller(client._client, pipeline_response, get_long_running_output, polling_method) + pager = poller.result() + + # paging calls + items = list(pager) + + assert len(items) == 10 + assert items[0]['properties']['id'] == 1 + assert items[1]['properties']['id'] == 2 + +@pytest.mark.asyncio +async def test_initial_response_no_items(get_pager): + pages = get_pager( + paging.build_first_response_empty_request, + ) + items = [] + async for page in pages: + items.append(page) + assert len(items) == 1 diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_parameter.py b/test/azure/low-level/AcceptanceTests/asynctests/test_parameter.py new file mode 100644 index 00000000000..d84fc7e3dac --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_parameter.py @@ -0,0 +1,234 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from async_generator import yield_, async_generator +from msrest.exceptions import ValidationError + +from azurespecialpropertieslowlevel.aio import AutoRestAzureSpecialParametersTestClient +from azurespecialpropertieslowlevel.rest import ( + skip_url_encoding, + subscription_in_credentials, + subscription_in_method, + api_version_default, + api_version_local, + odata, +) +from azureparametergroupinglowlevel.aio import AutoRestParameterGroupingTestService +from azureparametergroupinglowlevel.rest import parameter_grouping + +import pytest + +@pytest.fixture +def valid_subscription(): + return '1234-5678-9012-3456' + +@pytest.fixture +@async_generator +async def client(valid_subscription, credential, authentication_policy): + async with AutoRestAzureSpecialParametersTestClient( + credential, valid_subscription, base_url="http://localhost:3000", authentication_policy=authentication_policy + ) as client: + await yield_(client) + +@pytest.fixture +@async_generator +async def parameter_grouping_client(authentication_policy): + async with AutoRestParameterGroupingTestService( + base_url="http://localhost:3000" + ) as client: + await yield_(client) + +@pytest.fixture +def body_parameter(): + return 1234 + +@pytest.fixture +def header_parameter(): + return 'header' + +@pytest.fixture +def query_parameter(): + return 21 + +@pytest.fixture +def path_parameter(): + return 'path' + + +@pytest.fixture +def unencoded_path(): + return 'path1/path2/path3' + +@pytest.fixture +def unencoded_query(): + return 'value1&q2=value2&q3=value3' + +@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.fixture +def send_request_parameter_grouping(parameter_grouping_client, base_send_request): + async def _send_request(request): + return await base_send_request(parameter_grouping_client, request) + return _send_request + +@pytest.mark.asyncio +async def test_post_all_required_parameters(send_request_parameter_grouping, body_parameter, header_parameter, query_parameter, path_parameter): + request = parameter_grouping.build_post_required_request( + path=path_parameter, + json=body_parameter, + query=query_parameter, + custom_header=header_parameter + ) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_required_parameters_null_optional_parameters(send_request_parameter_grouping, body_parameter, path_parameter): + request = parameter_grouping.build_post_required_request( + path=path_parameter, + json=body_parameter, + query=None, + ) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_required_parameters_with_null_required_property(path_parameter): + with pytest.raises(TypeError): + parameter_grouping.build_post_required_request() + +@pytest.mark.asyncio +async def test_post_all_optional(send_request_parameter_grouping, header_parameter, query_parameter): + request = parameter_grouping.build_post_optional_request( + custom_header=header_parameter, + query=query_parameter + ) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_none_optional(send_request_parameter_grouping): + request = parameter_grouping.build_post_optional_request(query=None) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_all_multi_param_groups(send_request_parameter_grouping, header_parameter, query_parameter): + request = parameter_grouping.build_post_multi_param_groups_request( + header_one=header_parameter, + query_one=query_parameter, + header_two="header2", + query_two=42, + ) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_some_multi_param_groups(send_request_parameter_grouping, header_parameter): + request = parameter_grouping.build_post_multi_param_groups_request( + header_one=header_parameter, + query_two=42, + ) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_shared_parameter_group_object(send_request_parameter_grouping, header_parameter): + request = parameter_grouping.build_post_shared_parameter_group_object_request( + header_one=header_parameter + ) + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_post_reserved_words(send_request_parameter_grouping): + request = parameter_grouping.build_post_reserved_words_request(from_parameter="bob", accept_parameter="yes") + await send_request_parameter_grouping(request) + +@pytest.mark.asyncio +async def test_subscription_in_credentials(send_request, valid_subscription): + # valid_api_version = '2.0' + request = subscription_in_credentials.build_post_method_global_not_provided_valid_request(subscription_id=valid_subscription) + await send_request(request) + request = subscription_in_credentials.build_post_method_global_valid_request(subscription_id=valid_subscription) + await send_request(request) + request = subscription_in_credentials.build_post_path_global_valid_request(subscription_id=valid_subscription) + await send_request(request) + request = subscription_in_credentials.build_post_swagger_global_valid_request(subscription_id=valid_subscription) + await send_request(request) + +@pytest.mark.asyncio +async def test_subscription_in_method(send_request, valid_subscription): + request = subscription_in_method.build_post_method_local_valid_request(valid_subscription) + await send_request(request) + request = subscription_in_method.build_post_path_local_valid_request(valid_subscription) + await send_request(request) + request = subscription_in_method.build_post_swagger_local_valid_request(valid_subscription) + await send_request(request) + with pytest.raises(ValidationError): + request = subscription_in_method.build_post_method_local_null_request(None) + +@pytest.mark.asyncio +async def test_api_version_default(send_request): + request = api_version_default.build_get_method_global_not_provided_valid_request() + await send_request(request) + request = api_version_default.build_get_method_global_valid_request() + await send_request(request) + request = api_version_default.build_get_path_global_valid_request() + await send_request(request) + request = api_version_default.build_get_swagger_global_valid_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_api_version_local(send_request): + request = api_version_local.build_get_method_local_valid_request() + await send_request(request) + request = api_version_local.build_get_method_local_null_request() + await send_request(request) + request = api_version_local.build_get_path_local_valid_request() + await send_request(request) + request = api_version_local.build_get_swagger_local_valid_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_skip_url_encoding(send_request, unencoded_path, unencoded_query): + request = skip_url_encoding.build_get_method_path_valid_request(unencoded_path) + await send_request(request) + request = skip_url_encoding.build_get_path_valid_request(unencoded_path) + await send_request(request) + request = skip_url_encoding.build_get_swagger_path_valid_request() + await send_request(request) + request = skip_url_encoding.build_get_method_query_valid_request(q1=unencoded_query) + await send_request(request) + request = skip_url_encoding.build_get_path_query_valid_request(q1=unencoded_query) + await send_request(request) + request = skip_url_encoding.build_get_swagger_query_valid_request() + await send_request(request) + request = skip_url_encoding.build_get_method_query_null_request() + await send_request(request) + request = skip_url_encoding.build_get_method_query_null_request(q1=None) + await send_request(request) + +@pytest.mark.asyncio +async def test_azure_odata(send_request): + request = odata.build_get_with_filter_request(filter="id gt 5 and name eq 'foo'", top=10, orderby="id") + await send_request(request) diff --git a/test/azure/low-level/AcceptanceTests/asynctests/test_xms.py b/test/azure/low-level/AcceptanceTests/asynctests/test_xms.py new file mode 100644 index 00000000000..6873d0a5655 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/asynctests/test_xms.py @@ -0,0 +1,103 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +from azure.core.exceptions import HttpResponseError + +from azurespecialpropertieslowlevel import AutoRestAzureSpecialParametersTestClient +from azurespecialpropertieslowlevel.rest import xms_client_request_id, header + +from azurespecialpropertieslowlevel.aio import AutoRestAzureSpecialParametersTestClient + +import pytest + + +@pytest.fixture +@async_generator +async def client(credential, authentication_policy): + valid_subscription = "1234-5678-9012-3456" + async with AutoRestAzureSpecialParametersTestClient( + credential, + valid_subscription, + base_url="http://localhost:3000", + authentication_policy=authentication_policy, + ) as client: + await yield_(client) + + +@pytest.fixture +@async_generator +async def client_no_request_id(credential, authentication_policy): + valid_subscription = "1234-5678-9012-3456" + async with AutoRestAzureSpecialParametersTestClient( + credential, + valid_subscription, + base_url="http://localhost:3000", + auto_request_id=False, + authentication_policy=authentication_policy, + ) as client: + await yield_(client) + +@pytest.fixture +def send_request(client, base_send_request): + async def _send_request(request, **kwargs): + return await base_send_request(client, request, **kwargs) + return _send_request + + +@pytest.mark.asyncio +async def test_client_request_id_in_exception(send_request): + request = xms_client_request_id.build_get_request() + with pytest.raises(HttpResponseError): + await send_request(request) + +@pytest.mark.asyncio +async def test_xms_request_client_id_in_client_none(send_request): + request = xms_client_request_id.build_get_request() + await send_request(request, request_id=None) + +@pytest.mark.asyncio +async def test_xms_request_client_id_in_client(send_request): + request = xms_client_request_id.build_get_request() + await send_request(request, request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + +@pytest.mark.asyncio +async def test_xms_request_client_overwrite_via_parameter(client_no_request_id): + # We DON'T support a Swagger parameter for request_id, the request_id policy will overwrite it. + # We disable the request_id policy for this test + request = xms_client_request_id.build_param_get_request(x_ms_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + response = await client_no_request_id.send_request(request) + response.raise_for_status() + +@pytest.mark.asyncio +async def test_xms_custom_named_request_id(send_request): + request = header.build_custom_named_request_id_request(foo_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + await send_request(request) + +@pytest.mark.asyncio +async def test_xms_custom_named_request_id_parameter_group(send_request): + request = header.build_custom_named_request_id_param_grouping_request(foo_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + await send_request(request) diff --git a/test/azure/low-level/AcceptanceTests/conftest.py b/test/azure/low-level/AcceptanceTests/conftest.py new file mode 100644 index 00000000000..b05e7d7e9de --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/conftest.py @@ -0,0 +1,121 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +import subprocess +import os +import signal +from os.path import dirname, realpath +from azure.core.pipeline.policies import SansIOHTTPPolicy +from msrest import Serializer, Deserializer +import pytest + + +cwd = dirname(realpath(__file__)) + +#Ideally this would be in a common helper library shared between the tests +def start_server_process(): + cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) + if os.name == 'nt': #On windows, subprocess creation works without being in the shell + return subprocess.Popen(cmd) + + return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True + +#Ideally this would be in a common helper library shared between the tests +def terminate_server_process(process): + if os.name == 'nt': + process.kill() + else: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups + +@pytest.fixture(scope="session") +def testserver(): + """Start the Autorest testserver.""" + server = start_server_process() + yield + terminate_server_process(server) + +# Ignore collection of async tests for Python 2 +collect_ignore = [] +if sys.version_info < (3,5): + collect_ignore.append("asynctests") + +@pytest.fixture() +def base_send_request(): + def send_request(client, request, **kwargs): + response = client.send_request(request, **kwargs) + response.raise_for_status() + return response + return send_request + +@pytest.fixture() +def base_send_request_json_response(): + def send_request_json_response(client, request, **kwargs): + response = client.send_request(request, **kwargs) + response.raise_for_status() + return response.json() + return send_request_json_response + +class CookiePolicy(SansIOHTTPPolicy): + def __init__(self, *args, **kwargs): + self._current_cookie = None + + def on_request(self, request, **kwargs): + http_request = request.http_request + if self._current_cookie: + http_request.headers["Cookie"] = self._current_cookie + self._current_cookie = None + + def on_response(self, request, response, **kwargs): + http_response = response.http_response + + if "Set-Cookie" in http_response.headers: + self._current_cookie = http_response.headers["Set-Cookie"] + +@pytest.fixture() +def cookie_policy(): + return CookiePolicy() + + +@pytest.fixture() +def credential(): + """I actually don't need anything, since the authentication policy + will bypass it. + """ + class FakeCredential: + pass + return FakeCredential() + +@pytest.fixture() +def authentication_policy(): + return SansIOHTTPPolicy() + +@pytest.fixture() +def serializer(): + return Serializer() + +@pytest.fixture() +def deserializer(): + return Deserializer() diff --git a/test/azure/low-level/AcceptanceTests/test_azure_url.py b/test/azure/low-level/AcceptanceTests/test_azure_url.py new file mode 100644 index 00000000000..ea01533e00b --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_azure_url.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from uuid import uuid4 + +from subscriptionidapiversionlowlevel import MicrosoftAzureTestUrl +from subscriptionidapiversionlowlevel.rest import group + +def test_azure_url(credential, authentication_policy): + + sub_id = str(uuid4()) + + with MicrosoftAzureTestUrl(credential, sub_id, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + request = group.build_get_sample_resource_group_request(subscription_id=sub_id, resource_group_name="testgroup101") + response = client.send_request(request) + response.raise_for_status() + response_json = response.json() + assert response_json['name'] == 'testgroup101' + assert response_json['location'] == "West US" diff --git a/test/azure/low-level/AcceptanceTests/test_config.py b/test/azure/low-level/AcceptanceTests/test_config.py new file mode 100644 index 00000000000..4ecbf4bda38 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_config.py @@ -0,0 +1,52 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from azure.mgmt.core.policies import ARMHttpLoggingPolicy +# Head is azure-arm +from headlowlevel import AutoRestHeadTestService + +def test_arm_http_logging_policy_default(credential): + with AutoRestHeadTestService(credential, base_url="http://localhost:3000") as client: + assert isinstance(client._config.http_logging_policy, ARMHttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == ARMHttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST + +def test_arm_http_logging_policy_custom(credential): + http_logging_policy = ARMHttpLoggingPolicy(base_url="test") + http_logging_policy = ARMHttpLoggingPolicy() + http_logging_policy.allowed_header_names.update( + {"x-ms-added-header"} + ) + with AutoRestHeadTestService(credential, base_url="http://localhost:3000", http_logging_policy=http_logging_policy) as client: + assert isinstance(client._config.http_logging_policy, ARMHttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == ARMHttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST.union({"x-ms-added-header"}) + +def test_credential_scopes_default(credential): + with AutoRestHeadTestService(credential) as client: + assert client._config.credential_scopes == ['https://management.azure.com/.default'] + +def test_credential_scopes_override(credential): + with AutoRestHeadTestService(credential, credential_scopes=["http://i-should-be-the-only-credential"]) as client: + assert client._config.credential_scopes == ["http://i-should-be-the-only-credential"] diff --git a/test/azure/low-level/AcceptanceTests/test_duration.py b/test/azure/low-level/AcceptanceTests/test_duration.py new file mode 100644 index 00000000000..d9389ea5e18 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_duration.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +from datetime import timedelta + +from bodydurationlowlevel import AutoRestDurationTestService +from bodydurationlowlevel.rest import duration + +import pytest + +@pytest.fixture +def client(): + with AutoRestDurationTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_get_null_and_invalid(send_request, send_request_json_response): + request = duration.build_get_null_request() + assert send_request(request).text == '' + + # in llc, we don't raise deserialization error + request = duration.build_get_invalid_request() + with pytest.raises(isodate.ISO8601Error): + isodate.parse_duration(send_request_json_response(request)) + +def test_positive_duration(send_request, send_request_json_response): + request = duration.build_get_positive_duration_request() + response = isodate.parse_duration(send_request_json_response(request)) + assert response == isodate.Duration(4, 45005, 0, years=3, months=6) + delta = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + request = duration.build_put_positive_duration_request(json=isodate.duration_isoformat(delta)) + send_request(request) diff --git a/test/azure/low-level/AcceptanceTests/test_head.py b/test/azure/low-level/AcceptanceTests/test_head.py new file mode 100644 index 00000000000..ee8f82ead91 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_head.py @@ -0,0 +1,63 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from headlowlevel import AutoRestHeadTestService +from headlowlevel.rest import http_success +from headexceptionslowlevel import AutoRestHeadExceptionTestService +from headexceptionslowlevel.rest import head_exception +from azure.core.exceptions import HttpResponseError + +import pytest + +def test_head(credential, authentication_policy): + with AutoRestHeadTestService(credential, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + request = http_success.build_head200_request() + response = client.send_request(request) + response.raise_for_status() + + request = http_success.build_head204_request() + response = client.send_request(request) + response.raise_for_status() + + request = http_success.build_head404_request() + response = client.send_request(request) + with pytest.raises(HttpResponseError): + response.raise_for_status() + +def test_head_exception(credential, authentication_policy): + with AutoRestHeadExceptionTestService(credential, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + request = head_exception.build_head200_request() + response = client.send_request(request) + response.raise_for_status() + + request = head_exception.build_head204_request() + response = client.send_request(request) + response.raise_for_status() + + request = head_exception.build_head404_request() + response = client.send_request(request) + with pytest.raises(HttpResponseError): + response.raise_for_status() diff --git a/test/azure/low-level/AcceptanceTests/test_lro.py b/test/azure/low-level/AcceptanceTests/test_lro.py new file mode 100644 index 00000000000..9a54b8c764a --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_lro.py @@ -0,0 +1,545 @@ +# -------------------------------------------------------------------------- +# +# 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 time + +from azure.core.exceptions import DecodeError, HttpResponseError +from azure.core.pipeline.policies import ContentDecodePolicy, RetryPolicy, HeadersPolicy, RequestIdPolicy + +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from lrolowlevel import AutoRestLongRunningOperationTestService +from lrolowlevel.rest import lr_os_custom_header, lro_retrys, lros, lrosads +from azure.core.polling import LROPoller, NoPolling + +try: + from urlparse import urlparse +except ImportError: + from urllib.parse import urlparse + +import pytest + +POLLING_INTERVAL = 0 + +class AutorestTestARMPolling(ARMPolling): + + def _polling_cookie(self, response): + """Collect retry cookie - we only want to do this for the test server + at this point, unless we implement a proper cookie policy. + + :returns: Dictionary containing a cookie header if required, + otherwise an empty dictionary. + """ + parsed_url = urlparse(response.request.url) + host = parsed_url.hostname.strip('.') + if host == 'localhost': + return {'cookie': response.headers.get('set-cookie', '')} + return {} + + def request_status(self, status_link): + request = self._client.get(status_link, headers=self._polling_cookie(self._pipeline_response.http_response)) + # ARM requires to re-inject 'x-ms-client-request-id' while polling + if 'request_id' not in self._operation_config: + self._operation_config['request_id'] = self._get_request_id() + return self._client._pipeline.run(request, stream=False, **self._operation_config) + +@pytest.fixture() +def client(cookie_policy, credential): + """Create a AutoRestLongRunningOperationTestService client with test server credentials.""" + policies = [ + RequestIdPolicy(), + HeadersPolicy(), + ContentDecodePolicy(), + RetryPolicy(), + cookie_policy + ] + + with AutoRestLongRunningOperationTestService(credential, base_url="http://localhost:3000", policies=policies, polling_interval=POLLING_INTERVAL) as client: + yield client + +@pytest.fixture() +def product(): + return {"location": "West US"} + +@pytest.fixture() +def custom_headers(): + return {"x-ms-client-request-id": '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'} + +def lro_result(func, *args, **kwargs): + if "polling" not in kwargs: + kwargs["polling"] = AutorestTestARMPolling(0) + return func(*args, **kwargs).result() + +@pytest.fixture +def get_long_running_output(deserializer): + # this is the default deserializer, just returns deserialized object + def _callback(pipeline_response): + return deserializer("object", pipeline_response.http_response) + return _callback + +@pytest.fixture +def get_long_running_output_return_none(): + # for use if the swagger has no defined return object, so we + # follow the convenience layer, and just return none + def _callback(pipeline_response): + return None + return _callback + +@pytest.fixture +def get_poller(get_long_running_output, client): + + def _callback(request, **kwargs): + pipeline_response = client.send_request( + request._to_pipeline_transport_request(), + _return_pipeline_response=True + ) + pipeline_response.http_response.raise_for_status() + polling = kwargs.pop("polling", True) + deserializer = kwargs.pop("get_long_running_output", get_long_running_output) + polling_method = kwargs.pop("polling_method", None) + if not polling_method: + polling_method = AutorestTestARMPolling(kwargs.pop("polling_interval", 0)) if polling else NoPolling() + return LROPoller(client._client, pipeline_response, deserializer, polling_method) + return _callback + +def _check_message_in_error(ex, message): + try: + assert ex.value.message.lower() == message.lower() + except AssertionError: + assert message.lower() in ex.value.message.lower() + +@pytest.fixture +def assert_polling_raises_with_message(get_poller): + def _callback(request, message, **kwargs): + poller = get_poller(request, **kwargs) + with pytest.raises(HttpResponseError) as ex: + poller.result() + _check_message_in_error(ex, message) + return _callback + +@pytest.fixture +def assert_initial_call_raises_with_message(get_poller): + def _callback(request, message, **kwargs): + with pytest.raises(HttpResponseError) as ex: + get_poller(request, **kwargs) # this makes the initial call + _check_message_in_error(ex, message) + return _callback + +def test_post_double_headers_final_continuation_token(client, get_poller, get_long_running_output): + request = lros.build_post_double_headers_final_location_get_request() + + poller = get_poller(request) + continuation_token = poller.continuation_token() + + poller = LROPoller.from_continuation_token( + polling_method=ARMPolling(0), + continuation_token=continuation_token, + client=client._client, + deserialization_callback=get_long_running_output, + ) + product = poller.result() + assert product['id'] == "100" + +def test_post_double_headers_final(get_poller): + request = lros.build_post_double_headers_final_location_get_request() + poller = get_poller(request) + product = poller.result() + assert product['id'] == "100" + + request = lros.build_post_double_headers_final_azure_header_get_request() + polling_method = AutorestTestARMPolling(0, lro_options={"final-state-via": "azure-async-operation"}) + product = get_poller(request, polling_method=polling_method).result() + assert product['id'] == "100" + +def test_post_double_headers_default(get_poller): + # This test will work as long as the default is Location + request = lros.build_post_double_headers_final_azure_header_get_default_request() + product = get_poller(request).result() + assert product['id'] == "100" + +def test_happy_put201_creating_succeeded200(get_poller): + request = lros.build_put201_creating_succeeded200_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + # Testing nopolling + request = lros.build_put201_creating_succeeded200_request() + process = get_poller(request, polling=False).result() + assert "Creating" == process['properties']['provisioningState'] + +def test_happy_put201_creating_failed200(assert_polling_raises_with_message, get_poller): + request = lros.build_put201_creating_failed200_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_put201_creating_failed200_request() + process = get_poller(request, polling=False).result() + assert "Created" == process['properties']['provisioningState'] + +def test_happy_put200_updating_succeeded204(get_poller): + request = lros.build_put200_updating_succeeded204_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + process = get_poller(request, polling=False).result() + assert "Updating" == process['properties']['provisioningState'] + +def test_happy_put200_acceptedcanceled200(get_poller, assert_polling_raises_with_message): + request = lros.build_put200_acceptedcanceled200_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_put200_acceptedcanceled200_request() + process = get_poller(request, polling=False).result() + assert "Accepted" == process['properties']['provisioningState'] + +def test_happy_put_no_header_in_retry(get_poller): + request = lros.build_put_no_header_in_retry_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put_async_no_header_in_retry_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + +def test_happy_put_sub_resource(get_poller): + request = lros.build_put_sub_resource_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put_async_sub_resource_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + +def test_happy_put_non_resource(get_poller): + request = lros.build_put_non_resource_request() + process = get_poller(request).result() + assert "100" == process['id'] + + request = lros.build_put_async_non_resource_request() + process = get_poller(request).result() + assert "100" == process['id'] + +def test_happy_put200_succeeded(get_poller): + request = lros.build_put200_succeeded_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put200_succeeded_no_state_request() + process = get_poller(request).result() + assert "100" == process['id'] + +def test_put201_succeeded(get_poller): + request = lros.build_put201_succeeded_request() + process = get_poller(request).result() + + assert "Succeeded" == process['properties']['provisioningState'] + assert "100" == process['id'] + assert "foo" == process['name'] + +def test_happy_put202_retry200(get_poller): + request = lros.build_put202_retry200_request() + process = get_poller(request).result() + assert "100" == process['id'] + +def test_happy_put_retry_succeeded(get_poller): + request = lros.build_put_async_retry_succeeded_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_put_async_no_retry_succeeded_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + +def test_happy_put_retry_failed_canceled(get_poller, assert_polling_raises_with_message): + request = lros.build_put_async_retry_failed_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_put_async_no_retrycanceled_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + +def test_post202_retry200(get_poller, get_long_running_output_return_none): + request = lros.build_post202_retry200_request() + process = get_poller(request, get_long_running_output=get_long_running_output_return_none).result() + assert process is None + +def test_happy_delete(get_poller): + request = lros.build_delete204_succeeded_request() + assert get_poller(request).result() is None + + request = lros.build_delete202_retry200_request() + assert get_poller(request).result() is None + + request = lros.build_delete202_no_retry204_request() + assert get_poller(request).result() is None + +def test_happy_delete_no_header_in_retry(get_poller, get_long_running_output_return_none): + request = lros.build_delete_no_header_in_retry_request() + assert get_poller(request).result() is None + + request = lros.build_delete_async_no_header_in_retry_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + +def test_happy_delete_async_retry_failed_canceled(assert_polling_raises_with_message): + request = lros.build_delete_async_retrycanceled_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + + request = lros.build_delete_async_retry_failed_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + +def test_happy_delete_async_succeeded(get_poller, get_long_running_output_return_none): + request = lros.build_delete_async_no_retry_succeeded_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + + request = lros.build_delete_async_retry_succeeded_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + +def test_happy_delete_provisioning(get_poller): + request = lros.build_delete_provisioning202_accepted200_succeeded_request() + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + + request = lros.build_delete_provisioning202_deletingcanceled200_request() + result = get_poller(request).result() + assert result['properties']['provisioningState'] == 'Canceled' + + request = lros.build_delete_provisioning202_deleting_failed200_request() + result = get_poller(request).result() + assert result['properties']['provisioningState'] == 'Failed' + +def test_happy_post(get_poller): + request = lros.build_post202_no_retry204_request() + assert get_poller(request).result() is None + + request = lros.build_post200_with_payload_request() + + sku = get_poller(request).result() + assert sku['id'] == '1' + +def test_happy_post_async_retry_failed_canceled(assert_polling_raises_with_message): + request = lros.build_post_async_retry_failed_request() + assert_polling_raises_with_message(request, "Internal Server Error") + + request = lros.build_post_async_retrycanceled_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'OK'") + +def test_happy_post_async_succeeded(get_poller): + request = lros.build_post_async_retry_succeeded_request() + prod = get_poller(request).result() + assert prod['id'] == "100" + + request = lros.build_post_async_no_retry_succeeded_request() + prod = get_poller(request).result() + assert prod['id'] == "100" + +def test_retrys_put(get_poller): + request = lro_retrys.build_put201_creating_succeeded200_request() + process = get_poller(request).result() + assert 'Succeeded' == process['properties']['provisioningState'] + + request = lro_retrys.build_put_async_relative_retry_succeeded_request() + process = get_poller(request).result() + assert 'Succeeded' == process['properties']['provisioningState'] + +def test_retrys_delete(get_poller, get_long_running_output_return_none): + request = lro_retrys.build_delete_provisioning202_accepted200_succeeded_request() + process = get_poller(request).result() + assert 'Succeeded' == process['properties']['provisioningState'] + + request = lro_retrys.build_delete202_retry200_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + + request = lro_retrys.build_delete_async_relative_retry_succeeded_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + +def test_retrys_post(get_poller, get_long_running_output_return_none): + request = lro_retrys.build_post202_retry200_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + + request = lro_retrys.build_post_async_relative_retry_succeeded_request() + assert get_poller(request, get_long_running_output=get_long_running_output_return_none).result() is None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +def test_custom_headers_put_async_retry_succeeded(get_poller, custom_headers): + request = lr_os_custom_header.build_put_async_retry_succeeded_request(headers=custom_headers) + assert get_poller(request).result() is not None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +def test_custom_headers_post_async_retry_succeeded(get_poller, custom_headers): + request = lr_os_custom_header.build_post_async_retry_succeeded_request(headers=custom_headers) + assert get_poller(request).result() is None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +def test_custom_headers_put201_creating_succeeded200(get_poller, custom_headers): + request = lr_os_custom_header.build_put201_creating_succeeded200_request(headers=custom_headers) + assert get_poller(request).result() is not None + +@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +def test_custom_headers_post202_retry200(get_poller, custom_headers): + request = lr_os_custom_header.build_post202_retry200_request(headers=custom_headers) + assert get_poller(request).result() is None + +def test_sads_put_non_retry(assert_initial_call_raises_with_message, assert_polling_raises_with_message): + request = lrosads.build_put_non_retry400_request() + assert_initial_call_raises_with_message(request, "Bad Request") + + request = lrosads.build_put_non_retry201_creating400_request() + assert_polling_raises_with_message(request, "Error from the server") + +def test_sads_put_async_relative(assert_polling_raises_with_message): + request = lrosads.build_put_async_relative_retry400_request() + assert_polling_raises_with_message(request, "Operation returned an invalid status 'Bad Request'") + + request = lrosads.build_put_async_relative_retry_no_status_request() + assert_polling_raises_with_message(request, "no status found in body") + + request = lrosads.build_put_async_relative_retry_no_status_payload_request() + assert_polling_raises_with_message(request, "The response from long running operation does not contain a body.") + +def test_sads_put_error201_no_provisioning_state_payload(assert_polling_raises_with_message): + request = lrosads.build_put_error201_no_provisioning_state_payload_request() + assert_polling_raises_with_message(request, "The response from long running operation does not contain a body.") + +def test_sads_put200_invalid_json_with_exception(get_poller): + request = lrosads.build_put200_invalid_json_request() + with pytest.raises(DecodeError): + get_poller(request).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the response headers. LLC doesn't do that, so skipping") +def test_sads_put_async_relative_with_exception(get_poller): + request = lrosads.build_put_async_relative_retry_invalid_json_polling_request() + with pytest.raises(DecodeError): + get_poller(request).wait() + + request = lrosads.build_put_async_relative_retry_invalid_header_request() + with pytest.raises(Exception): + get_poller(request).wait() + +def test_sads_put_non_retry201_creating400_invalid_json_with_exception(get_poller): + request = lrosads.build_put_non_retry201_creating400_invalid_json_request() + with pytest.raises(DecodeError): + get_poller(request).wait() + +def tests_lro_sads_delete_non_retry(assert_initial_call_raises_with_message, assert_polling_raises_with_message): + request = lrosads.build_delete_non_retry400_request() + assert_initial_call_raises_with_message(request, "Bad Request") + + request = lrosads.build_delete202_non_retry400_request() + assert_polling_raises_with_message(request, "Bad Request") + +def test_sads_delete_async_relative(assert_polling_raises_with_message): + request = lrosads.build_delete_async_relative_retry400_request() + assert_polling_raises_with_message(request, "Bad Request") + + request = lrosads.build_delete_async_relative_retry_no_status_request() + assert_polling_raises_with_message(request, "no status found in body") + +def test_sads_delete204_succeeded(get_poller): + request = lrosads.build_delete204_succeeded_request() + get_poller(request).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +def test_sads_delete_async_relative_with_exception(get_poller): + request = lrosads.build_delete_async_relative_retry_invalid_header_request() + with pytest.raises(Exception): + get_poller(request).wait() + + request = lrosads.build_delete_async_relative_retry_invalid_json_polling_request() + with pytest.raises(DecodeError): + get_poller(request).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +def test_sads_delete202_retry_invalid_header_with_exception(get_poller): + request = lrosads.build_delete202_retry_invalid_header_request() + with pytest.raises(Exception): + get_poller(request).wait() + +def test_sads_post_non_retry(assert_initial_call_raises_with_message, assert_polling_raises_with_message): + request = lrosads.build_post_non_retry400_request() + assert_initial_call_raises_with_message(request, "Bad Request") + + request = lrosads.build_post202_non_retry400_request() + assert_polling_raises_with_message(request, "Bad Request") + +def test_sads_post_async_relative(assert_polling_raises_with_message): + request = lrosads.build_post_async_relative_retry400_request() + assert_polling_raises_with_message(request, "Bad Request") + + request = lrosads.build_post_async_relative_retry_no_payload_request() + assert_polling_raises_with_message(request, "The response from long running operation does not contain a body.") + +def test_sads_post202_no_location(get_poller): + # Testserver wants us to fail (coverage name is LROErrorPostNoLocation) + # Actually, Python will NOT, and consider any kind of success 2xx on the initial call + # is an actual success + request = lrosads.build_post202_no_location_request() + process = get_poller(request).result() + assert process is None + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +def test_sads_post_async_relative_with_exception(get_poller): + request = lrosads.build_post_async_relative_retry_invalid_header_request() + with pytest.raises(Exception): + get_poller(request).wait() + + request = lrosads.build_post_async_relative_retry_invalid_json_polling_request() + + with pytest.raises(DecodeError): + get_poller(request).wait() + +@pytest.mark.skip(reason="The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping") +def test_post202_retry_invalid_header_with_exception(get_poller): + request = lrosads.build_post202_retry_invalid_header_request() + with pytest.raises(Exception): + get_poller(request).wait() + +def test_polling_interval_operation(get_poller): + default_polling_interval_start_time = time.time() + request = lros.build_post_double_headers_final_azure_header_get_default_request() + product1 = get_poller(request).result() + default_polling_interval_duration = time.time() - default_polling_interval_start_time + assert abs(default_polling_interval_duration - 0) < 0.1 + + one_second_polling_interval_start_time = time.time() + request = lros.build_post_double_headers_final_azure_header_get_default_request() + + product2 = get_poller(request, polling_interval=1).result() + one_second_polling_interval_duration = time.time() - one_second_polling_interval_start_time + assert abs(one_second_polling_interval_duration - 1) < 0.1 + + assert product1 == product2 + +def test_passing_kwargs(get_poller): + request = lros.build_put200_succeeded_request(headers={"Content-Type": "application/json"}) + process = get_poller(request).result() + assert "Succeeded" == process['properties']['provisioningState'] + +def test_lro_list(get_poller): + request = lros.build_post202_list_request() + products = get_poller(request).result() + assert len(products) == 1 + product = products[0] + assert product['id'] == "100" + assert product['name'] == "foo" + diff --git a/test/azure/low-level/AcceptanceTests/test_paging.py b/test/azure/low-level/AcceptanceTests/test_paging.py new file mode 100644 index 00000000000..6e8c0d6a864 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_paging.py @@ -0,0 +1,284 @@ +# -------------------------------------------------------------------------- +# +# 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 functools +import sys +from azure.core.rest import HttpRequest +from azure.core.paging import ItemPaged +from paginglowlevel import AutoRestPagingTestService +from paginglowlevel.rest import paging +from azure.core.exceptions import HttpResponseError + + +import pytest + +@pytest.fixture +def client(): + with AutoRestPagingTestService(base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def extract_data_fixture(deserializer): + def _callback(pipeline_response, **kwargs): + item_name = kwargs.pop("item_name", "value") + next_link_name = kwargs.pop("next_link_name", "nextLink") + try: + deserialized = pipeline_response.http_response.json() # in the case of LRO + paging, the LRO returns an old response to us + except AttributeError: + deserialized = deserializer("object", pipeline_response.http_response) + list_of_elem = deserialized[item_name] + return deserialized.get(next_link_name, None), iter(list_of_elem) + return _callback + +@pytest.fixture +def get_next_fixture(client): + def _callback(prepare_request, next_link=None): + request = prepare_request(next_link) + + pipeline_response = client.send_request( + request, + _return_pipeline_response=True + ) + pipeline_response.http_response.raise_for_status() + + return pipeline_response + return _callback + +def default_prepare_request(next_link=None, **kwargs): + initial_request = kwargs.pop("initial_request") + next_request = kwargs.pop("next_request", None) + if not next_link: + request = initial_request() + elif next_request: + try: + request = next_request(next_link) + except TypeError: + request = next_request() # the query one doesn't take next link + else: + request = initial_request(template_url=next_link) + return request + +@pytest.fixture +def get_pager(get_next_fixture, extract_data_fixture): + def _callback(initial_request, **kwargs): + prepare_request = functools.partial( + default_prepare_request, + initial_request=initial_request, + **kwargs + ) + get_next = functools.partial( + get_next_fixture, + prepare_request, + ) + extract_data = kwargs.pop("extract_data", None) + if not extract_data: + extract_data = functools.partial( + extract_data_fixture, + **kwargs + ) + + return ItemPaged(get_next, extract_data) + return _callback + +def test_get_no_item_name_pages(get_pager): + pages = get_pager(initial_request=paging.build_get_no_item_name_pages_request) + items = [i for i in pages] + assert len(items) == 1 + assert items[0]['properties']['id'] == 1 + assert items[0]['properties']['name'] == "Product" + +def test_get_null_next_link_name_pages(get_pager): + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized['values'] + # defined as None next link in swagger + return None, iter(list_of_elem) + pages = get_pager( + initial_request=paging.build_get_null_next_link_name_pages_request, + item_name="values", + extract_data=extract_data + ) + items = [i for i in pages] + assert len(items) == 1 + assert items[0]['properties']['id'] == 1 + assert items[0]['properties']['name'] == "Product" + +def test_get_single_pages(get_pager): + pages = get_pager(initial_request=paging.build_get_single_pages_request, item_name="values") + items = [i for i in pages] + assert len(items) == 1 + assert items[0]['properties']['id'] == 1 + assert items[0]['properties']['name'] == "Product" + +def test_get_multiple_pages(get_pager): + pages = get_pager(initial_request=paging.build_get_multiple_pages_request, item_name="values") + items = [i for i in pages] + assert len(items) == 10 + +def test_query_params(get_pager): + initial_request = functools.partial( + paging.build_get_with_query_params_request, + required_query_parameter='100' + ) + pages = get_pager( + initial_request=initial_request, + next_request=paging.build_next_operation_with_query_params_request, + item_name="values" + ) + items = [i for i in pages] + assert len(items) == 2 + +def test_get_odata_multiple_pages(get_pager): + pages = get_pager( + initial_request=paging.build_get_odata_multiple_pages_request, + item_name="values", + next_link_name="odata.nextLink", + ) + items = [i for i in pages] + assert len(items) == 10 + +def test_get_multiple_pages_retry_first(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_retry_first_request, + item_name="values", + ) + items = [i for i in pages] + assert len(items) == 10 + +def test_get_multiple_pages_retry_second(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_retry_second_request, + item_name="values", + ) + items = [i for i in pages] + assert len(items) == 10 + +def test_get_multiple_pages_with_offset(get_pager): + initial_request = functools.partial( + paging.build_get_multiple_pages_with_offset_request, + 100, + ) + pages = get_pager( + initial_request=initial_request, + item_name="values" + ) + items = [i for i in pages] + assert len(items) == 10 + assert items[-1]['properties']['id'] == 110 + + +def test_get_single_pages_failure(get_pager): + pages = get_pager( + initial_request=paging.build_get_single_pages_failure_request, + item_name="values" + ) + with pytest.raises(HttpResponseError): + list(pages) + +def test_get_multiple_pages_failure(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_failure_request, + item_name="values" + ) + with pytest.raises(HttpResponseError): + list(pages) + +def test_get_multiple_pages_failure_uri(get_pager): + pages = get_pager( + initial_request=paging.build_get_multiple_pages_failure_uri_request, + item_name="values" + ) + with pytest.raises(HttpResponseError): + list(pages) + +def test_paging_fragment_path(get_pager): + initial_request = functools.partial( + paging.build_get_multiple_pages_fragment_next_link_request, + "test_user", + api_version="1.6" + ) + next_request = functools.partial( + paging.build_next_fragment_request, + "test_user", + api_version="1.6" + ) + pages = get_pager( + initial_request=initial_request, + next_request=next_request, + item_name="values", + next_link_name="odata.nextLink", + ) + items = [i for i in pages] + assert len(items) == 10 + + with pytest.raises(AttributeError): + # Be sure this method is not generated (Transform work) + paging.build_get_multiple_pages_fragment_next_link_next_request + +@pytest.mark.skip(reason="Can't figure this out yet, going to add later") +def test_get_multiple_pages_lro(client, get_next_fixture, extract_data_fixture): + """LRO + Paging at the same time. + """ + from azure.mgmt.core.polling.arm_polling import ARMPolling + from azure.core.polling import LROPoller + # initial LRO call + pipeline_response = client.send_request( + paging.build_get_multiple_pages_lro_request(), + _return_pipeline_response=True + ) + pipeline_response.http_response.raise_for_status() + prepare_request = functools.partial( + default_prepare_request, + initial_request=paging.build_get_multiple_pages_lro_request, + ) + def get_long_running_output(pipeline_response): + def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + else: + return get_next_fixture(prepare_request, next_link) + extract_data = functools.partial( + extract_data_fixture, + item_name="values" + ) + return ItemPaged(internal_get_next, extract_data) + + polling_method = ARMPolling(timeout=0) + poller = LROPoller(client._client, pipeline_response, get_long_running_output, polling_method) + pager = poller.result() + + # paging calls + items = list(pager) + + assert len(items) == 10 + assert items[0]['properties']['id'] == 1 + assert items[1]['properties']['id'] == 2 + +def test_initial_response_no_items(get_pager): + pages = get_pager( + paging.build_first_response_empty_request, + ) + items = [i for i in pages] + assert len(items) == 1 diff --git a/test/azure/low-level/AcceptanceTests/test_parameter.py b/test/azure/low-level/AcceptanceTests/test_parameter.py new file mode 100644 index 00000000000..9711531ae36 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_parameter.py @@ -0,0 +1,213 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from msrest.exceptions import ValidationError +from azurespecialpropertieslowlevel import AutoRestAzureSpecialParametersTestClient +from azurespecialpropertieslowlevel.rest import ( + skip_url_encoding, + subscription_in_credentials, + subscription_in_method, + api_version_default, + api_version_local, + odata, +) +from azureparametergroupinglowlevel import AutoRestParameterGroupingTestService +from azureparametergroupinglowlevel.rest import parameter_grouping + + +import pytest + +@pytest.fixture +def valid_subscription(): + return '1234-5678-9012-3456' + +@pytest.fixture +def client(valid_subscription, credential, authentication_policy): + with AutoRestAzureSpecialParametersTestClient(credential, valid_subscription, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: + yield client + +@pytest.fixture +def parameter_grouping_client(): + with AutoRestParameterGroupingTestService(base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def body_parameter(): + return 1234 + +@pytest.fixture +def header_parameter(): + return 'header' + +@pytest.fixture +def query_parameter(): + return 21 + +@pytest.fixture +def path_parameter(): + return 'path' + + +@pytest.fixture +def unencoded_path(): + return 'path1/path2/path3' + +@pytest.fixture +def unencoded_query(): + return 'value1&q2=value2&q3=value3' + +@pytest.fixture +def send_request(client, base_send_request): + def _send_request(request): + return base_send_request(client, request) + return _send_request + +@pytest.fixture +def send_request_parameter_grouping(parameter_grouping_client, base_send_request): + def _send_request(request): + return base_send_request(parameter_grouping_client, request) + return _send_request + +def test_post_all_required_parameters(send_request_parameter_grouping, body_parameter, header_parameter, query_parameter, path_parameter): + request = parameter_grouping.build_post_required_request( + path=path_parameter, + json=body_parameter, + query=query_parameter, + custom_header=header_parameter + ) + send_request_parameter_grouping(request) + +def test_post_required_parameters_null_optional_parameters(send_request_parameter_grouping, body_parameter, path_parameter): + request = parameter_grouping.build_post_required_request( + path=path_parameter, + json=body_parameter, + query=None, + ) + send_request_parameter_grouping(request) + +def test_post_required_parameters_with_null_required_property(path_parameter): + with pytest.raises(TypeError): + parameter_grouping.build_post_required_request() + +def test_post_reserved_words(send_request_parameter_grouping): + request = parameter_grouping.build_post_reserved_words_request(from_parameter="bob", accept_parameter="yes") + send_request_parameter_grouping(request) + +def test_post_all_optional(send_request_parameter_grouping, header_parameter, query_parameter): + request = parameter_grouping.build_post_optional_request( + custom_header=header_parameter, + query=query_parameter + ) + send_request_parameter_grouping(request) + +def test_post_none_optional(send_request_parameter_grouping): + request = parameter_grouping.build_post_optional_request(query=None) + send_request_parameter_grouping(request) + +def test_post_all_multi_param_groups(send_request_parameter_grouping, header_parameter, query_parameter): + request = parameter_grouping.build_post_multi_param_groups_request( + header_one=header_parameter, + query_one=query_parameter, + header_two="header2", + query_two=42, + ) + send_request_parameter_grouping(request) + +def test_post_some_multi_param_groups(send_request_parameter_grouping, header_parameter): + request = parameter_grouping.build_post_multi_param_groups_request( + header_one=header_parameter, + query_two=42, + ) + send_request_parameter_grouping(request) + +def test_post_shared_parameter_group_object(send_request_parameter_grouping, header_parameter): + request = parameter_grouping.build_post_shared_parameter_group_object_request( + header_one=header_parameter + ) + send_request_parameter_grouping(request) + +def test_subscription_in_credentials(send_request, valid_subscription): + # valid_api_version = '2.0' + request = subscription_in_credentials.build_post_method_global_not_provided_valid_request(subscription_id=valid_subscription) + send_request(request) + request = subscription_in_credentials.build_post_method_global_valid_request(subscription_id=valid_subscription) + send_request(request) + request = subscription_in_credentials.build_post_path_global_valid_request(subscription_id=valid_subscription) + send_request(request) + request = subscription_in_credentials.build_post_swagger_global_valid_request(subscription_id=valid_subscription) + send_request(request) + +def test_subscription_in_method(send_request, valid_subscription): + request = subscription_in_method.build_post_method_local_valid_request(valid_subscription) + send_request(request) + request = subscription_in_method.build_post_path_local_valid_request(valid_subscription) + send_request(request) + request = subscription_in_method.build_post_swagger_local_valid_request(valid_subscription) + send_request(request) + with pytest.raises(ValidationError): + request = subscription_in_method.build_post_method_local_null_request(None) + +def test_api_version_default(send_request): + request = api_version_default.build_get_method_global_not_provided_valid_request() + send_request(request) + request = api_version_default.build_get_method_global_valid_request() + send_request(request) + request = api_version_default.build_get_path_global_valid_request() + send_request(request) + request = api_version_default.build_get_swagger_global_valid_request() + send_request(request) + +def test_api_version_local(send_request): + request = api_version_local.build_get_method_local_valid_request() + send_request(request) + request = api_version_local.build_get_method_local_null_request() + send_request(request) + request = api_version_local.build_get_path_local_valid_request() + send_request(request) + request = api_version_local.build_get_swagger_local_valid_request() + send_request(request) + +def test_skip_url_encoding(send_request, unencoded_path, unencoded_query): + request = skip_url_encoding.build_get_method_path_valid_request(unencoded_path) + send_request(request) + request = skip_url_encoding.build_get_path_valid_request(unencoded_path) + send_request(request) + request = skip_url_encoding.build_get_swagger_path_valid_request() + send_request(request) + request = skip_url_encoding.build_get_method_query_valid_request(q1=unencoded_query) + send_request(request) + request = skip_url_encoding.build_get_path_query_valid_request(q1=unencoded_query) + send_request(request) + request = skip_url_encoding.build_get_swagger_query_valid_request() + send_request(request) + request = skip_url_encoding.build_get_method_query_null_request() + send_request(request) + request = skip_url_encoding.build_get_method_query_null_request(q1=None) + send_request(request) + +def test_azure_odata(send_request): + request = odata.build_get_with_filter_request(filter="id gt 5 and name eq 'foo'", top=10, orderby="id") + send_request(request) diff --git a/test/azure/low-level/AcceptanceTests/test_xms.py b/test/azure/low-level/AcceptanceTests/test_xms.py new file mode 100644 index 00000000000..1228c81c6f6 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_xms.py @@ -0,0 +1,92 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError + +from azurespecialpropertieslowlevel import AutoRestAzureSpecialParametersTestClient +from azurespecialpropertieslowlevel.rest import xms_client_request_id, header + +import pytest + + +@pytest.fixture +def client(credential, authentication_policy): + valid_subscription = "1234-5678-9012-3456" + with AutoRestAzureSpecialParametersTestClient( + credential, + valid_subscription, + base_url="http://localhost:3000", + authentication_policy=authentication_policy, + ) as client: + yield client + + +@pytest.fixture +def client_no_request_id(credential, authentication_policy): + valid_subscription = "1234-5678-9012-3456" + with AutoRestAzureSpecialParametersTestClient( + credential, + valid_subscription, + base_url="http://localhost:3000", + auto_request_id=False, + authentication_policy=authentication_policy, + ) as client: + yield client + +@pytest.fixture +def send_request(client, base_send_request): + def _send_request(request, **kwargs): + return base_send_request(client, request, **kwargs) + return _send_request + + +def test_client_request_id_in_exception(send_request): + request = xms_client_request_id.build_get_request() + with pytest.raises(HttpResponseError): + send_request(request) + +def test_xms_request_client_id_in_client_none(send_request): + request = xms_client_request_id.build_get_request() + send_request(request, request_id=None) + +def test_xms_request_client_id_in_client(send_request): + request = xms_client_request_id.build_get_request() + send_request(request, request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + +def test_xms_request_client_overwrite_via_parameter(client_no_request_id): + # We DON'T support a Swagger parameter for request_id, the request_id policy will overwrite it. + # We disable the request_id policy for this test + request = xms_client_request_id.build_param_get_request(x_ms_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + response = client_no_request_id.send_request(request) + response.raise_for_status() + +def test_xms_custom_named_request_id(send_request): + request = header.build_custom_named_request_id_request(foo_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + send_request(request) + +def test_xms_custom_named_request_id_parameter_group(send_request): + request = header.build_custom_named_request_id_param_grouping_request(foo_client_request_id="9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + send_request(request) diff --git a/test/azure/low-level/AcceptanceTests/test_zzz.py b/test/azure/low-level/AcceptanceTests/test_zzz.py new file mode 100644 index 00000000000..bbd1b0460a5 --- /dev/null +++ b/test/azure/low-level/AcceptanceTests/test_zzz.py @@ -0,0 +1,91 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +import datetime +import os +import platform +import warnings + +from azurereportlowlevel import AutoRestReportServiceForAzure, rest + + +class TestAcceptance(object): + + def test_ensure_coverage(self): + client = AutoRestReportServiceForAzure(base_url="http://localhost:3000") + request = rest.build_get_report_request(qualifier=platform.python_version()) + report = client.send_request(request).json() + + # Add tests that wont be supported due to the nature of Python here + not_supported = { + "LROConstantParameterizedPost": 1, # involves formatting base url + "LROConstantParameterizedGet": 1, # involves formatting base url + "CustomHeaderPutAsyncSucceded": 1, # waiting for https://github.com/Azure/azure-sdk-for-python/issues/17757 to be released + "CustomHeaderPostAsyncSucceded": 1, # waiting for https://github.com/Azure/azure-sdk-for-python/issues/17757 to be released + "CustomHeaderPutSucceeded": 1, # waiting for https://github.com/Azure/azure-sdk-for-python/issues/17757 to be released + "CustomHeaderPostSucceeded": 1, # waiting for https://github.com/Azure/azure-sdk-for-python/issues/17757 to be released + "PagingReturnModelWithXMSClientName": 1, # not relevant, we don't generate return models in LLC + "PagingCustomUrlPartialNextLink": 1, # involves formatting base url + "PagingCustomUrlPartialOperationNextLink": 1, # involves formatting base url + "LROParameterizedEndpoint": 1, # involves formatting base url + "LROErrorPutAsyncInvalidJsonPolling": 1, # The reason this fails is bc the convenience layer fails in deserializing the response headers. LLC doesn't do that, so skipping + "LROErrorPutAsyncInvalidHeader": 1, # The reason this fails is bc the convenience layer fails in deserializing the response headers. LLC doesn't do that, so skipping + "LROErrorDelete202RetryInvalidHeader": 1, # The reason this fails is bc the convenience layer fails in deserializing the response headers. LLC doesn't do that, so skipping + "LROErrorDeleteAsyncInvalidHeader": 1, # The reason this fails is bc the convenience layer fails in deserializing the response headers. LLC doesn't do that, so skipping + "LROErrorDeleteAsyncInvalidJsonPolling": 1, # The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping + "LROErrorPost202RetryInvalidHeader": 1, # The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping + "LROErrorPostAsyncInvalidHeader": 1, # The reason this fails is bc the convenience layer fails in deserializing the retry-after header /bar as an int. LLC doesn't do that, so skipping + "LROErrorPostAsyncInvalidJsonPolling": 1, # The reason this fails is bc the convenience layer fails in deserializing. LLC doesn't do that, so skipping + } + + # Please add missing features or failing tests here + missing_features_or_bugs = { + "PagingMultipleLRO": 1, # can't quite figure it out, skipping for now bc low pri + } + + print("Coverage:") + self._print_report(report, not_supported, missing_features_or_bugs) + + + def _print_report(self, report, not_supported=None, missing_features_or_bugs=None): + if not_supported: + report.update(not_supported) + for s in not_supported.keys(): + print("IGNORING {0}".format(s)) + + if missing_features_or_bugs: + report.update(missing_features_or_bugs) + for s in missing_features_or_bugs.keys(): + print("PENDING {0}".format(s)) + + failed = [k for k, v in report.items() if v == 0] + for s in failed: + print("FAILED TO EXECUTE {0}".format(s)) + + total_tests = len(report) + warnings.warn ("The test coverage is {0}/{1}.".format(total_tests - len(failed), total_tests)) + + assert 0 == len(failed) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/__init__.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/__init__.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_auto_rest_duration_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..79ec50941a0 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_auto_rest_duration_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestDurationTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDurationTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydurationlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydurationlowlevel.rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDurationTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_configuration.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_version.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/__init__.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/__init__.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/_auto_rest_duration_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..e76b2388a01 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/_auto_rest_duration_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestDurationTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestDurationTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydurationlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydurationlowlevel.rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDurationTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_configuration.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/py.typed b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/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/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/__init__.py new file mode 100644 index 00000000000..2551fd5500f --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/__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 ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_put_positive_duration_request + from ._request_builders_py3 import build_get_positive_duration_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_put_positive_duration_request # type: ignore + from ._request_builders import build_get_positive_duration_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_put_positive_duration_request", + "build_get_positive_duration_request", + "build_get_invalid_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders.py new file mode 100644 index 00000000000..0278d280973 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders.py @@ -0,0 +1,159 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "timedelta (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders_py3.py new file mode 100644 index 00000000000..9e75a3d6c0e --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders_py3.py @@ -0,0 +1,122 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_positive_duration_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "timedelta (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_positive_duration_request(**kwargs: Any) -> HttpRequest: + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/setup.py new file mode 100644 index 00000000000..5d6c5294492 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureBodyDurationLowLevel/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 = "autorestdurationtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDurationTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDurationTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/__init__.py new file mode 100644 index 00000000000..98bf4004ed5 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/__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 ._auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestParameterGroupingTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_auto_rest_parameter_grouping_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_auto_rest_parameter_grouping_test_service.py new file mode 100644 index 00000000000..a34b15caefc --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_auto_rest_parameter_grouping_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestParameterGroupingTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterGroupingTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterGroupingTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `azureparametergroupinglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azureparametergroupinglowlevel.rest import parameter_grouping + >>> request = parameter_grouping.build_post_required_request(path, json=json, content=content, custom_header=custom_header, query=query, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestParameterGroupingTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_configuration.py new file mode 100644 index 00000000000..2cf9f087e57 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_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 AutoRestParameterGroupingTestServiceConfiguration(Configuration): + """Configuration for AutoRestParameterGroupingTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestParameterGroupingTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestparametergroupingtestservice/{}".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/Expected/AcceptanceTests/Anything/anything/_version.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/__init__.py new file mode 100644 index 00000000000..b949ecefdc2 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/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 ._auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService + +__all__ = ["AutoRestParameterGroupingTestService"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/_auto_rest_parameter_grouping_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/_auto_rest_parameter_grouping_test_service.py new file mode 100644 index 00000000000..4b0c2a26f8e --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/_auto_rest_parameter_grouping_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestParameterGroupingTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestParameterGroupingTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterGroupingTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `azureparametergroupinglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azureparametergroupinglowlevel.rest import parameter_grouping + >>> request = parameter_grouping.build_post_required_request(path, json=json, content=content, custom_header=custom_header, query=query, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestParameterGroupingTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/aio/_configuration.py new file mode 100644 index 00000000000..41cfe947cb7 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/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 AutoRestParameterGroupingTestServiceConfiguration(Configuration): + """Configuration for AutoRestParameterGroupingTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestParameterGroupingTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestparametergroupingtestservice/{}".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/Expected/AcceptanceTests/Anything/anything/py.typed b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/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/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/__init__.py new file mode 100644 index 00000000000..7054a526d92 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/__init__.py @@ -0,0 +1,28 @@ +# 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_post_required_request + from ._request_builders_py3 import build_post_optional_request + from ._request_builders_py3 import build_post_reserved_words_request + from ._request_builders_py3 import build_post_multi_param_groups_request + from ._request_builders_py3 import build_post_shared_parameter_group_object_request +except (SyntaxError, ImportError): + from ._request_builders import build_post_required_request # type: ignore + from ._request_builders import build_post_optional_request # type: ignore + from ._request_builders import build_post_reserved_words_request # type: ignore + from ._request_builders import build_post_multi_param_groups_request # type: ignore + from ._request_builders import build_post_shared_parameter_group_object_request # type: ignore + +__all__ = [ + "build_post_required_request", + "build_post_optional_request", + "build_post_reserved_words_request", + "build_post_multi_param_groups_request", + "build_post_shared_parameter_group_object_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/_request_builders.py new file mode 100644 index 00000000000..3dd731f2c5a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/_request_builders.py @@ -0,0 +1,281 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_post_required_request( + path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post a bunch of required parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param path: Path parameter. + :type path: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :paramtype content: any + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + custom_header = kwargs.pop('custom_header', None) # type: Optional[str] + query = kwargs.pop('query', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postRequired/{path}') + path_format_arguments = { + 'path': _SERIALIZER.url("path", path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters['query'] = _SERIALIZER.query("query", query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters['customHeader'] = _SERIALIZER.header("custom_header", custom_header, 'str') + if content_type is not None: + 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, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post a bunch of optional parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + """ + + custom_header = kwargs.pop('custom_header', None) # type: Optional[str] + query = kwargs.pop('query', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postOptional') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters['query'] = _SERIALIZER.query("query", query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters['customHeader'] = _SERIALIZER.header("custom_header", custom_header, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_reserved_words_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post a grouped parameters with reserved words. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword from_parameter: 'from' is a reserved word. Pass in 'bob' to pass. + :paramtype from_parameter: str + :keyword accept_parameter: 'accept' is a reserved word. Pass in 'yes' to pass. + :paramtype accept_parameter: str + :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 + """ + + from_parameter = kwargs.pop('from_parameter', None) # type: Optional[str] + accept_parameter = kwargs.pop('accept_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postReservedWords') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if from_parameter is not None: + query_parameters['from'] = _SERIALIZER.query("from_parameter", from_parameter, 'str') + if accept_parameter is not None: + query_parameters['accept'] = _SERIALIZER.query("accept_parameter", accept_parameter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_multi_param_groups_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post parameters from multiple different parameter groups. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :keyword header_two: + :paramtype header_two: str + :keyword query_two: Query parameter with default. + :paramtype query_two: int + :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 + """ + + header_one = kwargs.pop('header_one', None) # type: Optional[str] + query_one = kwargs.pop('query_one', 30) # type: Optional[int] + header_two = kwargs.pop('header_two', None) # type: Optional[str] + query_two = kwargs.pop('query_two', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/postMultipleParameterGroups') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters['query-one'] = _SERIALIZER.query("query_one", query_one, 'int') + if query_two is not None: + query_parameters['query-two'] = _SERIALIZER.query("query_two", query_two, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters['header-one'] = _SERIALIZER.header("header_one", header_one, 'str') + if header_two is not None: + header_parameters['header-two'] = _SERIALIZER.header("header_two", header_two, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_shared_parameter_group_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post parameters with a shared parameter group object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :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 + """ + + header_one = kwargs.pop('header_one', None) # type: Optional[str] + query_one = kwargs.pop('query_one', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/parameterGrouping/sharedParameterGroupObject') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters['query-one'] = _SERIALIZER.query("query_one", query_one, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters['header-one'] = _SERIALIZER.header("header_one", header_one, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/_request_builders_py3.py new file mode 100644 index 00000000000..1aea63c8a03 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/azureparametergroupinglowlevel/rest/parameter_grouping/_request_builders_py3.py @@ -0,0 +1,237 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_post_required_request( + path: str, + *, + json: Any = None, + content: Any = None, + custom_header: Optional[str] = None, + query: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """Post a bunch of required parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param path: Path parameter. + :type path: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :paramtype content: any + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postRequired/{path}") + path_format_arguments = { + "path": _SERIALIZER.url("path", path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters["query"] = _SERIALIZER.query("query", query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters["customHeader"] = _SERIALIZER.header("custom_header", custom_header, "str") + if content_type is not None: + 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, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_post_optional_request( + *, custom_header: Optional[str] = None, query: Optional[int] = 30, **kwargs: Any +) -> HttpRequest: + """Post a bunch of optional parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword custom_header: + :paramtype custom_header: str + :keyword query: Query parameter with default. + :paramtype query: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postOptional") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query is not None: + query_parameters["query"] = _SERIALIZER.query("query", query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if custom_header is not None: + header_parameters["customHeader"] = _SERIALIZER.header("custom_header", custom_header, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_reserved_words_request( + *, from_parameter: Optional[str] = None, accept_parameter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + """Post a grouped parameters with reserved words. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword from_parameter: 'from' is a reserved word. Pass in 'bob' to pass. + :paramtype from_parameter: str + :keyword accept_parameter: 'accept' is a reserved word. Pass in 'yes' to pass. + :paramtype accept_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postReservedWords") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if from_parameter is not None: + query_parameters["from"] = _SERIALIZER.query("from_parameter", from_parameter, "str") + if accept_parameter is not None: + query_parameters["accept"] = _SERIALIZER.query("accept_parameter", accept_parameter, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_multi_param_groups_request( + *, + header_one: Optional[str] = None, + query_one: Optional[int] = 30, + header_two: Optional[str] = None, + query_two: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """Post parameters from multiple different parameter groups. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :keyword header_two: + :paramtype header_two: str + :keyword query_two: Query parameter with default. + :paramtype query_two: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/postMultipleParameterGroups") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters["query-one"] = _SERIALIZER.query("query_one", query_one, "int") + if query_two is not None: + query_parameters["query-two"] = _SERIALIZER.query("query_two", query_two, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters["header-one"] = _SERIALIZER.header("header_one", header_one, "str") + if header_two is not None: + header_parameters["header-two"] = _SERIALIZER.header("header_two", header_two, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_shared_parameter_group_object_request( + *, header_one: Optional[str] = None, query_one: Optional[int] = 30, **kwargs: Any +) -> HttpRequest: + """Post parameters with a shared parameter group object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword header_one: + :paramtype header_one: str + :keyword query_one: Query parameter with default. + :paramtype query_one: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/parameterGrouping/sharedParameterGroupObject") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_one is not None: + query_parameters["query-one"] = _SERIALIZER.query("query_one", query_one, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_one is not None: + header_parameters["header-one"] = _SERIALIZER.header("header_one", header_one, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/setup.py new file mode 100644 index 00000000000..43fc9e7bdd6 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureParameterGroupingLowLevel/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 = "autorestparametergroupingtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterGroupingTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterGroupingTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/__init__.py new file mode 100644 index 00000000000..d0eb9ad6178 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/__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 ._auto_rest_report_service_for_azure import AutoRestReportServiceForAzure +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestReportServiceForAzure"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_auto_rest_report_service_for_azure.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_auto_rest_report_service_for_azure.py new file mode 100644 index 00000000000..58b61a341fe --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_auto_rest_report_service_for_azure.py @@ -0,0 +1,91 @@ +# 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 AutoRestReportServiceForAzureConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestReportServiceForAzure(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceForAzureConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `azurereportlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurereportlowlevel.rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestReportServiceForAzure + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_configuration.py new file mode 100644 index 00000000000..c358d080144 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_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 AutoRestReportServiceForAzureConfiguration(Configuration): + """Configuration for AutoRestReportServiceForAzure. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestReportServiceForAzureConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestreportserviceforazure/{}".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/Expected/AcceptanceTests/BodyArray/bodyarray/_version.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/__init__.py new file mode 100644 index 00000000000..0a3c42d5315 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/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 ._auto_rest_report_service_for_azure import AutoRestReportServiceForAzure + +__all__ = ["AutoRestReportServiceForAzure"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/_auto_rest_report_service_for_azure.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/_auto_rest_report_service_for_azure.py new file mode 100644 index 00000000000..eef34f720c1 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/_auto_rest_report_service_for_azure.py @@ -0,0 +1,77 @@ +# 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 AutoRestReportServiceForAzureConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestReportServiceForAzure: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceForAzureConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `azurereportlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurereportlowlevel.rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestReportServiceForAzure": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..0a75f8ad29c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/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 AutoRestReportServiceForAzureConfiguration(Configuration): + """Configuration for AutoRestReportServiceForAzure. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestReportServiceForAzureConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestreportserviceforazure/{}".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/Expected/AcceptanceTests/BodyArray/bodyarray/py.typed b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/__init__.py new file mode 100644 index 00000000000..47e8a3b88d4 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/__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_get_report_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_report_request # type: ignore + +__all__ = [ + "build_get_report_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..35d45a80bed --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/_request_builders.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 TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_report_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + qualifier = kwargs.pop('qualifier', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/report/azure') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters['qualifier'] = _SERIALIZER.query("qualifier", qualifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..827f6607cab --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/azurereportlowlevel/rest/_request_builders_py3.py @@ -0,0 +1,53 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_report_request(*, qualifier: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/report/azure") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters["qualifier"] = _SERIALIZER.query("qualifier", qualifier, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/setup.py new file mode 100644 index 00000000000..e36aa3e6023 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureReportLowLevel/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 = "autorestreportserviceforazure" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestReportServiceForAzure", + author_email="", + url="", + keywords=["Swagger", "AutoRestReportServiceForAzure"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/__init__.py new file mode 100644 index 00000000000..b6b0d5c8ebc --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/__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 ._auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestAzureSpecialParametersTestClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_auto_rest_azure_special_parameters_test_client.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_auto_rest_azure_special_parameters_test_client.py new file mode 100644 index 00000000000..a4dd114dfae --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_auto_rest_azure_special_parameters_test_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestAzureSpecialParametersTestClient(object): + """Test Infrastructure for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestAzureSpecialParametersTestClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `azurespecialpropertieslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurespecialpropertieslowlevel.rest import xms_client_request_id + >>> request = xms_client_request_id.build_get_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestAzureSpecialParametersTestClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_configuration.py new file mode 100644 index 00000000000..860d0af7044 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_configuration.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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class AutoRestAzureSpecialParametersTestClientConfiguration(Configuration): + """Configuration for AutoRestAzureSpecialParametersTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription id, which appears in the path, always modeled in credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(AutoRestAzureSpecialParametersTestClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2015-07-01-preview" + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestazurespecialparameterstestclient/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_version.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/__init__.py new file mode 100644 index 00000000000..3da877b5b32 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/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 ._auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient + +__all__ = ["AutoRestAzureSpecialParametersTestClient"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/_auto_rest_azure_special_parameters_test_client.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/_auto_rest_azure_special_parameters_test_client.py new file mode 100644 index 00000000000..6a693c1ced5 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/_auto_rest_azure_special_parameters_test_client.py @@ -0,0 +1,86 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestAzureSpecialParametersTestClient: + """Test Infrastructure for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestAzureSpecialParametersTestClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `azurespecialpropertieslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from azurespecialpropertieslowlevel.rest import xms_client_request_id + >>> request = xms_client_request_id.build_get_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestAzureSpecialParametersTestClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..7b150ed213b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/aio/_configuration.py @@ -0,0 +1,61 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestAzureSpecialParametersTestClientConfiguration(Configuration): + """Configuration for AutoRestAzureSpecialParametersTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription id, which appears in the path, always modeled in credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(AutoRestAzureSpecialParametersTestClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2015-07-01-preview" + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestazurespecialparameterstestclient/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/py.typed b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/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/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/__init__.py new file mode 100644 index 00000000000..2de384d5760 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/__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 ._request_builders_py3 import build_get_method_global_valid_request + from ._request_builders_py3 import build_get_method_global_not_provided_valid_request + from ._request_builders_py3 import build_get_path_global_valid_request + from ._request_builders_py3 import build_get_swagger_global_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_method_global_valid_request # type: ignore + from ._request_builders import build_get_method_global_not_provided_valid_request # type: ignore + from ._request_builders import build_get_path_global_valid_request # type: ignore + from ._request_builders import build_get_swagger_global_valid_request # type: ignore + +__all__ = [ + "build_get_method_global_valid_request", + "build_get_method_global_not_provided_valid_request", + "build_get_path_global_valid_request", + "build_get_swagger_global_valid_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/_request_builders.py new file mode 100644 index 00000000000..f51ea528558 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/_request_builders.py @@ -0,0 +1,167 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_method_global_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_global_not_provided_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_global_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_global_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/_request_builders_py3.py new file mode 100644 index 00000000000..6fe39943966 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_default/_request_builders_py3.py @@ -0,0 +1,128 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_method_global_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/method/string/none/query/global/2015-07-01-preview") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_method_global_not_provided_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview" + ) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_path_global_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/path/string/none/query/global/2015-07-01-preview") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_swagger_global_valid_request(**kwargs: Any) -> HttpRequest: + """GET method with api-version modeled in global settings. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/swagger/string/none/query/global/2015-07-01-preview") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/__init__.py new file mode 100644 index 00000000000..1b0edf68897 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/__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 ._request_builders_py3 import build_get_method_local_valid_request + from ._request_builders_py3 import build_get_method_local_null_request + from ._request_builders_py3 import build_get_path_local_valid_request + from ._request_builders_py3 import build_get_swagger_local_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_method_local_valid_request # type: ignore + from ._request_builders import build_get_method_local_null_request # type: ignore + from ._request_builders import build_get_path_local_valid_request # type: ignore + from ._request_builders import build_get_swagger_local_valid_request # type: ignore + +__all__ = [ + "build_get_method_local_valid_request", + "build_get_method_local_null_request", + "build_get_path_local_valid_request", + "build_get_swagger_local_valid_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/_request_builders.py new file mode 100644 index 00000000000..b981ec59e7d --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/_request_builders.py @@ -0,0 +1,172 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_method_local_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/local/2.0') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_local_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = null to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword api_version: This should appear as a method parameter, use value null, this should + result in no serialized parameter. + :paramtype api_version: str + :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 + """ + + api_version = kwargs.pop('api_version', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/method/string/none/query/local/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_local_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/path/string/none/query/local/2.0') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_local_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/apiVersion/swagger/string/none/query/local/2.0') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/_request_builders_py3.py new file mode 100644 index 00000000000..ebf8080d4db --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/api_version_local/_request_builders_py3.py @@ -0,0 +1,129 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_method_local_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/method/string/none/query/local/2.0") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_method_local_null_request(*, api_version: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = null to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword api_version: This should appear as a method parameter, use value null, this should + result in no serialized parameter. + :paramtype api_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/method/string/none/query/local/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if api_version is not None: + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_path_local_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/path/string/none/query/local/2.0") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_swagger_local_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + api_version = "2.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/apiVersion/swagger/string/none/query/local/2.0") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/__init__.py new file mode 100644 index 00000000000..9482c75db3a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/__init__.py @@ -0,0 +1,22 @@ +# 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_custom_named_request_id_request + from ._request_builders_py3 import build_custom_named_request_id_param_grouping_request + from ._request_builders_py3 import build_custom_named_request_id_head_request +except (SyntaxError, ImportError): + from ._request_builders import build_custom_named_request_id_request # type: ignore + from ._request_builders import build_custom_named_request_id_param_grouping_request # type: ignore + from ._request_builders import build_custom_named_request_id_head_request # type: ignore + +__all__ = [ + "build_custom_named_request_id_request", + "build_custom_named_request_id_param_grouping_request", + "build_custom_named_request_id_head_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/_request_builders.py new file mode 100644 index 00000000000..ad57d09b7f4 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/_request_builders.py @@ -0,0 +1,128 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_custom_named_request_id_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + foo_client_request_id = kwargs.pop('foo_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/customNamedRequestId') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['foo-client-request-id'] = _SERIALIZER.header("foo_client_request_id", foo_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_custom_named_request_id_param_grouping_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, + via a parameter group. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + foo_client_request_id = kwargs.pop('foo_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/customNamedRequestIdParamGrouping') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['foo-client-request-id'] = _SERIALIZER.header("foo_client_request_id", foo_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_custom_named_request_id_head_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + foo_client_request_id = kwargs.pop('foo_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/customNamedRequestIdHead') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['foo-client-request-id'] = _SERIALIZER.header("foo_client_request_id", foo_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/_request_builders_py3.py new file mode 100644 index 00000000000..ea3fc535173 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/header/_request_builders_py3.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. +# -------------------------------------------------------------------------- +from typing import Any, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_custom_named_request_id_request(*, foo_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/customNamedRequestId") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["foo-client-request-id"] = _SERIALIZER.header( + "foo_client_request_id", foo_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_custom_named_request_id_param_grouping_request(*, foo_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, + via a parameter group. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/customNamedRequestIdParamGrouping") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["foo-client-request-id"] = _SERIALIZER.header( + "foo_client_request_id", foo_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_custom_named_request_id_head_request(*, foo_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword foo_client_request_id: The fooRequestId. + :paramtype foo_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/customNamedRequestIdHead") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["foo-client-request-id"] = _SERIALIZER.header( + "foo_client_request_id", foo_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/__init__.py new file mode 100644 index 00000000000..ed7f4a99f12 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/__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_get_with_filter_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_with_filter_request # type: ignore + +__all__ = [ + "build_get_with_filter_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/_request_builders.py new file mode 100644 index 00000000000..4392bc79619 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/_request_builders.py @@ -0,0 +1,70 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_with_filter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. + :paramtype filter: str + :keyword top: The top parameter with value 10. + :paramtype top: int + :keyword orderby: The orderby parameter with value id. + :paramtype orderby: str + :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 + """ + + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + orderby = kwargs.pop('orderby', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/odata/filter') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/_request_builders_py3.py new file mode 100644 index 00000000000..835a087c198 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/odata/_request_builders_py3.py @@ -0,0 +1,54 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_with_filter_request( + *, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + """Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword filter: The filter parameter with value '$filter=id gt 5 and name eq 'foo''. + :paramtype filter: str + :keyword top: The top parameter with value 10. + :paramtype top: int + :keyword orderby: The orderby parameter with value id. + :paramtype orderby: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/odata/filter") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + query_parameters["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + query_parameters["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/__init__.py new file mode 100644 index 00000000000..75de623f002 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/__init__.py @@ -0,0 +1,34 @@ +# 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_get_method_path_valid_request + from ._request_builders_py3 import build_get_path_valid_request + from ._request_builders_py3 import build_get_swagger_path_valid_request + from ._request_builders_py3 import build_get_method_query_valid_request + from ._request_builders_py3 import build_get_method_query_null_request + from ._request_builders_py3 import build_get_path_query_valid_request + from ._request_builders_py3 import build_get_swagger_query_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_method_path_valid_request # type: ignore + from ._request_builders import build_get_path_valid_request # type: ignore + from ._request_builders import build_get_swagger_path_valid_request # type: ignore + from ._request_builders import build_get_method_query_valid_request # type: ignore + from ._request_builders import build_get_method_query_null_request # type: ignore + from ._request_builders import build_get_path_query_valid_request # type: ignore + from ._request_builders import build_get_swagger_query_valid_request # type: ignore + +__all__ = [ + "build_get_method_path_valid_request", + "build_get_path_valid_request", + "build_get_swagger_path_valid_request", + "build_get_method_query_valid_request", + "build_get_method_query_null_request", + "build_get_path_query_valid_request", + "build_get_swagger_query_valid_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/_request_builders.py new file mode 100644 index 00000000000..eba87460f68 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/_request_builders.py @@ -0,0 +1,289 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_method_path_valid_request( + unencoded_path_param, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}') + path_format_arguments = { + 'unencodedPathParam': _SERIALIZER.url("unencoded_path_param", unencoded_path_param, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_valid_request( + unencoded_path_param, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}') + path_format_arguments = { + 'unencodedPathParam': _SERIALIZER.url("unencoded_path_param", unencoded_path_param, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_path_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + unencoded_path_param = "path1/path2/path3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}') + path_format_arguments = { + 'unencodedPathParam': _SERIALIZER.url("unencoded_path_param", unencoded_path_param, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_query_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + q1 = kwargs.pop('q1') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/method/query/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_method_query_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword q1: Unencoded query parameter with value null. + :paramtype q1: str + :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 + """ + + q1 = kwargs.pop('q1', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/method/query/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if q1 is not None: + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_path_query_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + q1 = kwargs.pop('q1') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/path/query/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_swagger_query_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + q1 = "value1&q2=value2&q3=value3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/skipUrlEncoding/swagger/query/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['q1'] = _SERIALIZER.query("q1", q1, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/_request_builders_py3.py new file mode 100644 index 00000000000..303c84a55c4 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/skip_url_encoding/_request_builders_py3.py @@ -0,0 +1,216 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_method_path_valid_request(unencoded_path_param: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/method/path/valid/{unencodedPathParam}") + path_format_arguments = { + "unencodedPathParam": _SERIALIZER.url("unencoded_path_param", unencoded_path_param, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_path_valid_request(unencoded_path_param: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param unencoded_path_param: Unencoded path parameter with value 'path1/path2/path3'. + :type unencoded_path_param: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/path/path/valid/{unencodedPathParam}") + path_format_arguments = { + "unencodedPathParam": _SERIALIZER.url("unencoded_path_param", unencoded_path_param, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_swagger_path_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with unencoded path parameter with value 'path1/path2/path3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + unencoded_path_param = "path1/path2/path3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/swagger/path/valid/{unencodedPathParam}") + path_format_arguments = { + "unencodedPathParam": _SERIALIZER.url("unencoded_path_param", unencoded_path_param, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_method_query_valid_request(*, q1: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/method/query/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_method_query_null_request(*, q1: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword q1: Unencoded query parameter with value null. + :paramtype q1: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/method/query/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if q1 is not None: + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_path_query_valid_request(*, q1: str, **kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword q1: Unencoded query parameter with value 'value1&q2=value2&q3=value3'. + :paramtype q1: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/path/query/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_swagger_query_valid_request(**kwargs: Any) -> HttpRequest: + """Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + q1 = "value1&q2=value2&q3=value3" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/skipUrlEncoding/swagger/query/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["q1"] = _SERIALIZER.query("q1", q1, "str", skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/__init__.py new file mode 100644 index 00000000000..037aec6cb67 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/__init__.py @@ -0,0 +1,28 @@ +# 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_post_method_global_valid_request + from ._request_builders_py3 import build_post_method_global_null_request + from ._request_builders_py3 import build_post_method_global_not_provided_valid_request + from ._request_builders_py3 import build_post_path_global_valid_request + from ._request_builders_py3 import build_post_swagger_global_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_post_method_global_valid_request # type: ignore + from ._request_builders import build_post_method_global_null_request # type: ignore + from ._request_builders import build_post_method_global_not_provided_valid_request # type: ignore + from ._request_builders import build_post_path_global_valid_request # type: ignore + from ._request_builders import build_post_swagger_global_valid_request # type: ignore + +__all__ = [ + "build_post_method_global_valid_request", + "build_post_method_global_null_request", + "build_post_method_global_not_provided_valid_request", + "build_post_path_global_valid_request", + "build_post_swagger_global_valid_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/_request_builders.py new file mode 100644 index 00000000000..3f88c83412c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/_request_builders.py @@ -0,0 +1,225 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_post_method_global_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_method_global_null_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + null, and client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_method_global_not_provided_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_path_global_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_swagger_global_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/_request_builders_py3.py new file mode 100644 index 00000000000..9b67911e113 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_credentials/_request_builders_py3.py @@ -0,0 +1,188 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_post_method_global_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_method_global_null_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + null, and client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_method_global_not_provided_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + api_version = "2015-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_post_path_global_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_swagger_global_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscription id, which appears in the path, always modeled in + credentials. The value is always '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/__init__.py new file mode 100644 index 00000000000..f9e02296e01 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/__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 ._request_builders_py3 import build_post_method_local_valid_request + from ._request_builders_py3 import build_post_method_local_null_request + from ._request_builders_py3 import build_post_path_local_valid_request + from ._request_builders_py3 import build_post_swagger_local_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_post_method_local_valid_request # type: ignore + from ._request_builders import build_post_method_local_null_request # type: ignore + from ._request_builders import build_post_path_local_valid_request # type: ignore + from ._request_builders import build_post_swagger_local_valid_request # type: ignore + +__all__ = [ + "build_post_method_local_valid_request", + "build_post_method_local_null_request", + "build_post_path_local_valid_request", + "build_post_swagger_local_valid_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/_request_builders.py new file mode 100644 index 00000000000..478b604fb35 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/_request_builders.py @@ -0,0 +1,178 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_post_method_local_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: This should appear as a method parameter, use value + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_method_local_null_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = null, + client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: This should appear as a method parameter, use value null, client-side + validation should prvenet the call. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_path_local_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_swagger_local_valid_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscriptionId, which appears in the path, the value is always + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/_request_builders_py3.py new file mode 100644 index 00000000000..85e5c072c63 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/subscription_in_method/_request_builders_py3.py @@ -0,0 +1,147 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_post_method_local_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: This should appear as a method parameter, use value + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_method_local_null_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = null, + client-side validation should prevent you from making this call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: This should appear as a method parameter, use value null, client-side + validation should prvenet the call. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_path_local_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Should appear as a method parameter -use value '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_swagger_local_valid_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """POST method with subscriptionId modeled in the method. pass in subscription id = + '1234-5678-9012-3456' to succeed. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: The subscriptionId, which appears in the path, the value is always + '1234-5678-9012-3456'. + :type subscription_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/__init__.py new file mode 100644 index 00000000000..d91016b544c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/__init__.py @@ -0,0 +1,19 @@ +# 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_get_request + from ._request_builders_py3 import build_param_get_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_request # type: ignore + from ._request_builders import build_param_get_request # type: ignore + +__all__ = [ + "build_get_request", + "build_param_get_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/_request_builders.py new file mode 100644 index 00000000000..8dd2a55a5db --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/_request_builders.py @@ -0,0 +1,83 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/overwrite/x-ms-client-request-id/method/') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_param_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword x_ms_client_request_id: This should appear as a method parameter, use value + '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. + :paramtype x_ms_client_request_id: str + :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 + """ + + x_ms_client_request_id = kwargs.pop('x_ms_client_request_id') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azurespecials/overwrite/x-ms-client-request-id/via-param/method/') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("x_ms_client_request_id", x_ms_client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/_request_builders_py3.py new file mode 100644 index 00000000000..7338d848276 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/azurespecialpropertieslowlevel/rest/xms_client_request_id/_request_builders_py3.py @@ -0,0 +1,63 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/overwrite/x-ms-client-request-id/method/") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_param_get_request(*, x_ms_client_request_id: str, **kwargs: Any) -> HttpRequest: + """Get method that overwrites x-ms-client-request header with value + 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword x_ms_client_request_id: This should appear as a method parameter, use value + '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'. + :paramtype x_ms_client_request_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/azurespecials/overwrite/x-ms-client-request-id/via-param/method/") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["x-ms-client-request-id"] = _SERIALIZER.header( + "x_ms_client_request_id", x_ms_client_request_id, "str" + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/setup.py new file mode 100644 index 00000000000..90ff32230bf --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/AzureSpecialsLowLevel/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 = "autorestazurespecialparameterstestclient" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestAzureSpecialParametersTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestAzureSpecialParametersTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py rename to test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/__init__.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_auto_rest_parameterized_host_test_client.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..d00e1ca9266 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,93 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedHostTestClient(object): + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurllowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurllowlevel.rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedHostTestClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py rename to test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_version.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py rename to test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/__init__.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_auto_rest_parameterized_host_test_client.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..20af13c1141 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,79 @@ +# 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, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestParameterizedHostTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestParameterizedHostTestClient: + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurllowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurllowlevel.rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedHostTestClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py rename to test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/py.typed b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/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/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/__init__.py new file mode 100644 index 00000000000..5daa0aa077d --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/__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_get_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_request # type: ignore + +__all__ = [ + "build_get_empty_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders.py new file mode 100644 index 00000000000..89ec619690a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders.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.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/customuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..19b138bf21a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders_py3.py @@ -0,0 +1,36 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/customuri") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/setup.py new file mode 100644 index 00000000000..37d0593ce8f --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/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 = "autorestparameterizedhosttestclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/__init__.py new file mode 100644 index 00000000000..21225fcba5a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/__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 ._auto_rest_parameterized_host_test_paging_client import AutoRestParameterizedHostTestPagingClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestParameterizedHostTestPagingClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_auto_rest_parameterized_host_test_paging_client.py new file mode 100644 index 00000000000..44e913fa525 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_auto_rest_parameterized_host_test_paging_client.py @@ -0,0 +1,93 @@ +# 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 AutoRestParameterizedHostTestPagingClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedHostTestPagingClient(object): + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurlpaginglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlpaginglowlevel.rest import paging + >>> request = paging.build_get_pages_partial_url_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedHostTestPagingClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_configuration.py new file mode 100644 index 00000000000..b2d26e03b6b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_configuration.py @@ -0,0 +1,57 @@ +# 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 AutoRestParameterizedHostTestPagingClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedHostTestPagingClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AutoRestParameterizedHostTestPagingClientConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "autorestparameterizedhosttestpagingclient/{}".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/Expected/AcceptanceTests/BodyByte/bodybyte/_version.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/__init__.py new file mode 100644 index 00000000000..7c01a9e4d6a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/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 ._auto_rest_parameterized_host_test_paging_client import AutoRestParameterizedHostTestPagingClient + +__all__ = ["AutoRestParameterizedHostTestPagingClient"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/_auto_rest_parameterized_host_test_paging_client.py new file mode 100644 index 00000000000..d2a7dc28c09 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/_auto_rest_parameterized_host_test_paging_client.py @@ -0,0 +1,79 @@ +# 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, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestParameterizedHostTestPagingClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestParameterizedHostTestPagingClient: + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurlpaginglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlpaginglowlevel.rest import paging + >>> request = paging.build_get_pages_partial_url_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedHostTestPagingClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/_configuration.py new file mode 100644 index 00000000000..4edca66bda1 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/aio/_configuration.py @@ -0,0 +1,45 @@ +# 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 AutoRestParameterizedHostTestPagingClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedHostTestPagingClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AutoRestParameterizedHostTestPagingClientConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "autorestparameterizedhosttestpagingclient/{}".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/Expected/AcceptanceTests/BodyByte/bodybyte/py.typed b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/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/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/__init__.py new file mode 100644 index 00000000000..2bf67c01227 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/__init__.py @@ -0,0 +1,22 @@ +# 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_get_pages_partial_url_request + from ._request_builders_py3 import build_get_pages_partial_url_operation_request + from ._request_builders_py3 import build_get_pages_partial_url_operation_next_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_pages_partial_url_request # type: ignore + from ._request_builders import build_get_pages_partial_url_operation_request # type: ignore + from ._request_builders import build_get_pages_partial_url_operation_next_request # type: ignore + +__all__ = [ + "build_get_pages_partial_url_request", + "build_get_pages_partial_url_operation_request", + "build_get_pages_partial_url_operation_next_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/_request_builders.py new file mode 100644 index 00000000000..65d9106bec6 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/_request_builders.py @@ -0,0 +1,168 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_pages_partial_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that combines custom url, paging and partial URL and expect to concat after + host. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/customurl/partialnextlink') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_pages_partial_url_operation_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that combines custom url, paging and partial URL with next operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/customurl/partialnextlinkop') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_pages_partial_url_operation_next_request( + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that combines custom url, paging and partial URL. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param next_link: Next link for the list operation. + :type next_link: str + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/customurl/{nextLink}') + path_format_arguments = { + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/_request_builders_py3.py new file mode 100644 index 00000000000..c8fe1f66ae7 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/custombaseurlpaginglowlevel/rest/paging/_request_builders_py3.py @@ -0,0 +1,138 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_pages_partial_url_request(**kwargs: Any) -> HttpRequest: + """A paging operation that combines custom url, paging and partial URL and expect to concat after + host. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/customurl/partialnextlink") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_pages_partial_url_operation_request(**kwargs: Any) -> HttpRequest: + """A paging operation that combines custom url, paging and partial URL with next operation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/customurl/partialnextlinkop") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_pages_partial_url_operation_next_request(next_link: str, **kwargs: Any) -> HttpRequest: + """A paging operation that combines custom url, paging and partial URL. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param next_link: Next link for the list operation. + :type next_link: str + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/customurl/{nextLink}") + path_format_arguments = { + "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/setup.py new file mode 100644 index 00000000000..2c57ff3661d --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/CustomUrlPagingLowLevel/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 = "autorestparameterizedhosttestpagingclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedHostTestPagingClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedHostTestPagingClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/__init__.py new file mode 100644 index 00000000000..7ebd68b989a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/__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 ._auto_rest_head_exception_test_service import AutoRestHeadExceptionTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestHeadExceptionTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_auto_rest_head_exception_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_auto_rest_head_exception_test_service.py new file mode 100644 index 00000000000..fbea18880ea --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_auto_rest_head_exception_test_service.py @@ -0,0 +1,95 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadExceptionTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHeadExceptionTestService(object): + """Test Infrastructure for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadExceptionTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `headexceptionslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headexceptionslowlevel.rest import head_exception + >>> request = head_exception.build_head200_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHeadExceptionTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_configuration.py new file mode 100644 index 00000000000..b622c32fb98 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_configuration.py @@ -0,0 +1,65 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class AutoRestHeadExceptionTestServiceConfiguration(Configuration): + """Configuration for AutoRestHeadExceptionTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ + + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AutoRestHeadExceptionTestServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestheadexceptiontestservice/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_version.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/__init__.py new file mode 100644 index 00000000000..9702e479d95 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/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 ._auto_rest_head_exception_test_service import AutoRestHeadExceptionTestService + +__all__ = ["AutoRestHeadExceptionTestService"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/_auto_rest_head_exception_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/_auto_rest_head_exception_test_service.py new file mode 100644 index 00000000000..f4a7326e21a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/_auto_rest_head_exception_test_service.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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadExceptionTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestHeadExceptionTestService: + """Test Infrastructure for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadExceptionTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `headexceptionslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headexceptionslowlevel.rest import head_exception + >>> request = head_exception.build_head200_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHeadExceptionTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..8ab463507c3 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/aio/_configuration.py @@ -0,0 +1,55 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestHeadExceptionTestServiceConfiguration(Configuration): + """Configuration for AutoRestHeadExceptionTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AutoRestHeadExceptionTestServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestheadexceptiontestservice/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/py.typed b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/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/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/__init__.py new file mode 100644 index 00000000000..5581e44ff36 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_head204_request", + "build_head404_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/_request_builders.py new file mode 100644 index 00000000000..9b8382675b4 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/_request_builders.py @@ -0,0 +1,93 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/_request_builders_py3.py new file mode 100644 index 00000000000..98bc3cd55a0 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/headexceptionslowlevel/rest/head_exception/_request_builders_py3.py @@ -0,0 +1,67 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + return HttpRequest(method="HEAD", url=url, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/setup.py new file mode 100644 index 00000000000..3d86e1ce5fd --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadExceptionsLowLevel/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 = "autorestheadexceptiontestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHeadExceptionTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHeadExceptionTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/__init__.py new file mode 100644 index 00000000000..25782867850 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/__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 ._auto_rest_head_test_service import AutoRestHeadTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestHeadTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_auto_rest_head_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_auto_rest_head_test_service.py new file mode 100644 index 00000000000..2b742257fcd --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_auto_rest_head_test_service.py @@ -0,0 +1,95 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHeadTestService(object): + """Test Infrastructure for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `headlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headlowlevel.rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHeadTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_configuration.py new file mode 100644 index 00000000000..fb1a1508cbd --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_configuration.py @@ -0,0 +1,65 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class AutoRestHeadTestServiceConfiguration(Configuration): + """Configuration for AutoRestHeadTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ + + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestheadtestservice/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_version.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/__init__.py new file mode 100644 index 00000000000..d7aef967ba4 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/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 ._auto_rest_head_test_service import AutoRestHeadTestService + +__all__ = ["AutoRestHeadTestService"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/_auto_rest_head_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/_auto_rest_head_test_service.py new file mode 100644 index 00000000000..8feab596bac --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/_auto_rest_head_test_service.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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestHeadTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestHeadTestService: + """Test Infrastructure for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `headlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headlowlevel.rest import http_success + >>> request = http_success.build_head200_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHeadTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..c6a69e8483d --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/aio/_configuration.py @@ -0,0 +1,55 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestHeadTestServiceConfiguration(Configuration): + """Configuration for AutoRestHeadTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestheadtestservice/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/py.typed b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/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/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/__init__.py new file mode 100644 index 00000000000..5581e44ff36 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/__init__.py @@ -0,0 +1,22 @@ +# 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_head200_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_head204_request", + "build_head404_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/_request_builders.py new file mode 100644 index 00000000000..9b8382675b4 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/_request_builders.py @@ -0,0 +1,93 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + return HttpRequest( + method="HEAD", + url=url, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..98bc3cd55a0 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/headlowlevel/rest/http_success/_request_builders_py3.py @@ -0,0 +1,67 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + return HttpRequest(method="HEAD", url=url, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + return HttpRequest(method="HEAD", url=url, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/setup.py new file mode 100644 index 00000000000..ba5ee762717 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/HeadLowLevel/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 = "autorestheadtestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHeadTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHeadTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/__init__.py new file mode 100644 index 00000000000..7b71d7f0cf7 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/__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 ._auto_rest_long_running_operation_test_service import AutoRestLongRunningOperationTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestLongRunningOperationTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_auto_rest_long_running_operation_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_auto_rest_long_running_operation_test_service.py new file mode 100644 index 00000000000..d6781a4ec97 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_auto_rest_long_running_operation_test_service.py @@ -0,0 +1,95 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestLongRunningOperationTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestLongRunningOperationTestService(object): + """Long-running Operation for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestLongRunningOperationTestServiceConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `lrolowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lrolowlevel.rest import lros + >>> request = lros.build_put200_succeeded_request(json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestLongRunningOperationTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_configuration.py new file mode 100644 index 00000000000..74854b8e42a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_configuration.py @@ -0,0 +1,65 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class AutoRestLongRunningOperationTestServiceConfiguration(Configuration): + """Configuration for AutoRestLongRunningOperationTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ + + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AutoRestLongRunningOperationTestServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestlongrunningoperationtestservice/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_version.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/__init__.py new file mode 100644 index 00000000000..3b0f24c5be6 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/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 ._auto_rest_long_running_operation_test_service import AutoRestLongRunningOperationTestService + +__all__ = ["AutoRestLongRunningOperationTestService"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/_auto_rest_long_running_operation_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/_auto_rest_long_running_operation_test_service.py new file mode 100644 index 00000000000..56863d7d6a9 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/_auto_rest_long_running_operation_test_service.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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestLongRunningOperationTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestLongRunningOperationTestService: + """Long-running Operation for AutoRest. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestLongRunningOperationTestServiceConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `lrolowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lrolowlevel.rest import lros + >>> request = lros.build_put200_succeeded_request(json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestLongRunningOperationTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/_configuration.py new file mode 100644 index 00000000000..d1a7958a1de --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/aio/_configuration.py @@ -0,0 +1,55 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutoRestLongRunningOperationTestServiceConfiguration(Configuration): + """Configuration for AutoRestLongRunningOperationTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AutoRestLongRunningOperationTestServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "autorestlongrunningoperationtestservice/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/py.typed b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/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/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/__init__.py new file mode 100644 index 00000000000..b9d80b78ba2 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/__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 ._request_builders_py3 import build_put_async_retry_succeeded_request + from ._request_builders_py3 import build_put201_creating_succeeded200_request + from ._request_builders_py3 import build_post202_retry200_request + from ._request_builders_py3 import build_post_async_retry_succeeded_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_async_retry_succeeded_request # type: ignore + from ._request_builders import build_put201_creating_succeeded200_request # type: ignore + from ._request_builders import build_post202_retry200_request # type: ignore + from ._request_builders import build_post_async_retry_succeeded_request # type: ignore + +__all__ = [ + "build_put_async_retry_succeeded_request", + "build_put201_creating_succeeded200_request", + "build_post202_retry200_request", + "build_post_async_retry_succeeded_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/_request_builders.py new file mode 100644 index 00000000000..936d347507e --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/_request_builders.py @@ -0,0 +1,253 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_async_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/putasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_creating_succeeded200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/put/201/creating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/post/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/customheader/postasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/_request_builders_py3.py new file mode 100644 index 00000000000..3888af2455c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lr_os_custom_header/_request_builders_py3.py @@ -0,0 +1,216 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_async_retry_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/putasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_creating_succeeded200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running put request, service returns a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/put/201/creating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_retry200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/post/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_retry_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for + all requests. Long running post request, service returns a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/customheader/postasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/__init__.py new file mode 100644 index 00000000000..5adea5a6e47 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/__init__.py @@ -0,0 +1,34 @@ +# 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_put201_creating_succeeded200_request + from ._request_builders_py3 import build_put_async_relative_retry_succeeded_request + from ._request_builders_py3 import build_delete_provisioning202_accepted200_succeeded_request + from ._request_builders_py3 import build_delete202_retry200_request + from ._request_builders_py3 import build_delete_async_relative_retry_succeeded_request + from ._request_builders_py3 import build_post202_retry200_request + from ._request_builders_py3 import build_post_async_relative_retry_succeeded_request +except (SyntaxError, ImportError): + from ._request_builders import build_put201_creating_succeeded200_request # type: ignore + from ._request_builders import build_put_async_relative_retry_succeeded_request # type: ignore + from ._request_builders import build_delete_provisioning202_accepted200_succeeded_request # type: ignore + from ._request_builders import build_delete202_retry200_request # type: ignore + from ._request_builders import build_delete_async_relative_retry_succeeded_request # type: ignore + from ._request_builders import build_post202_retry200_request # type: ignore + from ._request_builders import build_post_async_relative_retry_succeeded_request # type: ignore + +__all__ = [ + "build_put201_creating_succeeded200_request", + "build_put_async_relative_retry_succeeded_request", + "build_delete_provisioning202_accepted200_succeeded_request", + "build_delete202_retry200_request", + "build_delete_async_relative_retry_succeeded_request", + "build_post202_retry200_request", + "build_post_async_relative_retry_succeeded_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/_request_builders.py new file mode 100644 index 00000000000..6925449d355 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/_request_builders.py @@ -0,0 +1,357 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put201_creating_succeeded200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 500, then a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/put/201/creating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 500, then a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/putasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_accepted200_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/delete/provisioning/202/accepted/200/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_retry200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 500, then a 202 to the initial request. Polls + return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/delete/202/retry/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/deleteasync/retry/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 500, then a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/post/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/retryerror/postasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/_request_builders_py3.py new file mode 100644 index 00000000000..eb2f6800199 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lro_retrys/_request_builders_py3.py @@ -0,0 +1,300 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put201_creating_succeeded200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 500, then a 201 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/put/201/creating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_succeeded_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 500, then a 200 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/putasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete_provisioning202_accepted200_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll + returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/delete/provisioning/202/accepted/200/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_retry200_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 500, then a 202 to the initial request. Polls + return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/delete/202/retry/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/deleteasync/retry/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post202_retry200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 500, then a 202 to the initial request, with + 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/post/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_succeeded_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 500, then a 202 to the initial request, with an + entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the + Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/retryerror/postasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/__init__.py new file mode 100644 index 00000000000..29604c2bf27 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/__init__.py @@ -0,0 +1,136 @@ +# 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_put200_succeeded_request + from ._request_builders_py3 import build_put201_succeeded_request + from ._request_builders_py3 import build_post202_list_request + from ._request_builders_py3 import build_put200_succeeded_no_state_request + from ._request_builders_py3 import build_put202_retry200_request + from ._request_builders_py3 import build_put201_creating_succeeded200_request + from ._request_builders_py3 import build_put200_updating_succeeded204_request + from ._request_builders_py3 import build_put201_creating_failed200_request + from ._request_builders_py3 import build_put200_acceptedcanceled200_request + from ._request_builders_py3 import build_put_no_header_in_retry_request + from ._request_builders_py3 import build_put_async_retry_succeeded_request + from ._request_builders_py3 import build_put_async_no_retry_succeeded_request + from ._request_builders_py3 import build_put_async_retry_failed_request + from ._request_builders_py3 import build_put_async_no_retrycanceled_request + from ._request_builders_py3 import build_put_async_no_header_in_retry_request + from ._request_builders_py3 import build_put_non_resource_request + from ._request_builders_py3 import build_put_async_non_resource_request + from ._request_builders_py3 import build_put_sub_resource_request + from ._request_builders_py3 import build_put_async_sub_resource_request + from ._request_builders_py3 import build_delete_provisioning202_accepted200_succeeded_request + from ._request_builders_py3 import build_delete_provisioning202_deleting_failed200_request + from ._request_builders_py3 import build_delete_provisioning202_deletingcanceled200_request + from ._request_builders_py3 import build_delete204_succeeded_request + from ._request_builders_py3 import build_delete202_retry200_request + from ._request_builders_py3 import build_delete202_no_retry204_request + from ._request_builders_py3 import build_delete_no_header_in_retry_request + from ._request_builders_py3 import build_delete_async_no_header_in_retry_request + from ._request_builders_py3 import build_delete_async_retry_succeeded_request + from ._request_builders_py3 import build_delete_async_no_retry_succeeded_request + from ._request_builders_py3 import build_delete_async_retry_failed_request + from ._request_builders_py3 import build_delete_async_retrycanceled_request + from ._request_builders_py3 import build_post200_with_payload_request + from ._request_builders_py3 import build_post202_retry200_request + from ._request_builders_py3 import build_post202_no_retry204_request + from ._request_builders_py3 import build_post_double_headers_final_location_get_request + from ._request_builders_py3 import build_post_double_headers_final_azure_header_get_request + from ._request_builders_py3 import build_post_double_headers_final_azure_header_get_default_request + from ._request_builders_py3 import build_post_async_retry_succeeded_request + from ._request_builders_py3 import build_post_async_no_retry_succeeded_request + from ._request_builders_py3 import build_post_async_retry_failed_request + from ._request_builders_py3 import build_post_async_retrycanceled_request +except (SyntaxError, ImportError): + from ._request_builders import build_put200_succeeded_request # type: ignore + from ._request_builders import build_put201_succeeded_request # type: ignore + from ._request_builders import build_post202_list_request # type: ignore + from ._request_builders import build_put200_succeeded_no_state_request # type: ignore + from ._request_builders import build_put202_retry200_request # type: ignore + from ._request_builders import build_put201_creating_succeeded200_request # type: ignore + from ._request_builders import build_put200_updating_succeeded204_request # type: ignore + from ._request_builders import build_put201_creating_failed200_request # type: ignore + from ._request_builders import build_put200_acceptedcanceled200_request # type: ignore + from ._request_builders import build_put_no_header_in_retry_request # type: ignore + from ._request_builders import build_put_async_retry_succeeded_request # type: ignore + from ._request_builders import build_put_async_no_retry_succeeded_request # type: ignore + from ._request_builders import build_put_async_retry_failed_request # type: ignore + from ._request_builders import build_put_async_no_retrycanceled_request # type: ignore + from ._request_builders import build_put_async_no_header_in_retry_request # type: ignore + from ._request_builders import build_put_non_resource_request # type: ignore + from ._request_builders import build_put_async_non_resource_request # type: ignore + from ._request_builders import build_put_sub_resource_request # type: ignore + from ._request_builders import build_put_async_sub_resource_request # type: ignore + from ._request_builders import build_delete_provisioning202_accepted200_succeeded_request # type: ignore + from ._request_builders import build_delete_provisioning202_deleting_failed200_request # type: ignore + from ._request_builders import build_delete_provisioning202_deletingcanceled200_request # type: ignore + from ._request_builders import build_delete204_succeeded_request # type: ignore + from ._request_builders import build_delete202_retry200_request # type: ignore + from ._request_builders import build_delete202_no_retry204_request # type: ignore + from ._request_builders import build_delete_no_header_in_retry_request # type: ignore + from ._request_builders import build_delete_async_no_header_in_retry_request # type: ignore + from ._request_builders import build_delete_async_retry_succeeded_request # type: ignore + from ._request_builders import build_delete_async_no_retry_succeeded_request # type: ignore + from ._request_builders import build_delete_async_retry_failed_request # type: ignore + from ._request_builders import build_delete_async_retrycanceled_request # type: ignore + from ._request_builders import build_post200_with_payload_request # type: ignore + from ._request_builders import build_post202_retry200_request # type: ignore + from ._request_builders import build_post202_no_retry204_request # type: ignore + from ._request_builders import build_post_double_headers_final_location_get_request # type: ignore + from ._request_builders import build_post_double_headers_final_azure_header_get_request # type: ignore + from ._request_builders import build_post_double_headers_final_azure_header_get_default_request # type: ignore + from ._request_builders import build_post_async_retry_succeeded_request # type: ignore + from ._request_builders import build_post_async_no_retry_succeeded_request # type: ignore + from ._request_builders import build_post_async_retry_failed_request # type: ignore + from ._request_builders import build_post_async_retrycanceled_request # type: ignore + +__all__ = [ + "build_put200_succeeded_request", + "build_put201_succeeded_request", + "build_post202_list_request", + "build_put200_succeeded_no_state_request", + "build_put202_retry200_request", + "build_put201_creating_succeeded200_request", + "build_put200_updating_succeeded204_request", + "build_put201_creating_failed200_request", + "build_put200_acceptedcanceled200_request", + "build_put_no_header_in_retry_request", + "build_put_async_retry_succeeded_request", + "build_put_async_no_retry_succeeded_request", + "build_put_async_retry_failed_request", + "build_put_async_no_retrycanceled_request", + "build_put_async_no_header_in_retry_request", + "build_put_non_resource_request", + "build_put_async_non_resource_request", + "build_put_sub_resource_request", + "build_put_async_sub_resource_request", + "build_delete_provisioning202_accepted200_succeeded_request", + "build_delete_provisioning202_deleting_failed200_request", + "build_delete_provisioning202_deletingcanceled200_request", + "build_delete204_succeeded_request", + "build_delete202_retry200_request", + "build_delete202_no_retry204_request", + "build_delete_no_header_in_retry_request", + "build_delete_async_no_header_in_retry_request", + "build_delete_async_retry_succeeded_request", + "build_delete_async_no_retry_succeeded_request", + "build_delete_async_retry_failed_request", + "build_delete_async_retrycanceled_request", + "build_post200_with_payload_request", + "build_post202_retry200_request", + "build_post202_no_retry204_request", + "build_post_double_headers_final_location_get_request", + "build_post_double_headers_final_azure_header_get_request", + "build_post_double_headers_final_azure_header_get_default_request", + "build_post_async_retry_succeeded_request", + "build_post_async_no_retry_succeeded_request", + "build_post_async_retry_failed_request", + "build_post_async_retrycanceled_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/_request_builders.py new file mode 100644 index 00000000000..0ceed4b2e58 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/_request_builders.py @@ -0,0 +1,2119 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put200_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/201/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 with empty body to first request, returns a 200 + with body [{ 'id': '100', 'name': 'foo' }]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_succeeded_no_state_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + does not contain ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/succeeded/nostate') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put202_retry200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 to the initial request, with a location header + that points to a polling URL that returns a 200 and an entity that doesn't contains + ProvisioningState. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_creating_succeeded200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/201/creating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_updating_succeeded204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/updating/succeeded/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_creating_failed200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Created’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/201/created/failed/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_acceptedcanceled200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/200/accepted/canceled/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_no_header_in_retry_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 to the initial request with location header. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/put/noheader/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_no_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/noretry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_retry_failed_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/retry/failed') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_no_retrycanceled_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/noretry/canceled') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_no_header_in_retry_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 202 to the initial request with + Azure-AsyncOperation header. Subsequent calls to operation status do not contain + Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putasync/noheader/201/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_resource_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). sku to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "str (optional)", + "name": "str (optional)" + } + + # response body for status code(s): 202 + response.json() == { + "id": "str (optional)", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putnonresource/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_non_resource_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sku to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "str (optional)", + "name": "str (optional)" + } + + # response body for status code(s): 202 + response.json() == { + "id": "str (optional)", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putnonresourceasync/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_sub_resource_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putsubresource/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_sub_resource_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/putsubresourceasync/202/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_accepted200_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/provisioning/202/accepted/200/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_deleting_failed200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/provisioning/202/deleting/200/failed') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_provisioning202_deletingcanceled200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/provisioning/202/deleting/200/canceled') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete204_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete succeeds and returns right away. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/204/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_retry200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/202/retry/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_no_retry204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/202/noretry/204') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_no_header_in_retry_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a location header in the initial request. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/delete/noheader') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_no_header_in_retry_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns an Azure-AsyncOperation header in the initial + request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/noheader/202/204') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/retry/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_no_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/noretry/succeeded') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_retry_failed_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/retry/failed') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_retrycanceled_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/deleteasync/retry/canceled') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post200_with_payload_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with 'Location' + header. Poll returns a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "id": "str (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/post/payload/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with 'Location' and + 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/post/202/retry/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_no_retry204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with 'Location' + header, 204 with noresponse body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/post/202/noretry/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_double_headers_final_location_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final + object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/LROPostDoubleHeadersFinalLocationGet') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_double_headers_final_azure_header_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/LROPostDoubleHeadersFinalAzureHeaderGet') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_double_headers_final_azure_header_get_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object if you support initial Autorest behavior. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/retry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_no_retry_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/noretry/succeeded') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retry_failed_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/retry/failed') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_retrycanceled_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/postasync/retry/canceled') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/_request_builders_py3.py new file mode 100644 index 00000000000..3326be019fa --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lros/_request_builders_py3.py @@ -0,0 +1,1786 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put200_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/201/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_list_request(**kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 202 with empty body to first request, returns a 200 + with body [{ 'id': '100', 'name': 'foo' }]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_put200_succeeded_no_state_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + does not contain ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/succeeded/nostate") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put202_retry200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 202 to the initial request, with a location header + that points to a polling URL that returns a 200 and an entity that doesn't contains + ProvisioningState. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_creating_succeeded200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/201/creating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put200_updating_succeeded204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/updating/succeeded/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_creating_failed200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Created’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/201/created/failed/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put200_acceptedcanceled200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/200/accepted/canceled/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_no_header_in_retry_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 202 to the initial request with location header. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/put/noheader/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_retry_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_no_retry_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/noretry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_retry_failed_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/retry/failed") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_no_retrycanceled_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/noretry/canceled") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_no_header_in_retry_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 202 to the initial request with + Azure-AsyncOperation header. Subsequent calls to operation status do not contain + Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putasync/noheader/201/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_non_resource_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). sku to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "str (optional)", + "name": "str (optional)" + } + + # response body for status code(s): 202 + response.json() == { + "id": "str (optional)", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putnonresource/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_non_resource_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request with non resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sku to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sku to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "str (optional)", + "name": "str (optional)" + } + + # response body for status code(s): 202 + response.json() == { + "id": "str (optional)", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putnonresourceasync/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_sub_resource_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putsubresource/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_sub_resource_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request with sub resource. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Sub Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Sub Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/putsubresourceasync/202/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete_provisioning202_accepted200_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/provisioning/202/accepted/200/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_provisioning202_deleting_failed200_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Failed’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/provisioning/202/deleting/200/failed") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_provisioning202_deletingcanceled200_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a + ‘200’ with ProvisioningState=’Canceled’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/provisioning/202/deleting/200/canceled") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete204_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete succeeds and returns right away. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/204/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_retry200_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/202/retry/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_no_retry204_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Polls return this + value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/202/noretry/204") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_no_header_in_retry_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a location header in the initial request. + Subsequent calls to operation status do not contain location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/delete/noheader") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_no_header_in_retry_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns an Azure-AsyncOperation header in the initial + request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/noheader/202/204") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_retry_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/retry/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_no_retry_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/noretry/succeeded") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_retry_failed_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/retry/failed") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_retrycanceled_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/deleteasync/retry/canceled") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post200_with_payload_request(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with 'Location' + header. Poll returns a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200, 202 + response.json() == { + "id": "str (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/post/payload/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post202_retry200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with 'Location' and + 'Retry-After' headers, Polls return a 200 with a response body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/post/202/retry/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_no_retry204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with 'Location' + header, 204 with noresponse body after success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/post/202/noretry/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_double_headers_final_location_get_request(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final + object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/LROPostDoubleHeadersFinalLocationGet") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_double_headers_final_azure_header_get_request(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/LROPostDoubleHeadersFinalAzureHeaderGet") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_double_headers_final_azure_header_get_default_request(**kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request with both Location and + Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the + final object if you support initial Autorest behavior. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 202 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_async_retry_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/retry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_no_retry_succeeded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/noretry/succeeded") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_retry_failed_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/retry/failed") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_retrycanceled_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/postasync/retry/canceled") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/__init__.py new file mode 100644 index 00000000000..37765c4463f --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/__init__.py @@ -0,0 +1,91 @@ +# 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_put_non_retry400_request + from ._request_builders_py3 import build_put_non_retry201_creating400_request + from ._request_builders_py3 import build_put_non_retry201_creating400_invalid_json_request + from ._request_builders_py3 import build_put_async_relative_retry400_request + from ._request_builders_py3 import build_delete_non_retry400_request + from ._request_builders_py3 import build_delete202_non_retry400_request + from ._request_builders_py3 import build_delete_async_relative_retry400_request + from ._request_builders_py3 import build_post_non_retry400_request + from ._request_builders_py3 import build_post202_non_retry400_request + from ._request_builders_py3 import build_post_async_relative_retry400_request + from ._request_builders_py3 import build_put_error201_no_provisioning_state_payload_request + from ._request_builders_py3 import build_put_async_relative_retry_no_status_request + from ._request_builders_py3 import build_put_async_relative_retry_no_status_payload_request + from ._request_builders_py3 import build_delete204_succeeded_request + from ._request_builders_py3 import build_delete_async_relative_retry_no_status_request + from ._request_builders_py3 import build_post202_no_location_request + from ._request_builders_py3 import build_post_async_relative_retry_no_payload_request + from ._request_builders_py3 import build_put200_invalid_json_request + from ._request_builders_py3 import build_put_async_relative_retry_invalid_header_request + from ._request_builders_py3 import build_put_async_relative_retry_invalid_json_polling_request + from ._request_builders_py3 import build_delete202_retry_invalid_header_request + from ._request_builders_py3 import build_delete_async_relative_retry_invalid_header_request + from ._request_builders_py3 import build_delete_async_relative_retry_invalid_json_polling_request + from ._request_builders_py3 import build_post202_retry_invalid_header_request + from ._request_builders_py3 import build_post_async_relative_retry_invalid_header_request + from ._request_builders_py3 import build_post_async_relative_retry_invalid_json_polling_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_non_retry400_request # type: ignore + from ._request_builders import build_put_non_retry201_creating400_request # type: ignore + from ._request_builders import build_put_non_retry201_creating400_invalid_json_request # type: ignore + from ._request_builders import build_put_async_relative_retry400_request # type: ignore + from ._request_builders import build_delete_non_retry400_request # type: ignore + from ._request_builders import build_delete202_non_retry400_request # type: ignore + from ._request_builders import build_delete_async_relative_retry400_request # type: ignore + from ._request_builders import build_post_non_retry400_request # type: ignore + from ._request_builders import build_post202_non_retry400_request # type: ignore + from ._request_builders import build_post_async_relative_retry400_request # type: ignore + from ._request_builders import build_put_error201_no_provisioning_state_payload_request # type: ignore + from ._request_builders import build_put_async_relative_retry_no_status_request # type: ignore + from ._request_builders import build_put_async_relative_retry_no_status_payload_request # type: ignore + from ._request_builders import build_delete204_succeeded_request # type: ignore + from ._request_builders import build_delete_async_relative_retry_no_status_request # type: ignore + from ._request_builders import build_post202_no_location_request # type: ignore + from ._request_builders import build_post_async_relative_retry_no_payload_request # type: ignore + from ._request_builders import build_put200_invalid_json_request # type: ignore + from ._request_builders import build_put_async_relative_retry_invalid_header_request # type: ignore + from ._request_builders import build_put_async_relative_retry_invalid_json_polling_request # type: ignore + from ._request_builders import build_delete202_retry_invalid_header_request # type: ignore + from ._request_builders import build_delete_async_relative_retry_invalid_header_request # type: ignore + from ._request_builders import build_delete_async_relative_retry_invalid_json_polling_request # type: ignore + from ._request_builders import build_post202_retry_invalid_header_request # type: ignore + from ._request_builders import build_post_async_relative_retry_invalid_header_request # type: ignore + from ._request_builders import build_post_async_relative_retry_invalid_json_polling_request # type: ignore + +__all__ = [ + "build_put_non_retry400_request", + "build_put_non_retry201_creating400_request", + "build_put_non_retry201_creating400_invalid_json_request", + "build_put_async_relative_retry400_request", + "build_delete_non_retry400_request", + "build_delete202_non_retry400_request", + "build_delete_async_relative_retry400_request", + "build_post_non_retry400_request", + "build_post202_non_retry400_request", + "build_post_async_relative_retry400_request", + "build_put_error201_no_provisioning_state_payload_request", + "build_put_async_relative_retry_no_status_request", + "build_put_async_relative_retry_no_status_payload_request", + "build_delete204_succeeded_request", + "build_delete_async_relative_retry_no_status_request", + "build_post202_no_location_request", + "build_post_async_relative_retry_no_payload_request", + "build_put200_invalid_json_request", + "build_put_async_relative_retry_invalid_header_request", + "build_put_async_relative_retry_invalid_json_polling_request", + "build_delete202_retry_invalid_header_request", + "build_delete_async_relative_retry_invalid_header_request", + "build_delete_async_relative_retry_invalid_json_polling_request", + "build_post202_retry_invalid_header_request", + "build_post_async_relative_retry_invalid_header_request", + "build_post_async_relative_retry_invalid_json_polling_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/_request_builders.py new file mode 100644 index 00000000000..2a8360b220c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/_request_builders.py @@ -0,0 +1,1308 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_non_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 400 to the initial request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/put/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_retry201_creating400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/put/201/creating/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_retry201_creating400_invalid_json_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/put/201/creating/400/invalidjson') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/putasync/retry/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_non_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 400 with an error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/delete/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_non_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/delete/202/retry/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/deleteasync/retry/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_non_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 400 with no error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/post/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_non_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/post/202/retry/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/nonretryerror/postasync/retry/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_error201_no_provisioning_state_payload_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 201 to the initial request with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/put/201/noprovisioningstatepayload') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_no_status_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/nostatus') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_no_status_payload_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/nostatuspayload') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete204_succeeded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 204 to the initial request, indicating success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/delete/204/nolocation') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_no_status_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/deleteasync/retry/nostatus') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_no_location_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, without a location + header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/post/202/nolocation') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_no_payload_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/postasync/retry/nopayload') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_invalid_json_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that is + not a valid json. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/put/200/invalidjson') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_invalid_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/invalidheader') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_async_relative_retry_invalid_json_polling_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/putasync/retry/invalidjsonpolling') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_retry_invalid_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request receing a reponse + with an invalid 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/delete/202/retry/invalidheader') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_invalid_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. The endpoint + indicated in the Azure-AsyncOperation header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/deleteasync/retry/invalidheader') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete_async_relative_retry_invalid_json_polling_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/deleteasync/retry/invalidjsonpolling') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_retry_invalid_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with invalid + 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/post/202/retry/invalidheader') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_invalid_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/postasync/retry/invalidheader') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_async_relative_retry_invalid_json_polling_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lro/error/postasync/retry/invalidjsonpolling') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/_request_builders_py3.py new file mode 100644 index 00000000000..93bac8773ea --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/lrolowlevel/rest/lrosads/_request_builders_py3.py @@ -0,0 +1,1113 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_non_retry400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 400 to the initial request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/put/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_non_retry201_creating400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/put/201/creating/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_non_retry201_creating400_invalid_json_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and + 201 response code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/put/201/creating/400/invalidjson") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the + endpoint indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/putasync/retry/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete_non_retry400_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 400 with an error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/delete/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete202_non_retry400_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/delete/202/retry/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry400_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/deleteasync/retry/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post_non_retry400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 400 with no error body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/post/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_non_retry400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 with a location header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/post/202/retry/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/nonretryerror/postasync/retry/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_error201_no_provisioning_state_payload_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 201 to the initial request with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/put/201/noprovisioningstatepayload") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_no_status_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/nostatus") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_no_status_payload_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/nostatuspayload") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete204_succeeded_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 204 to the initial request, indicating success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/delete/204/nolocation") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_no_status_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/deleteasync/retry/nostatus") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post202_no_location_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, without a location + header. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/post/202/nolocation") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_no_payload_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/postasync/retry/nopayload") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put200_invalid_json_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that is + not a valid json. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/put/200/invalidjson") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_invalid_header_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/invalidheader") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_async_relative_retry_invalid_json_polling_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running put request, service returns a 200 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/putasync/retry/invalidjsonpolling") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete202_retry_invalid_header_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request receing a reponse + with an invalid 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/delete/202/retry/invalidheader") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_invalid_header_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. The endpoint + indicated in the Azure-AsyncOperation header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/deleteasync/retry/invalidheader") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_delete_async_relative_retry_invalid_json_polling_request(**kwargs: Any) -> HttpRequest: + """Long running delete request, service returns a 202 to the initial request. Poll the endpoint + indicated in the Azure-AsyncOperation header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/deleteasync/retry/invalidjsonpolling") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, **kwargs) + + +def build_post202_retry_invalid_header_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with invalid + 'Location' and 'Retry-After' headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/post/202/retry/invalidheader") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_invalid_header_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation + header is invalid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/postasync/retry/invalidheader") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_async_relative_retry_invalid_json_polling_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Long running post request, service returns a 202 to the initial request, with an entity that + contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation + header for operation status. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lro/error/postasync/retry/invalidjsonpolling") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/setup.py new file mode 100644 index 00000000000..caf94faf8e9 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroLowLevel/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 = "autorestlongrunningoperationtestservice" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestLongRunningOperationTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestLongRunningOperationTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Long-running Operation for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/__init__.py new file mode 100644 index 00000000000..e5ca82fe3ed --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/__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 ._lro_with_paramaterized_endpoints import LROWithParamaterizedEndpoints +from ._version import VERSION + +__version__ = VERSION +__all__ = ["LROWithParamaterizedEndpoints"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_configuration.py new file mode 100644 index 00000000000..5ee7789467b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_configuration.py @@ -0,0 +1,57 @@ +# 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 LROWithParamaterizedEndpointsConfiguration(Configuration): + """Configuration for LROWithParamaterizedEndpoints. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(LROWithParamaterizedEndpointsConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "lrowithparamaterizedendpoints/{}".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/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_lro_with_paramaterized_endpoints.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_lro_with_paramaterized_endpoints.py new file mode 100644 index 00000000000..de84f824516 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_lro_with_paramaterized_endpoints.py @@ -0,0 +1,94 @@ +# 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 LROWithParamaterizedEndpointsConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict + + from azure.core.rest import HttpRequest, HttpResponse + + +class LROWithParamaterizedEndpoints(object): + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. Pass in + 'host:3000' to pass test. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = LROWithParamaterizedEndpointsConfiguration(host, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `lrowithparameterizedendpointslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lrowithparameterizedendpointslowlevel.rest import build_poll_with_parameterized_endpoints_request + >>> request = build_poll_with_parameterized_endpoints_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> LROWithParamaterizedEndpoints + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_version.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/__init__.py new file mode 100644 index 00000000000..ac1e3809886 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/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 ._lro_with_paramaterized_endpoints import LROWithParamaterizedEndpoints + +__all__ = ["LROWithParamaterizedEndpoints"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..df3fe0799ce --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/_configuration.py @@ -0,0 +1,45 @@ +# 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 LROWithParamaterizedEndpointsConfiguration(Configuration): + """Configuration for LROWithParamaterizedEndpoints. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(LROWithParamaterizedEndpointsConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "lrowithparamaterizedendpoints/{}".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/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/_lro_with_paramaterized_endpoints.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/_lro_with_paramaterized_endpoints.py new file mode 100644 index 00000000000..94b0ab55102 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/aio/_lro_with_paramaterized_endpoints.py @@ -0,0 +1,80 @@ +# 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, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import LROWithParamaterizedEndpointsConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class LROWithParamaterizedEndpoints: + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. Pass in + 'host:3000' to pass test. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = LROWithParamaterizedEndpointsConfiguration(host, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `lrowithparameterizedendpointslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from lrowithparameterizedendpointslowlevel.rest import build_poll_with_parameterized_endpoints_request + >>> request = build_poll_with_parameterized_endpoints_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "LROWithParamaterizedEndpoints": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/py.typed b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/__init__.py new file mode 100644 index 00000000000..6819157cc98 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/__init__.py @@ -0,0 +1,19 @@ +# 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_poll_with_parameterized_endpoints_request + from ._request_builders_py3 import build_poll_with_constant_parameterized_endpoints_request +except (SyntaxError, ImportError): + from ._request_builders import build_poll_with_parameterized_endpoints_request # type: ignore + from ._request_builders import build_poll_with_constant_parameterized_endpoints_request # type: ignore + +__all__ = [ + "build_poll_with_parameterized_endpoints_request", + "build_poll_with_constant_parameterized_endpoints_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..b899c36379b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/_request_builders.py @@ -0,0 +1,86 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_poll_with_parameterized_endpoints_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Poll with method and client level parameters in endpoint. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lroParameterizedEndpoints') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_poll_with_constant_parameterized_endpoints_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Poll with method and client level parameters in endpoint, with a constant value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + constant_parameter = "iAmConstant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/lroConstantParameterizedEndpoints/{constantParameter}') + path_format_arguments = { + 'constantParameter': _SERIALIZER.url("constant_parameter", constant_parameter, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..be7a395f70c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/lrowithparameterizedendpointslowlevel/rest/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_poll_with_parameterized_endpoints_request(**kwargs: Any) -> HttpRequest: + """Poll with method and client level parameters in endpoint. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lroParameterizedEndpoints") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_poll_with_constant_parameterized_endpoints_request(**kwargs: Any) -> HttpRequest: + """Poll with method and client level parameters in endpoint, with a constant value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + """ + + constant_parameter = "iAmConstant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/lroConstantParameterizedEndpoints/{constantParameter}") + path_format_arguments = { + "constantParameter": _SERIALIZER.url("constant_parameter", constant_parameter, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/setup.py new file mode 100644 index 00000000000..46be9af6e00 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel/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 = "lrowithparamaterizedendpoints" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="LROWithParamaterizedEndpoints", + author_email="", + url="", + keywords=["Swagger", "LROWithParamaterizedEndpoints"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/__init__.py new file mode 100644 index 00000000000..8711274f7ea --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/__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 ._auto_rest_paging_test_service import AutoRestPagingTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestPagingTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_auto_rest_paging_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_auto_rest_paging_test_service.py new file mode 100644 index 00000000000..d2a911fd722 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_auto_rest_paging_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestPagingTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestPagingTestService(object): + """Long-running Operation for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestPagingTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `paginglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from paginglowlevel.rest import paging + >>> request = paging.build_get_no_item_name_pages_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestPagingTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_configuration.py new file mode 100644 index 00000000000..1e57648004b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_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 AutoRestPagingTestServiceConfiguration(Configuration): + """Configuration for AutoRestPagingTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestPagingTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestpagingtestservice/{}".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/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_version.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/__init__.py new file mode 100644 index 00000000000..c04764f16be --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/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 ._auto_rest_paging_test_service import AutoRestPagingTestService + +__all__ = ["AutoRestPagingTestService"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/_auto_rest_paging_test_service.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/_auto_rest_paging_test_service.py new file mode 100644 index 00000000000..344e83d5f77 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/_auto_rest_paging_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestPagingTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestPagingTestService: + """Long-running Operation for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestPagingTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `paginglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from paginglowlevel.rest import paging + >>> request = paging.build_get_no_item_name_pages_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestPagingTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/aio/_configuration.py new file mode 100644 index 00000000000..e39ce7a3614 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/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 AutoRestPagingTestServiceConfiguration(Configuration): + """Configuration for AutoRestPagingTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestPagingTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestpagingtestservice/{}".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/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/py.typed b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/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/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/__init__.py new file mode 100644 index 00000000000..94cb2afe469 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/__init__.py @@ -0,0 +1,73 @@ +# 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_get_no_item_name_pages_request + from ._request_builders_py3 import build_get_null_next_link_name_pages_request + from ._request_builders_py3 import build_get_single_pages_request + from ._request_builders_py3 import build_first_response_empty_request + from ._request_builders_py3 import build_get_multiple_pages_request + from ._request_builders_py3 import build_get_with_query_params_request + from ._request_builders_py3 import build_next_operation_with_query_params_request + from ._request_builders_py3 import build_get_odata_multiple_pages_request + from ._request_builders_py3 import build_get_multiple_pages_with_offset_request + from ._request_builders_py3 import build_get_multiple_pages_retry_first_request + from ._request_builders_py3 import build_get_multiple_pages_retry_second_request + from ._request_builders_py3 import build_get_single_pages_failure_request + from ._request_builders_py3 import build_get_multiple_pages_failure_request + from ._request_builders_py3 import build_get_multiple_pages_failure_uri_request + from ._request_builders_py3 import build_get_multiple_pages_fragment_next_link_request + from ._request_builders_py3 import build_get_multiple_pages_fragment_with_grouping_next_link_request + from ._request_builders_py3 import build_get_multiple_pages_lro_request + from ._request_builders_py3 import build_next_fragment_request + from ._request_builders_py3 import build_next_fragment_with_grouping_request + from ._request_builders_py3 import build_get_paging_model_with_item_name_with_xms_client_name_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_no_item_name_pages_request # type: ignore + from ._request_builders import build_get_null_next_link_name_pages_request # type: ignore + from ._request_builders import build_get_single_pages_request # type: ignore + from ._request_builders import build_first_response_empty_request # type: ignore + from ._request_builders import build_get_multiple_pages_request # type: ignore + from ._request_builders import build_get_with_query_params_request # type: ignore + from ._request_builders import build_next_operation_with_query_params_request # type: ignore + from ._request_builders import build_get_odata_multiple_pages_request # type: ignore + from ._request_builders import build_get_multiple_pages_with_offset_request # type: ignore + from ._request_builders import build_get_multiple_pages_retry_first_request # type: ignore + from ._request_builders import build_get_multiple_pages_retry_second_request # type: ignore + from ._request_builders import build_get_single_pages_failure_request # type: ignore + from ._request_builders import build_get_multiple_pages_failure_request # type: ignore + from ._request_builders import build_get_multiple_pages_failure_uri_request # type: ignore + from ._request_builders import build_get_multiple_pages_fragment_next_link_request # type: ignore + from ._request_builders import build_get_multiple_pages_fragment_with_grouping_next_link_request # type: ignore + from ._request_builders import build_get_multiple_pages_lro_request # type: ignore + from ._request_builders import build_next_fragment_request # type: ignore + from ._request_builders import build_next_fragment_with_grouping_request # type: ignore + from ._request_builders import build_get_paging_model_with_item_name_with_xms_client_name_request # type: ignore + +__all__ = [ + "build_get_no_item_name_pages_request", + "build_get_null_next_link_name_pages_request", + "build_get_single_pages_request", + "build_first_response_empty_request", + "build_get_multiple_pages_request", + "build_get_with_query_params_request", + "build_next_operation_with_query_params_request", + "build_get_odata_multiple_pages_request", + "build_get_multiple_pages_with_offset_request", + "build_get_multiple_pages_retry_first_request", + "build_get_multiple_pages_retry_second_request", + "build_get_single_pages_failure_request", + "build_get_multiple_pages_failure_request", + "build_get_multiple_pages_failure_uri_request", + "build_get_multiple_pages_fragment_next_link_request", + "build_get_multiple_pages_fragment_with_grouping_next_link_request", + "build_get_multiple_pages_lro_request", + "build_next_fragment_request", + "build_next_fragment_with_grouping_request", + "build_get_paging_model_with_item_name_with_xms_client_name_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/_request_builders.py new file mode 100644 index 00000000000..608c397514b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/_request_builders.py @@ -0,0 +1,1129 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_no_item_name_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that must return result of the default 'value' node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/noitemname') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_next_link_name_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/nullnextlink') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that finishes on the first call without a nextlink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_first_response_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/firstResponseEmpty/1') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_with_query_params_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword required_query_parameter: A required integer query parameter. Put in value '100' to + pass test. + :paramtype required_query_parameter: int + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + required_query_parameter = kwargs.pop('required_query_parameter') # type: int + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/getWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['requiredQueryParameter'] = _SERIALIZER.query("required_query_parameter", required_query_parameter, 'int') + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_operation_with_query_params_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/nextOperationWithQueryParams') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['queryConstant'] = _SERIALIZER.query("query_constant", query_constant, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_odata_multiple_pages_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink in odata format that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/odata') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_with_offset_request( + offset, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param offset: Offset of return value. + :type offset: int + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/withpath/{offset}') + path_format_arguments = { + 'offset': _SERIALIZER.url("offset", offset, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_first_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retryfirst') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_retry_second_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/retrysecond') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_single_pages_failure_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives a 400 on the first call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/single/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives a 400 on the second call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failure') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_failure_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that receives an invalid nextLink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/failureuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_next_link_request( + tenant, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_multiple_pages_lro_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 202 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/lro') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_request( + tenant, # type: str + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragment/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_next_fragment_with_grouping_request( + tenant, # type: str + next_link, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}') + path_format_arguments = { + 'tenant': _SERIALIZER.url("tenant", tenant, 'str'), + 'nextLink': _SERIALIZER.url("next_link", next_link, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api_version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_paging_model_with_item_name_with_xms_client_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paging/itemNameWithXMSClientName') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/_request_builders_py3.py new file mode 100644 index 00000000000..d1e929ff68d --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/paginglowlevel/rest/paging/_request_builders_py3.py @@ -0,0 +1,956 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_no_item_name_pages_request(**kwargs: Any) -> HttpRequest: + """A paging operation that must return result of the default 'value' node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/noitemname") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_next_link_name_pages_request(**kwargs: Any) -> HttpRequest: + """A paging operation that must ignore any kind of nextLink, and stop after page 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/nullnextlink") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_single_pages_request(**kwargs: Any) -> HttpRequest: + """A paging operation that finishes on the first call without a nextlink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/single") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_first_response_empty_request(**kwargs: Any) -> HttpRequest: + """A paging operation whose first response's items list is empty, but still returns a next link. + Second (and final) call, will give you an items list of 1. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/firstResponseEmpty/1") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_with_query_params_request(*, required_query_parameter: int, **kwargs: Any) -> HttpRequest: + """A paging operation that includes a next operation. It has a different query parameter from it's + next operation nextOperationWithQueryParams. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword required_query_parameter: A required integer query parameter. Put in value '100' to + pass test. + :paramtype required_query_parameter: int + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/getWithQueryParams") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["requiredQueryParameter"] = _SERIALIZER.query( + "required_query_parameter", required_query_parameter, "int" + ) + query_parameters["queryConstant"] = _SERIALIZER.query("query_constant", query_constant, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_next_operation_with_query_params_request(**kwargs: Any) -> HttpRequest: + """Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + query_constant = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/nextOperationWithQueryParams") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["queryConstant"] = _SERIALIZER.query("query_constant", query_constant, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_odata_multiple_pages_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink in odata format that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/odata") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_with_offset_request( + offset: int, + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param offset: Offset of return value. + :type offset: int + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/withpath/{offset}") + path_format_arguments = { + "offset": _SERIALIZER.url("offset", offset, "int"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_retry_first_request(**kwargs: Any) -> HttpRequest: + """A paging operation that fails on the first call with 500 and then retries and then get a + response including a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/retryfirst") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_retry_second_request(**kwargs: Any) -> HttpRequest: + """A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails + first with 500. The client should retry and finish all 10 pages eventually. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/retrysecond") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_single_pages_failure_request(**kwargs: Any) -> HttpRequest: + """A paging operation that receives a 400 on the first call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/single/failure") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_failure_request(**kwargs: Any) -> HttpRequest: + """A paging operation that receives a 400 on the second call. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/failure") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_failure_uri_request(**kwargs: Any) -> HttpRequest: + """A paging operation that receives an invalid nextLink. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/failureuri") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_fragment_next_link_request(tenant: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragment/{tenant}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_fragment_with_grouping_next_link_request( + tenant: str, *, api_version: str, **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment with parameters grouped. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragmentwithgrouping/{tenant}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_multiple_pages_lro_request( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + + # response body for status code(s): 202 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/lro") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters["client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + if maxresults is not None: + header_parameters["maxresults"] = _SERIALIZER.header("maxresults", maxresults, "int") + if timeout is not None: + header_parameters["timeout"] = _SERIALIZER.header("timeout", timeout, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_next_fragment_request(tenant: str, next_link: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragment/{tenant}/{nextLink}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_next_fragment_with_grouping_request( + tenant: str, next_link: str, *, api_version: str, **kwargs: Any +) -> HttpRequest: + """A paging operation that doesn't return a full URL, just a fragment. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param tenant: Sets the tenant to use. + :type tenant: str + :param next_link: Next link for list operation. + :type next_link: str + :keyword api_version: Sets the api version to use. + :paramtype api_version: str + :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 + + # response body for status code(s): 200 + response.json() == { + "odata.nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/multiple/fragmentwithgrouping/{tenant}/{nextLink}") + path_format_arguments = { + "tenant": _SERIALIZER.url("tenant", tenant, "str"), + "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api_version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_paging_model_with_item_name_with_xms_client_name_request(**kwargs: Any) -> HttpRequest: + """A paging operation that returns a paging model whose item name is is overriden by + x-ms-client-name 'indexes'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "values": [ + { + "properties": { + "id": "int (optional)", + "name": "str (optional)" + } + } + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paging/itemNameWithXMSClientName") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/setup.py new file mode 100644 index 00000000000..fa06e332afe --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/PagingLowLevel/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 = "autorestpagingtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestPagingTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestPagingTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Long-running Operation for AutoRest. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/setup.py new file mode 100644 index 00000000000..ebf00958336 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/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 = "storagemanagementclient" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="StorageManagementClient", + author_email="", + url="", + keywords=["Swagger", "StorageManagementClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + StorageManagementClient. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/__init__.py new file mode 100644 index 00000000000..8a6a128e195 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/__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 ._storage_management_client import StorageManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["StorageManagementClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_configuration.py new file mode 100644 index 00000000000..e4b713a433b --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_configuration.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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class StorageManagementClientConfiguration(Configuration): + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(StorageManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2015-05-01-preview" + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "storagemanagementclient/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_storage_management_client.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_storage_management_client.py new file mode 100644 index 00000000000..8069c2d007a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_storage_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import StorageManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class StorageManagementClient(object): + """StorageManagementClient. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "https://management.azure.com" + self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `storagelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from storagelowlevel.rest import storage_accounts + >>> request = storage_accounts.build_check_name_availability_request(subscription_id, json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> StorageManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_version.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/__init__.py new file mode 100644 index 00000000000..a6627fc24f1 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/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 ._storage_management_client import StorageManagementClient + +__all__ = ["StorageManagementClient"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..f0e57dacffa --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/_configuration.py @@ -0,0 +1,61 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClientConfiguration(Configuration): + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(StorageManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2015-05-01-preview" + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "storagemanagementclient/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/_storage_management_client.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/_storage_management_client.py new file mode 100644 index 00000000000..39e2f924c09 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/aio/_storage_management_client.py @@ -0,0 +1,86 @@ +# 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.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import StorageManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClient: + """StorageManagementClient. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + if not base_url: + base_url = "https://management.azure.com" + self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `storagelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from storagelowlevel.rest import storage_accounts + >>> request = storage_accounts.build_check_name_availability_request(subscription_id, json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "StorageManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/py.typed b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/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/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/__init__.py new file mode 100644 index 00000000000..553b7460908 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/__init__.py @@ -0,0 +1,40 @@ +# 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_check_name_availability_request + from ._request_builders_py3 import build_create_request + from ._request_builders_py3 import build_delete_request + from ._request_builders_py3 import build_get_properties_request + from ._request_builders_py3 import build_update_request + from ._request_builders_py3 import build_list_keys_request + from ._request_builders_py3 import build_list_request + from ._request_builders_py3 import build_list_by_resource_group_request + from ._request_builders_py3 import build_regenerate_key_request +except (SyntaxError, ImportError): + from ._request_builders import build_check_name_availability_request # type: ignore + from ._request_builders import build_create_request # type: ignore + from ._request_builders import build_delete_request # type: ignore + from ._request_builders import build_get_properties_request # type: ignore + from ._request_builders import build_update_request # type: ignore + from ._request_builders import build_list_keys_request # type: ignore + from ._request_builders import build_list_request # type: ignore + from ._request_builders import build_list_by_resource_group_request # type: ignore + from ._request_builders import build_regenerate_key_request # type: ignore + +__all__ = [ + "build_check_name_availability_request", + "build_create_request", + "build_delete_request", + "build_get_properties_request", + "build_update_request", + "build_list_keys_request", + "build_list_request", + "build_list_by_resource_group_request", + "build_regenerate_key_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/_request_builders.py new file mode 100644 index 00000000000..a2095630a35 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/_request_builders.py @@ -0,0 +1,821 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_check_name_availability_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Checks that account name is valid and is not in use. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "name": "str", + "type": "str (optional). Default value is \"Microsoft.Storage/storageAccounts\"" + } + + # response body for status code(s): 200 + response.json() == { + "message": "str (optional)", + "nameAvailable": "bool (optional)", + "reason": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Asynchronously creates a new storage account with the specified parameters. Existing accounts + cannot be updated with this API and should instead use the Update Storage Account API. If an + account is already created and subsequent PUT request is issued with exact same set of + properties, then HTTP 200 would be returned. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to provide for the created account. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to provide for the created account. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "accountType": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Deletes a storage account in Microsoft Azure. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_properties_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns the properties for the specified storage account including but not limited to name, + account type, location, and account status. The ListKeys operation should be used to retrieve + storage keys. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Updates the account type or tags for a storage account. It can also be used to add a custom + domain (note that custom domains cannot be added via the Create operation). Only one custom + domain is supported per storage account. This API can only be used to update one of tags, + accountType, or customDomain per call. To update multiple of these properties, call the API + multiple times with one change per call. This call does not change the storage keys for the + account. If you want to change storage account keys, use the RegenerateKey operation. The + location and name of the storage account cannot be changed after creation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to update on the account. Note that only + one property can be changed at a time using this API. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to update on the account. Note that only one + property can be changed at a time using this API. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "accountType": "str (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "key1": "str (optional)", + "key2": "str (optional)" + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + ] + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + ] + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_key_request( + resource_group_name, # type: str + account_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Regenerates the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Specifies name of the key which should be regenerated. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Specifies name of the key which should be regenerated. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "keyName": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "key1": "str (optional)", + "key2": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'accountName': _SERIALIZER.url("account_name", account_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/_request_builders_py3.py new file mode 100644 index 00000000000..357308084cb --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/storage_accounts/_request_builders_py3.py @@ -0,0 +1,783 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_check_name_availability_request( + subscription_id: str, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Checks that account name is valid and is not in use. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The name of the storage account within the specified + resource group. Storage account names must be between 3 and 24 characters in length and use + numbers and lower-case letters only. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "name": "str", + "type": "str (optional). Default value is \"Microsoft.Storage/storageAccounts\"" + } + + # response body for status code(s): 200 + response.json() == { + "message": "str (optional)", + "nameAvailable": "bool (optional)", + "reason": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_create_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Asynchronously creates a new storage account with the specified parameters. Existing accounts + cannot be updated with this API and should instead use the Update Storage Account API. If an + account is already created and subsequent PUT request is issued with exact same set of + properties, then HTTP 200 would be returned. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to provide for the created account. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to provide for the created account. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "accountType": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_delete_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + """Deletes a storage account in Microsoft Azure. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + """ + + api_version = "2015-05-01-preview" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=url, params=query_parameters, **kwargs) + + +def build_get_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + """Returns the properties for the specified storage account including but not limited to name, + account type, location, and account status. The ListKeys operation should be used to retrieve + storage keys. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Updates the account type or tags for a storage account. It can also be used to add a custom + domain (note that custom domains cannot be added via the Create operation). Only one custom + domain is supported per storage account. This API can only be used to update one of tags, + accountType, or customDomain per call. To update multiple of these properties, call the API + multiple times with one change per call. This call does not change the storage keys for the + account. If you want to change storage account keys, use the RegenerateKey operation. The + location and name of the storage account cannot be changed after creation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The parameters to update on the account. Note that only + one property can be changed at a time using this API. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The parameters to update on the account. Note that only one + property can be changed at a time using this API. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "properties": { + "accountType": "str (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + """Lists the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "key1": "str (optional)", + "key2": "str (optional)" + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + ] + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str (optional)", + "value": [ + { + "properties": { + "accountType": "str (optional)", + "creationTime": "datetime (optional)", + "customDomain": { + "name": "str (optional)", + "useSubDomain": "bool (optional)" + }, + "lastGeoFailoverTime": "datetime (optional)", + "primaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "primaryLocation": "str (optional)", + "provisioningState": "str (optional)", + "secondaryEndpoints": { + "FooPoint": { + "Bar.Point": { + "RecursivePoint": "..." + } + }, + "blob": "str (optional)", + "dummyEndPoint": "...", + "queue": "str (optional)", + "table": "str (optional)" + }, + "secondaryLocation": "str (optional)", + "statusOfPrimary": "str (optional)", + "statusOfSecondary": "str (optional)" + } + } + ] + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_regenerate_key_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Regenerates the access keys for the specified storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param resource_group_name: The name of the resource group within the user’s subscription. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Specifies name of the key which should be regenerated. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Specifies name of the key which should be regenerated. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "keyName": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "key1": "str (optional)", + "key2": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/__init__.py new file mode 100644 index 00000000000..fbe313bf81a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/__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_list_request +except (SyntaxError, ImportError): + from ._request_builders import build_list_request # type: ignore + +__all__ = [ + "build_list_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/_request_builders.py new file mode 100644 index 00000000000..291ce71ee2c --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/_request_builders.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 TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets the current usage count and the limit for the resources under the subscription. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "value": [ + { + "currentValue": "int (optional)", + "limit": "int (optional)", + "name": { + "localizedValue": "str (optional)", + "value": "str (optional)" + }, + "unit": "str (optional)" + } + ] + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/_request_builders_py3.py new file mode 100644 index 00000000000..e463aa77276 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/StorageManagementClientLowLevel/storagelowlevel/rest/usage/_request_builders_py3.py @@ -0,0 +1,67 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + """Gets the current usage count and the limit for the resources under the subscription. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "value": [ + { + "currentValue": "int (optional)", + "limit": "int (optional)", + "name": { + "localizedValue": "str (optional)", + "value": "str (optional)" + }, + "unit": "str (optional)" + } + ] + } + """ + + api_version = "2015-05-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/setup.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/setup.py new file mode 100644 index 00000000000..eadaad6a419 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/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 = "microsoftazuretesturl" +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.16.0", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="MicrosoftAzureTestUrl", + author_email="", + url="", + keywords=["Swagger", "MicrosoftAzureTestUrl"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Some cool documentation. + """, +) diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/__init__.py new file mode 100644 index 00000000000..3e45961dfad --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/__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 ._microsoft_azure_test_url import MicrosoftAzureTestUrl +from ._version import VERSION + +__version__ = VERSION +__all__ = ["MicrosoftAzureTestUrl"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_configuration.py new file mode 100644 index 00000000000..63fe1f4ac74 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_configuration.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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class MicrosoftAzureTestUrlConfiguration(Configuration): + """Configuration for MicrosoftAzureTestUrl. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription Id. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(MicrosoftAzureTestUrlConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2014-04-01-preview" + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "microsoftazuretesturl/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_microsoft_azure_test_url.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_microsoft_azure_test_url.py new file mode 100644 index 00000000000..30bdd528310 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_microsoft_azure_test_url.py @@ -0,0 +1,98 @@ +# 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.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import MicrosoftAzureTestUrlConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + + +class MicrosoftAzureTestUrl(object): + """Some cool documentation. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription Id. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = MicrosoftAzureTestUrlConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `subscriptionidapiversionlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from subscriptionidapiversionlowlevel.rest import group + >>> request = group.build_get_sample_resource_group_request(subscription_id, resource_group_name, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> MicrosoftAzureTestUrl + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_version.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_version.py rename to test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/_version.py diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/__init__.py new file mode 100644 index 00000000000..7a36ac22242 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/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 ._microsoft_azure_test_url import MicrosoftAzureTestUrl + +__all__ = ["MicrosoftAzureTestUrl"] diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/_configuration.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..445ce141037 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/_configuration.py @@ -0,0 +1,61 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MicrosoftAzureTestUrlConfiguration(Configuration): + """Configuration for MicrosoftAzureTestUrl. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription Id. + :type subscription_id: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(MicrosoftAzureTestUrlConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2014-04-01-preview" + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "microsoftazuretesturl/{}".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 ARMHttpLoggingPolicy(**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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/_microsoft_azure_test_url.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/_microsoft_azure_test_url.py new file mode 100644 index 00000000000..5d7effb5290 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/aio/_microsoft_azure_test_url.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 Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import MicrosoftAzureTestUrlConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + + +class MicrosoftAzureTestUrl: + """Some cool documentation. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription Id. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = MicrosoftAzureTestUrlConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `subscriptionidapiversionlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from subscriptionidapiversionlowlevel.rest import group + >>> request = group.build_get_sample_resource_group_request(subscription_id, resource_group_name, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "MicrosoftAzureTestUrl": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/py.typed b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/py.typed rename to test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/py.typed diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/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/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/__init__.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/__init__.py new file mode 100644 index 00000000000..8b64bc9508a --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/__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_get_sample_resource_group_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_sample_resource_group_request # type: ignore + +__all__ = [ + "build_get_sample_resource_group_request", +] diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/_request_builders.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/_request_builders.py new file mode 100644 index 00000000000..f892366eb37 --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/_request_builders.py @@ -0,0 +1,76 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_sample_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Provides a resouce group with name 'testgroup101' and location 'West US'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param resource_group_name: Resource Group name 'testgroup101'. + :type resource_group_name: str + :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 + + # response body for status code(s): 200 + response.json() == { + "location": "str (optional)", + "name": "str (optional)" + } + """ + + api_version = "2014-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/_request_builders_py3.py b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/_request_builders_py3.py new file mode 100644 index 00000000000..e6771a7487f --- /dev/null +++ b/test/azure/low-level/Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel/subscriptionidapiversionlowlevel/rest/group/_request_builders_py3.py @@ -0,0 +1,62 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_sample_resource_group_request( + subscription_id: str, resource_group_name: str, **kwargs: Any +) -> HttpRequest: + """Provides a resouce group with name 'testgroup101' and location 'West US'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your + code flow. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param resource_group_name: Resource Group name 'testgroup101'. + :type resource_group_name: str + :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 + + # response body for status code(s): 200 + response.json() == { + "location": "str (optional)", + "name": "str (optional)" + } + """ + + api_version = "2014-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/azure/low-level/coverage/report-azure.json b/test/azure/low-level/coverage/report-azure.json new file mode 100644 index 00000000000..9879d3b8c34 --- /dev/null +++ b/test/azure/low-level/coverage/report-azure.json @@ -0,0 +1,139 @@ +{ + "LROPostDoubleHeadersFinalLocationPost": 4, + "LROPostDoubleHeadersFinalLocationAsync": 5, + "LROPostDoubleHeadersFinalLocationGet": 5, + "LROConstantParameterizedPost": 0, + "LROConstantParameterizedGet": 0, + "PostParameterGroupingWithReservedWords": 1, + "LROPutInlineComplete": 2, + "LROPutInlineComplete201": 1, + "CustomHeaderPutAsyncSucceded": 0, + "CustomHeaderPostAsyncSucceded": 0, + "CustomHeaderPutSucceeded": 0, + "CustomHeaderPostSucceeded": 0, + "LROPut200InlineCompleteNoState": 1, + "LROPut202Retry200": 1, + "LROPutSucceededWithBody": 1, + "LROPutSucceededNoBody": 1, + "LROPutFailed": 1, + "LROPutCanceled": 1, + "LROPutAsyncRetrySucceeded": 1, + "LROPutAsyncNoRetrySucceeded": 1, + "LROPutAsyncRetryFailed": 1, + "LROPutAsyncNoRetryCanceled": 1, + "LROPutNoHeaderInRetry": 1, + "LROPutAsyncNoHeaderInRetry": 1, + "LRODeleteNoHeaderInRetry": 1, + "LRODeleteAsyncNoHeaderInRetry": 1, + "LROPutSubResourceInRetry": 1, + "LROPutSubResourceAsyncInRetry": 2, + "LROPutNonResourceInRetry": 1, + "LROPutNonResourceAsyncInRetry": 1, + "LRODeleteProvisioningSucceededWithBody": 1, + "LRODeleteProvisioningFailed": 1, + "LRODeleteProvisioningCanceled": 1, + "LRODeleteInlineComplete": 1, + "LRODelete200": 1, + "LRODelete204": 1, + "LRODeleteAsyncRetrySucceeded": 1, + "LRODeleteAsyncNoRetrySucceeded": 1, + "LRODeleteAsyncRetryFailed": 1, + "LRODeleteAsyncRetryCanceled": 1, + "LROPostSuccededWithBody": 1, + "LROPostSuccededNoBody": 1, + "LROPost200": 1, + "LROPostDoubleHeadersFinalAzureHeaderGet": 1, + "LROPostDoubleHeadersFinalAzureHeaderGetDefault": 3, + "LROPostAndGetList": 1, + "LROPostAsyncRetrySucceeded": 1, + "LROPostAsyncNoRetrySucceeded": 1, + "LROPostAsyncRetryFailed": 1, + "LROPostAsyncRetryCanceled": 1, + "LRORetryPutSucceededWithBody": 1, + "LRORetryErrorPutAsyncSucceeded": 1, + "LRORetryErrorPutAsyncSucceededPolling": 1, + "LRORetryErrorDelete202Accepted200Succeeded": 1, + "LRORetryErrorDelete202Retry200Succeeded": 1, + "LRORetryErrorDeleteAsyncRetrySucceeded": 1, + "LRORetryErrorPost202Retry200Succeeded": 1, + "LRORetryErrorPostAsyncRetrySucceeded": 2, + "LRONonRetryPut400": 1, + "LRONonRetryPut201Creating400": 1, + "LRONonRetryPut201Creating400InvalidJson": 1, + "LRONonRetryPutAsyncRetry400": 1, + "LRONonRetryDelete400": 1, + "LRONonRetryDelete202Retry400": 1, + "LRONonRetryDeleteAsyncRetry400": 1, + "LRONonRetryPost400": 1, + "LRONonRetryPost202Retry400": 1, + "LRONonRetryPostAsyncRetry400": 1, + "LROErrorPut201NoProvisioningStatePayload": 1, + "LROErrorPutAsyncNoPollingStatus": 1, + "LROErrorPutAsyncNoPollingStatusPayload": 1, + "LROErrorPut200InvalidJson": 1, + "LROErrorPutAsyncInvalidHeader": 0, + "LROErrorPutAsyncInvalidJsonPolling": 0, + "LROErrorDeleteNoLocation": 1, + "LROErrorDelete202RetryInvalidHeader": 0, + "LROErrorDeleteAsyncNoPollingStatus": 1, + "LROErrorDeleteAsyncInvalidHeader": 0, + "LROErrorDeleteAsyncInvalidJsonPolling": 0, + "LROErrorPostNoLocation": 1, + "LROErrorPost202RetryInvalidHeader": 0, + "LROErrorPostAsyncNoPollingPayload": 1, + "LROErrorPostAsyncInvalidHeader": 0, + "LROErrorPostAsyncInvalidJsonPolling": 0, + "LROParameterizedEndpoint": 0, + "PagingNoItemName": 1, + "PagingNextLinkNameNull": 1, + "PagingSingle": 1, + "PagingMultiple": 1, + "PagingMultipleWithQueryParameters": 1, + "PagingOdataMultiple": 1, + "PagingMultiplePath": 1, + "PagingMultipleRetryFirst": 1, + "PagingMultipleRetrySecond": 1, + "PagingSingleFailure": 1, + "PagingMultipleFailure": 1, + "PagingMultipleFailureUri": 1, + "PagingFragment": 1, + "PagingMultipleLRO": 0, + "PagingCustomUrlPartialNextLink": 0, + "PagingCustomUrlPartialOperationNextLink": 0, + "PagingReturnModelWithXMSClientName": 0, + "PagingFirstResponseEmpty": 1, + "AzureSubscriptionMethodLocalValid": 1, + "AzureSubscriptionMethodGlobalValid": 1, + "AzureSubscriptionMethodGlobalNotProvidedValid": 1, + "AzureSubscriptionPathLocalValid": 1, + "AzureSubscriptionPathGlobalValid": 1, + "AzureSubscriptionSwaggerLocalValid": 1, + "AzureSubscriptionSwaggerGlobalValid": 1, + "AzureApiVersionMethodLocalNull": 1, + "AzureApiVersionMethodLocalValid": 1, + "AzureApiVersionMethodGlobalValid": 1, + "AzureApiVersionMethodGlobalNotProvidedValid": 1, + "AzureApiVersionPathLocalValid": 1, + "AzureApiVersionPathGlobalValid": 1, + "AzureApiVersionSwaggerLocalValid": 1, + "AzureApiVersionSwaggerGlobalValid": 1, + "AzureMethodPathUrlEncoding": 1, + "AzurePathPathUrlEncoding": 1, + "AzureSwaggerPathUrlEncoding": 1, + "AzureMethodQueryUrlEncoding": 1, + "AzurePathQueryUrlEncoding": 1, + "AzureSwaggerQueryUrlEncoding": 1, + "AzureMethodQueryUrlEncodingNull": 2, + "AzureXmsRequestClientOverwrite": 1, + "AzureXmsRequestClientOverwriteViaParameter": 1, + "AzureXmsRequestClientIdNull": 1, + "AzureXmsCustomNamedRequestId": 1, + "AzureXmsCustomNamedRequestIdParameterGroup": 1, + "AzureRequestClientIdInError": 1, + "AzureODataFilter": 1, + "SubscriptionIdAndApiVersion": 2, + "postParameterGroupingOptionalParameters": 2, + "postParameterGroupingRequiredParameters": 2, + "postParameterGroupingMultipleParameterGroups": 2, + "postParameterGroupingSharedParameterGroupObject": 1 +} \ No newline at end of file diff --git a/test/azure/low-level/coverage/report-optional.json b/test/azure/low-level/coverage/report-optional.json new file mode 100644 index 00000000000..8d46c893031 --- /dev/null +++ b/test/azure/low-level/coverage/report-optional.json @@ -0,0 +1,48 @@ +{ + "StreamUploadFile": 120, + "UpdatePetWithForm": 0, + "getDecimalInvalid": 24, + "getDecimalBig": 24, + "getDecimalSmall": 24, + "getDecimalBigPositiveDecimal": 24, + "getDecimalBigNegativeDecimal": 24, + "putDecimalBig": 24, + "putDecimalSmall": 24, + "putDecimalBigPositiveDecimal": 24, + "putDecimalBigNegativeDecimal": 19, + "putDateTimeMaxUtc7MS": 0, + "getDateTimeMaxUtc7MSUppercase": 25, + "putDateTimeMaxLocalPositiveOffset": 25, + "putDateTimeMaxLocalNegativeOffset": 0, + "putDateTimeMinLocalPositiveOffset": 0, + "putDateTimeMinLocalNegativeOffset": 25, + "HeaderParameterProtectedKey": 1, + "CustomHeaderInRequest": 19, + "FormdataStreamUploadFile": 86, + "HttpSuccess200Options": 0, + "HttpRedirect307Options": 0, + "HttpRetry502Options": 0, + "HttpClientFailure400Options": 0, + "HttpClientFailure403Options": 0, + "HttpClientFailure412Options": 0, + "ResponsesScenarioNoModelEmptyBody": 24, + "sendErrorWithParamNameModels": 72, + "MultiapiPutTestOneApiVersionOne": 17, + "MultiapiPutTestOneApiVersionTwo": 17, + "MultiapiGetTestTwoApiVersionOne": 17, + "MultiapiGetTestTwoApiVersionTwo": 17, + "MultiapiGetTestTwoApiVersionThree": 17, + "MultiapiPutTestThreeApiVersionTwo": 17, + "MultiapiPostTestFourApiVersionTwo": 17, + "MultiapiPostTestFourApiVersionThreeJSON": 17, + "MultiapiPostTestFourApiVersionThreePDF": 0, + "MultiapiPutTestFiveApiVersionThree": 17, + "MultiapiLRO": 13, + "MultiapiPaging": 17, + "MultiapiLROAndPaging": 16, + "MultiapiDifferentCallsApiVersionOne": 0, + "MultiapiDifferentCallsApiVersionTwo": 0, + "MultiapiDifferentCallsApiVersionThree": 0, + "MultiapiCustomBaseUrlApiVersionOne": 7, + "MultiapiCustomBaseUrlApiVersionTwo": 7 +} \ No newline at end of file diff --git a/test/azure/low-level/coverage/report-vanilla.json b/test/azure/low-level/coverage/report-vanilla.json new file mode 100644 index 00000000000..ed1bdb01f0a --- /dev/null +++ b/test/azure/low-level/coverage/report-vanilla.json @@ -0,0 +1,618 @@ +{ + "GetStringAsAnything": 21, + "PutStringAsAnything": 21, + "GetObjectAsAnything": 21, + "PutObjectAsAnything": 21, + "GetArrayAsAnything": 21, + "PutArrayAsAnything": 21, + "verifyIncorrectErrorParsing": 19, + "LLCRequiredToOptional": 0, + "MediaTypesAnalyzeBodyNoAcceptHeader": 0, + "verifyHost": 0, + "ImplicitOptionalBinaryBody": 19, + "ExplicitOptionalBinaryBody": 29, + "ExplicitRequiredBinaryBody": 21, + "OptionalImplicitBody": 24, + "GeneralOptional": 264, + "OptionalImplicitHeader": 24, + "OptionalImplicitQuery": 24, + "OptionalGlobalQuery": 24, + "getStringNull": 24, + "putStringNull": 24, + "getStringEmpty": 24, + "putStringEmpty": 24, + "getStringNotProvided": 24, + "getStringWithLeadingAndTrailingWhitespace": 24, + "putStringWithLeadingAndTrailingWhitespace": 24, + "getStringBase64UrlEncoded": 24, + "putStringBase64UrlEncoded": 24, + "getStringBase64Encoded": 24, + "getStringNullBase64UrlEncoding": 24, + "getStringMultiByteCharacters": 24, + "putStringMultiByteCharacters": 24, + "getEnumNotExpandable": 24, + "putEnumNotExpandable": 48, + "getEnumReferenced": 24, + "putEnumReferenced": 53, + "getEnumReferencedConstant": 24, + "putEnumReferencedConstant": 19, + "XmlGetBytes": 23, + "XmlPutBytes": 23, + "XmlGetUrl": 23, + "XmlPutUrl": 23, + "additionalPropertiesTrue": 26, + "additionalPropertiesSubclass": 26, + "additionalPropertiesTypeObject": 26, + "additionalPropertiesTypeString": 26, + "additionalPropertiesInProperties": 26, + "additionalPropertiesInPropertiesWithAPTypeString": 26, + "getArrayNull": 25, + "getArrayEmpty": 25, + "putArrayEmpty": 25, + "getArrayInvalid": 25, + "getArrayBooleanValid": 25, + "putArrayBooleanValid": 25, + "getArrayBooleanWithNull": 25, + "getArrayBooleanWithString": 25, + "getArrayIntegerValid": 25, + "putArrayIntegerValid": 25, + "getArrayIntegerWithNull": 25, + "getArrayIntegerWithString": 25, + "getArrayLongValid": 25, + "putArrayLongValid": 25, + "getArrayLongWithNull": 25, + "getArrayLongWithString": 25, + "getArrayFloatValid": 25, + "putArrayFloatValid": 25, + "getArrayFloatWithNull": 25, + "getArrayFloatWithString": 25, + "getArrayDoubleValid": 25, + "putArrayDoubleValid": 25, + "getArrayDoubleWithNull": 25, + "getArrayDoubleWithString": 25, + "getArrayStringValid": 25, + "putArrayStringValid": 25, + "getArrayEnumValid": 25, + "putArrayEnumValid": 25, + "getArrayStringEnumValid": 25, + "putArrayStringEnumValid": 25, + "getArrayStringWithNull": 25, + "getArrayStringWithNumber": 50, + "getArrayDateValid": 25, + "putArrayDateValid": 25, + "getArrayDateWithNull": 25, + "getArrayDateWithInvalidChars": 25, + "getArrayDateTimeValid": 25, + "putArrayDateTimeValid": 25, + "getArrayDateTimeWithNull": 25, + "getArrayDateTimeWithInvalidChars": 25, + "getArrayDateTimeRfc1123Valid": 25, + "putArrayDateTimeRfc1123Valid": 25, + "getArrayDurationValid": 25, + "putArrayDurationValid": 25, + "getArrayUuidValid": 25, + "getArrayUuidWithInvalidChars": 25, + "putArrayUuidValid": 25, + "getArrayByteValid": 25, + "putArrayByteValid": 25, + "getArrayByteWithNull": 25, + "getArrayArrayNull": 25, + "getArrayArrayEmpty": 25, + "getArrayArrayItemNull": 25, + "getArrayArrayItemEmpty": 25, + "getArrayArrayValid": 25, + "putArrayArrayValid": 25, + "getArrayComplexNull": 25, + "getArrayComplexEmpty": 25, + "getArrayComplexItemNull": 25, + "getArrayComplexItemEmpty": 25, + "getArrayComplexValid": 25, + "putArrayComplexValid": 25, + "getArrayDictionaryNull": 25, + "getArrayDictionaryEmpty": 25, + "getArrayDictionaryItemNull": 25, + "getArrayDictionaryItemEmpty": 25, + "getArrayDictionaryValid": 25, + "putArrayDictionaryValid": 25, + "getBoolTrue": 25, + "putBoolTrue": 25, + "getBoolFalse": 25, + "putBoolFalse": 25, + "getBoolInvalid": 25, + "getBoolNull": 25, + "getByteNull": 25, + "getByteEmpty": 25, + "getByteNonAscii": 25, + "putByteNonAscii": 25, + "getByteInvalid": 25, + "getDateNull": 25, + "getDateInvalid": 25, + "getDateOverflow": 25, + "getDateUnderflow": 25, + "getDateMax": 25, + "putDateMax": 25, + "getDateMin": 25, + "putDateMin": 25, + "getDateTimeNull": 25, + "getDateTimeInvalid": 25, + "getDateTimeOverflow": 25, + "getDateTimeUnderflow": 25, + "putDateTimeMaxUtc": 25, + "getDateTimeMaxUtcLowercase": 25, + "getDateTimeMaxUtcUppercase": 25, + "getDateTimeMaxLocalPositiveOffsetLowercase": 25, + "getDateTimeMaxLocalPositiveOffsetUppercase": 25, + "getDateTimeMaxLocalNegativeOffsetLowercase": 25, + "getDateTimeMaxLocalNegativeOffsetUppercase": 25, + "getDateTimeMinUtc": 25, + "putDateTimeMinUtc": 25, + "getDateTimeMinLocalPositiveOffset": 25, + "getDateTimeMinLocalNegativeOffset": 25, + "getDateTimeRfc1123Null": 25, + "getDateTimeRfc1123Invalid": 25, + "getDateTimeRfc1123Overflow": 25, + "getDateTimeRfc1123Underflow": 25, + "getDateTimeRfc1123MinUtc": 25, + "putDateTimeRfc1123Max": 25, + "putDateTimeRfc1123Min": 25, + "getDateTimeRfc1123MaxUtcLowercase": 25, + "getDateTimeRfc1123MaxUtcUppercase": 25, + "getIntegerNull": 24, + "getIntegerInvalid": 24, + "getIntegerOverflow": 24, + "getIntegerUnderflow": 24, + "getLongOverflow": 24, + "getLongUnderflow": 24, + "putIntegerMax": 24, + "putLongMax": 24, + "putIntegerMin": 24, + "putLongMin": 24, + "getNumberNull": 24, + "getFloatInvalid": 24, + "getDoubleInvalid": 24, + "getFloatBigScientificNotation": 24, + "putFloatBigScientificNotation": 24, + "getDoubleBigScientificNotation": 24, + "putDoubleBigScientificNotation": 24, + "getDoubleBigPositiveDecimal": 24, + "putDoubleBigPositiveDecimal": 24, + "getDoubleBigNegativeDecimal": 29, + "putDoubleBigNegativeDecimal": 19, + "getFloatSmallScientificNotation": 24, + "putFloatSmallScientificNotation": 24, + "getDoubleSmallScientificNotation": 24, + "putDoubleSmallScientificNotation": 24, + "putComplexBasicValid": 50, + "getComplexBasicValid": 25, + "getComplexBasicEmpty": 25, + "getComplexBasicNotProvided": 25, + "getComplexBasicNull": 25, + "getComplexBasicInvalid": 25, + "putComplexPrimitiveInteger": 25, + "putComplexPrimitiveLong": 25, + "putComplexPrimitiveFloat": 25, + "putComplexPrimitiveDouble": 25, + "putComplexPrimitiveBool": 25, + "putComplexPrimitiveString": 25, + "putComplexPrimitiveDate": 25, + "putComplexPrimitiveDateTime": 25, + "putComplexPrimitiveDateTimeRfc1123": 25, + "putComplexPrimitiveDuration": 25, + "putComplexPrimitiveByte": 25, + "getComplexPrimitiveInteger": 25, + "getComplexPrimitiveLong": 25, + "getComplexPrimitiveFloat": 25, + "getComplexPrimitiveDouble": 25, + "getComplexPrimitiveBool": 25, + "getComplexPrimitiveString": 25, + "getComplexPrimitiveDate": 25, + "getComplexPrimitiveDateTime": 25, + "getComplexPrimitiveDateTimeRfc1123": 25, + "getComplexPrimitiveDuration": 25, + "getComplexPrimitiveByte": 25, + "putComplexArrayValid": 25, + "putComplexArrayEmpty": 25, + "getComplexArrayValid": 25, + "getComplexArrayEmpty": 25, + "getComplexArrayNotProvided": 25, + "putComplexDictionaryValid": 25, + "putComplexDictionaryEmpty": 25, + "getComplexDictionaryValid": 25, + "getComplexDictionaryEmpty": 25, + "getComplexDictionaryNull": 25, + "getComplexDictionaryNotProvided": 25, + "putComplexInheritanceValid": 68, + "getComplexInheritanceValid": 97, + "putComplexPolymorphismValid": 25, + "getComplexPolymorphismValid": 25, + "putComplexPolymorphismComplicated": 25, + "getComplexPolymorphismComplicated": 25, + "putComplexPolymorphismNoDiscriminator": 25, + "putComplexPolymorphicRecursiveValid": 25, + "getComplexPolymorphicRecursiveValid": 25, + "putComplexReadOnlyPropertyValid": 25, + "getComplexReadOnlyPropertyValid": 25, + "UrlPathsBoolFalse": 24, + "UrlPathsBoolTrue": 24, + "UrlPathsIntPositive": 24, + "UrlPathsIntNegative": 24, + "UrlPathsLongPositive": 24, + "UrlPathsLongNegative": 24, + "UrlPathsFloatPositive": 24, + "UrlPathsFloatNegative": 24, + "UrlPathsDoublePositive": 24, + "UrlPathsDoubleNegative": 24, + "UrlPathsStringUrlEncoded": 24, + "UrlPathsStringUrlNonEncoded": 24, + "UrlPathsStringEmpty": 24, + "UrlPathsStringUnicode": 24, + "UrlPathsEnumValid": 24, + "UrlPathsByteMultiByte": 24, + "UrlPathsByteEmpty": 24, + "UrlPathsDateValid": 24, + "UrlPathsDateTimeValid": 24, + "UrlQueriesBoolFalse": 24, + "UrlQueriesBoolTrue": 24, + "UrlQueriesBoolNull": 24, + "UrlQueriesIntPositive": 24, + "UrlQueriesIntNegative": 24, + "UrlQueriesIntNull": 24, + "UrlQueriesLongPositive": 24, + "UrlQueriesLongNegative": 24, + "UrlQueriesLongNull": 24, + "UrlQueriesFloatPositive": 24, + "UrlQueriesFloatNegative": 24, + "UrlQueriesFloatNull": 24, + "UrlQueriesDoublePositive": 24, + "UrlQueriesDoubleNegative": 24, + "UrlQueriesDoubleNull": 24, + "UrlQueriesStringUrlEncoded": 24, + "UrlQueriesStringEmpty": 24, + "UrlQueriesStringNull": 24, + "UrlQueriesStringUnicode": 24, + "UrlQueriesEnumValid": 24, + "UrlQueriesEnumNull": 24, + "UrlQueriesByteMultiByte": 24, + "UrlQueriesByteEmpty": 24, + "UrlQueriesByteNull": 24, + "UrlQueriesDateValid": 24, + "UrlQueriesDateNull": 24, + "UrlQueriesDateTimeValid": 24, + "UrlQueriesDateTimeNull": 24, + "UrlQueriesArrayCsvNull": 24, + "UrlQueriesArrayCsvEmpty": 24, + "UrlQueriesArrayCsvValid": 24, + "UrlQueriesArrayMultiNull": 24, + "UrlQueriesArrayMultiEmpty": 24, + "UrlQueriesArrayMultiValid": 24, + "UrlQueriesArraySsvValid": 19, + "UrlQueriesArrayPipesValid": 19, + "UrlQueriesArrayTsvValid": 13, + "UrlQueriesArrayNoCollectionFormatValid": 24, + "UrlPathItemGetAll": 24, + "UrlPathItemGetGlobalNull": 24, + "UrlPathItemGetGlobalAndLocalNull": 24, + "UrlPathItemGetPathItemAndLocalNull": 24, + "putDictionaryEmpty": 25, + "getDictionaryNull": 25, + "getDictionaryEmpty": 25, + "getDictionaryInvalid": 25, + "getDictionaryNullValue": 25, + "getDictionaryNullkey": 25, + "getDictionaryKeyEmptyString": 25, + "getDictionaryBooleanValid": 25, + "getDictionaryBooleanWithNull": 25, + "getDictionaryBooleanWithString": 25, + "getDictionaryIntegerValid": 25, + "getDictionaryIntegerWithNull": 25, + "getDictionaryIntegerWithString": 25, + "getDictionaryLongValid": 25, + "getDictionaryLongWithNull": 25, + "getDictionaryLongWithString": 25, + "getDictionaryFloatValid": 25, + "getDictionaryFloatWithNull": 25, + "getDictionaryFloatWithString": 25, + "getDictionaryDoubleValid": 25, + "getDictionaryDoubleWithNull": 25, + "getDictionaryDoubleWithString": 25, + "getDictionaryStringValid": 25, + "getDictionaryStringWithNull": 25, + "getDictionaryStringWithNumber": 25, + "getDictionaryDateValid": 25, + "getDictionaryDateWithNull": 25, + "getDictionaryDateWithInvalidChars": 25, + "getDictionaryDateTimeValid": 25, + "getDictionaryDateTimeWithNull": 25, + "getDictionaryDateTimeWithInvalidChars": 25, + "getDictionaryDateTimeRfc1123Valid": 25, + "getDictionaryDurationValid": 25, + "getDictionaryByteValid": 25, + "getDictionaryByteWithNull": 25, + "putDictionaryBooleanValid": 25, + "putDictionaryIntegerValid": 25, + "putDictionaryLongValid": 25, + "putDictionaryFloatValid": 25, + "putDictionaryDoubleValid": 25, + "putDictionaryStringValid": 25, + "putDictionaryDateValid": 25, + "putDictionaryDateTimeValid": 25, + "putDictionaryDateTimeRfc1123Valid": 25, + "putDictionaryDurationValid": 25, + "putDictionaryByteValid": 25, + "getDictionaryComplexNull": 25, + "getDictionaryComplexEmpty": 25, + "getDictionaryComplexItemNull": 25, + "getDictionaryComplexItemEmpty": 25, + "getDictionaryComplexValid": 25, + "putDictionaryComplexValid": 25, + "getDictionaryArrayNull": 25, + "getDictionaryArrayEmpty": 25, + "getDictionaryArrayItemNull": 30, + "getDictionaryArrayItemEmpty": 20, + "getDictionaryArrayValid": 25, + "putDictionaryArrayValid": 25, + "getDictionaryDictionaryNull": 25, + "getDictionaryDictionaryEmpty": 25, + "getDictionaryDictionaryItemNull": 25, + "getDictionaryDictionaryItemEmpty": 25, + "getDictionaryDictionaryValid": 25, + "putDictionaryDictionaryValid": 25, + "putDurationPositive": 43, + "getDurationNull": 43, + "getDurationInvalid": 43, + "getDurationPositive": 43, + "HeaderParameterExistingKey": 24, + "HeaderResponseExistingKey": 24, + "HeaderResponseProtectedKey": 24, + "HeaderParameterIntegerPositive": 24, + "HeaderParameterIntegerNegative": 24, + "HeaderParameterLongPositive": 24, + "HeaderParameterLongNegative": 24, + "HeaderParameterFloatPositive": 24, + "HeaderParameterFloatNegative": 24, + "HeaderParameterDoublePositive": 24, + "HeaderParameterDoubleNegative": 24, + "HeaderParameterBoolTrue": 24, + "HeaderParameterBoolFalse": 24, + "HeaderParameterStringValid": 24, + "HeaderParameterStringNull": 24, + "HeaderParameterStringEmpty": 24, + "HeaderParameterDateValid": 24, + "HeaderParameterDateMin": 24, + "HeaderParameterDateTimeValid": 24, + "HeaderParameterDateTimeMin": 24, + "HeaderParameterDateTimeRfc1123Valid": 24, + "HeaderParameterDateTimeRfc1123Min": 24, + "HeaderParameterBytesValid": 24, + "HeaderParameterDurationValid": 24, + "HeaderResponseIntegerPositive": 24, + "HeaderResponseIntegerNegative": 24, + "HeaderResponseLongPositive": 24, + "HeaderResponseLongNegative": 24, + "HeaderResponseFloatPositive": 24, + "HeaderResponseFloatNegative": 24, + "HeaderResponseDoublePositive": 24, + "HeaderResponseDoubleNegative": 24, + "HeaderResponseBoolTrue": 24, + "HeaderResponseBoolFalse": 24, + "HeaderResponseStringValid": 24, + "HeaderResponseStringNull": 24, + "HeaderResponseStringEmpty": 24, + "HeaderParameterEnumValid": 48, + "HeaderParameterEnumNull": 24, + "HeaderResponseEnumValid": 24, + "HeaderResponseEnumNull": 24, + "HeaderResponseDateValid": 24, + "HeaderResponseDateMin": 24, + "HeaderResponseDateTimeValid": 24, + "HeaderResponseDateTimeMin": 24, + "HeaderResponseDateTimeRfc1123Valid": 24, + "HeaderResponseDateTimeRfc1123Min": 24, + "HeaderResponseBytesValid": 24, + "HeaderResponseDurationValid": 24, + "ConstantsInPath": 24, + "ConstantsInBody": 24, + "CustomBaseUri": 35, + "CustomBaseUriMoreOptions": 20, + "getModelFlattenArray": 19, + "putModelFlattenArray": 19, + "getModelFlattenDictionary": 19, + "putModelFlattenDictionary": 19, + "getModelFlattenResourceCollection": 19, + "putModelFlattenResourceCollection": 19, + "putModelFlattenCustomBase": 19, + "postModelFlattenCustomParameter": 19, + "putModelFlattenCustomGroupedParameter": 19, + "getArrayBase64Url": 30, + "getDictionaryBase64Url": 25, + "UrlPathsStringBase64Url": 24, + "UrlPathsArrayCSVInPath": 24, + "getUnixTime": 24, + "getInvalidUnixTime": 24, + "getNullUnixTime": 24, + "putUnixTime": 24, + "UrlPathsIntUnixTime": 24, + "expectedEnum": 25, + "unexpectedEnum": 25, + "allowedValueEnum": 25, + "roundTripEnum": 25, + "expectedNoErrors": 36, + "expectedPetSadError": 72, + "expectedPetHungryError": 18, + "intError": 18, + "stringError": 18, + "animalNotFoundError": 18, + "linkNotFoundError": 18, + "getDateTimeMinLocalNoOffset": 25, + "getComplexPolymorphismDotSyntax": 25, + "getComposedWithDiscriminator": 25, + "getComposedWithoutDiscriminator": 25, + "FileStreamNonempty": 68, + "FileStreamVeryLarge": 25, + "FileStreamEmpty": 44, + "HttpSuccess200Head": 60, + "HttpSuccess200Get": 24, + "HttpSuccess200Put": 24, + "HttpSuccess200Post": 24, + "HttpSuccess200Patch": 24, + "HttpSuccess200Delete": 24, + "HttpSuccess201Put": 24, + "HttpSuccess201Post": 24, + "HttpSuccess202Put": 24, + "HttpSuccess202Post": 24, + "HttpSuccess202Patch": 24, + "HttpSuccess202Delete": 24, + "HttpSuccess204Head": 60, + "HttpSuccess404Head": 60, + "HttpSuccess204Put": 24, + "HttpSuccess204Post": 24, + "HttpSuccess204Patch": 24, + "HttpSuccess204Delete": 24, + "HttpRedirect300Head": 24, + "HttpRedirect300Get": 24, + "HttpRedirect301Put": 24, + "HttpRedirect301Get": 24, + "HttpRedirect302Head": 24, + "HttpRedirect302Get": 24, + "HttpRedirect302Patch": 24, + "HttpRedirect303Post": 24, + "HttpRedirect307Head": 24, + "HttpRedirect307Get": 24, + "HttpRedirect307Put": 24, + "HttpRedirect307Post": 24, + "HttpRedirect307Patch": 24, + "HttpRedirect307Delete": 24, + "HttpRetry408Head": 24, + "HttpRetry500Put": 24, + "HttpRetry500Patch": 24, + "HttpRetry502Get": 24, + "HttpRetry503Post": 24, + "HttpRetry503Delete": 24, + "HttpRetry504Put": 24, + "HttpRetry504Patch": 24, + "HttpClientFailure400Head": 24, + "HttpClientFailure400Get": 24, + "HttpClientFailure400Put": 24, + "HttpClientFailure400Post": 24, + "HttpClientFailure400Patch": 24, + "HttpClientFailure400Delete": 24, + "HttpClientFailure401Head": 24, + "HttpClientFailure402Get": 24, + "HttpClientFailure403Get": 24, + "HttpClientFailure404Put": 24, + "HttpClientFailure405Patch": 24, + "HttpClientFailure406Post": 24, + "HttpClientFailure407Delete": 24, + "HttpClientFailure409Put": 24, + "HttpClientFailure410Head": 24, + "HttpClientFailure411Get": 24, + "HttpClientFailure412Get": 24, + "HttpClientFailure413Put": 24, + "HttpClientFailure414Patch": 24, + "HttpClientFailure415Post": 24, + "HttpClientFailure416Get": 24, + "HttpClientFailure417Delete": 24, + "HttpClientFailure429Head": 96, + "HttpServerFailure501Head": 24, + "HttpServerFailure501Get": 24, + "HttpServerFailure505Post": 24, + "HttpServerFailure505Delete": 24, + "ResponsesScenarioA200MatchingModel": 24, + "ResponsesScenarioA204MatchingNoModel": 24, + "ResponsesScenarioA201DefaultNoModel": 24, + "ResponsesScenarioA202DefaultNoModel": 24, + "ResponsesScenarioA400DefaultModel": 24, + "ResponsesScenarioB200MatchingModel": 24, + "ResponsesScenarioB201MatchingModel": 24, + "ResponsesScenarioB400DefaultModel": 24, + "ResponsesScenarioC200MatchingModel": 24, + "ResponsesScenarioC201MatchingModel": 24, + "ResponsesScenarioC404MatchingModel": 24, + "ResponsesScenarioC400DefaultModel": 24, + "ResponsesScenarioD202MatchingNoModel": 24, + "ResponsesScenarioD204MatchingNoModel": 24, + "ResponsesScenarioD400DefaultModel": 24, + "ResponsesScenarioE202MatchingInvalid": 24, + "ResponsesScenarioE204MatchingNoModel": 24, + "ResponsesScenarioE400DefaultNoModel": 24, + "ResponsesScenarioE400DefaultInvalid": 24, + "ResponsesScenarioF200DefaultModel": 48, + "ResponsesScenarioF200DefaultNone": 48, + "ResponsesScenarioF400DefaultModel": 19, + "ResponsesScenarioF400DefaultNone": 19, + "ResponsesScenarioG200DefaultInvalid": 29, + "ResponsesScenarioG200DefaultNoModel": 19, + "ResponsesScenarioG400DefaultInvalid": 24, + "ResponsesScenarioG400DefaultNoModel": 24, + "ResponsesScenarioH200MatchingNone": 24, + "ResponsesScenarioH200MatchingModel": 24, + "ResponsesScenarioH200MatchingInvalid": 24, + "ResponsesScenarioH400NonMatchingNone": 24, + "ResponsesScenarioH400NonMatchingModel": 24, + "ResponsesScenarioH400NonMatchingInvalid": 24, + "ResponsesScenarioH202NonMatchingModel": 24, + "ResponsesScenarioEmptyErrorBody": 24, + "ResponsesScenarioNoModelErrorBody": 24, + "MediaTypeJson": 24, + "MediaTypePdf": 24, + "MediaTypeWithEncoding": 24, + "StorageListContainersXML": 23, + "StorageGetServicePropertiesXML": 23, + "StoragePutServicePropertiesXML": 23, + "StorageGetContainerACLXML": 23, + "StorageListBlobsXML": 23, + "StoragePutContainerACLXML": 23, + "GetSimpleXML": 24, + "PutSimpleXML": 24, + "GetWrappedXMLList": 24, + "PutWrappedXMLList": 24, + "GetEmptyXMLList": 24, + "PutEmptyXMLList": 24, + "GetEmptyWrappedXMLList": 24, + "PutEmptyWrappedXMLList": 24, + "GetXMLListAtRoot": 24, + "PutXMLListAtRoot": 24, + "GetXMLListAtRootSingle": 24, + "PutXMLListAtRootSingle": 24, + "GetEmptyXMLListAtRoot": 29, + "PutEmptyXMLListAtRoot": 24, + "GetXMLEmptyNode": 24, + "PutXMLEmptyNode": 24, + "GetRootWithRefAndNoMetaXML": 24, + "PutRootWithRefAndNoMetaXML": 24, + "GetRootWithRefAndMetaXML": 23, + "PutRootWithRefAndMetaXML": 23, + "jsonInputInXMLSwagger": 24, + "jsonOutputInXMLSwagger": 24, + "GetWithXMsText": 23, + "ObjectTypeResponse": 24, + "ObjectTypePut": 24, + "ObjectTypeErrorResponse": 24, + "NonStringEnumsPostInt": 24, + "NonStringEnumsGetInt": 24, + "NonStringEnumsPostFloat": 24, + "NonStringEnumsGetFloat": 24, + "BodyTimeGet": 24, + "BodyTimePut": 24, + "MultipleInheritancePetGet": 24, + "MultipleInheritancePetPut": 24, + "MultipleInheritanceHorseGet": 24, + "MultipleInheritanceHorsePut": 24, + "MultipleInheritanceFelineGet": 24, + "MultipleInheritanceFelinePut": 24, + "MultipleInheritanceCatGet": 24, + "MultipleInheritanceCatPut": 24, + "MultipleInheritanceKittenGet": 24, + "MultipleInheritanceKittenPut": 24, + "OptionalIntegerParameter": 24, + "OptionalIntegerProperty": 24, + "OptionalIntegerHeader": 24, + "OptionalStringParameter": 24, + "OptionalStringProperty": 24, + "OptionalStringHeader": 24, + "OptionalClassParameter": 24, + "OptionalClassProperty": 24, + "OptionalArrayParameter": 24, + "OptionalArrayProperty": 24, + "OptionalArrayHeader": 24 +} \ No newline at end of file diff --git a/test/azure/low-level/requirements.txt b/test/azure/low-level/requirements.txt new file mode 100644 index 00000000000..f950466a439 --- /dev/null +++ b/test/azure/low-level/requirements.txt @@ -0,0 +1,22 @@ +requests>=2.14.0 +pytest +pytest-cov +pytest-asyncio==0.14.0;python_full_version>="3.5.2" +async_generator;python_full_version>="3.5.2" +azure-core>=1.8.2 +azure-mgmt-core>=1.2.1 +msrest>=0.6.21 +aiohttp;python_full_version>="3.5.2" +-e ./Expected/AcceptanceTests/AzureBodyDurationLowLevel +-e ./Expected/AcceptanceTests/AzureParameterGroupingLowLevel +-e ./Expected/AcceptanceTests/AzureReportLowLevel +-e ./Expected/AcceptanceTests/AzureSpecialsLowLevel +-e ./Expected/AcceptanceTests/CustomBaseUriLowLevel +-e ./Expected/AcceptanceTests/CustomUrlPagingLowLevel +-e ./Expected/AcceptanceTests/HeadLowLevel +-e ./Expected/AcceptanceTests/HeadExceptionsLowLevel +-e ./Expected/AcceptanceTests/LroLowLevel +-e ./Expected/AcceptanceTests/LroWithParameterizedEndpointsLowLevel +-e ./Expected/AcceptanceTests/PagingLowLevel +-e ./Expected/AcceptanceTests/StorageManagementClientLowLevel +-e ./Expected/AcceptanceTests/SubscriptionIdApiVersionLowLevel \ No newline at end of file diff --git a/test/azure/low-level/tox.ini b/test/azure/low-level/tox.ini new file mode 100644 index 00000000000..067f256495a --- /dev/null +++ b/test/azure/low-level/tox.ini @@ -0,0 +1,18 @@ +[tox] +envlist=py27, py36 +skipsdist=True + +[testenv] +deps= + -rrequirements.txt + coverage +commands= + pytest --cov=Expected + +[testenv:ci] +deps= + -rrequirements.txt + coverage==4.5.4 + pytest-cov +commands = + pytest --cov=Expected diff --git a/test/azure/packages.config b/test/azure/packages.config deleted file mode 100644 index 2d5c663a425..00000000000 --- a/test/azure/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/test/azure/specification/custompollerpager/README.md b/test/azure/specification/custompollerpager/README.md deleted file mode 100644 index e3fefcf96cb..00000000000 --- a/test/azure/specification/custompollerpager/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Testing adding a custom poller and pager - -### Settings - -``` yaml -input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/paging.json -namespace: custompollerpager -output-folder: $(python-sdks-folder)/azure/Expected/AcceptanceTests/CustomPollerPager -package-name: custompollerpager -license-header: MICROSOFT_MIT_NO_VERSION -azure-arm: true -add-credentials: true -package-version: 0.1.0 -basic-setup-py: true -output-artifact: code-model-v4-no-tags -payload-flattening-threshold: 1 -clear-output-folder: true -``` - -### Override ItemPaged to custom Pager -``` yaml -directive: - - from: swagger-document - where: '$.paths["/paging/single"].get' - transform: > - $["x-python-custom-pager-sync"] = "custompollerpagerdefinitions.CustomPager"; - $["x-python-custom-pager-async"] = "custompollerpagerdefinitions.aio.AsyncCustomPager" -``` - -### Override LROPoller to custom Poller -``` yaml -directive: - - from: swagger-document - where: '$.paths["/paging/multiple/lro"].post' - transform: > - $["x-python-custom-poller-sync"] = "custompollerpagerdefinitions.CustomPoller"; - $["x-python-custom-poller-async"] = "custompollerpagerdefinitions.aio.AsyncCustomPoller" -``` diff --git a/test/azure/tox.ini b/test/azure/tox.ini deleted file mode 100644 index 22088fa7f12..00000000000 --- a/test/azure/tox.ini +++ /dev/null @@ -1,18 +0,0 @@ -[tox] -envlist=py27, py36 -skipsdist=True - -[testenv] -deps= - -rrequirements.txt - coverage -commands= - pytest --cov=Expected - -[testenv:ci] -deps= - -rrequirements.txt - coverage==4.5.4 - pytest-cov -commands = - pytest --cov=Expected --junitxml=test-junit-azure-{envname}.xml diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py index 42dc1490b4c..e3a8b8fcb88 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py index f2974d4ec81..1e6f86e87b7 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py @@ -10,19 +10,13 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Iterable, Optional + + from azure.core.paging import ItemPaged + from azure.core.polling import LROPoller class MultiapiServiceClientOperationsMixin(object): @@ -32,19 +26,22 @@ def begin_test_lro( product=None, # type: Optional["_models.Product"] **kwargs # type: Any ): + # type: (...) -> LROPoller["_models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. :type product: ~multiapi.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapi.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -65,6 +62,7 @@ def begin_test_lro_and_paging( test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"] **kwargs # type: Any ): + # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: @@ -73,13 +71,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapi.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapi.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -101,6 +103,7 @@ def test_different_calls( greeting_in_french=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """Has added parameters across the API versions. :param greeting_in_english: pass in 'hello' to pass test. @@ -137,6 +140,7 @@ def test_one( message=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """TestOne should be in an FirstVersionOperationsMixin. :param id: An int parameter. @@ -167,6 +171,7 @@ def test_paging( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.PagingResult"] """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_multiapi_service_client.py index b097a88ee30..ab9638f4ed2 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_multiapi_service_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py index 48def2041bc..27e7475f99e 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py @@ -9,16 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Optional -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling +from azure.core.async_paging import AsyncItemPaged +from azure.core.polling import AsyncLROPoller class MultiapiServiceClientOperationsMixin(object): @@ -34,13 +28,16 @@ async def begin_test_lro( :type product: ~multiapi.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapi.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -55,7 +52,7 @@ async def begin_test_lro( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.begin_test_lro(product, **kwargs) - def begin_test_lro_and_paging( + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None, @@ -69,13 +66,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -88,7 +89,7 @@ def begin_test_lro_and_paging( mixin_instance._serialize = Serializer(self._models_dict(api_version)) mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) - return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + return await mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) async def test_different_calls( self, @@ -162,7 +163,7 @@ async def test_one( def test_paging( self, **kwargs: Any - ) -> AsyncItemPaged["_models.PagingResult"]: + ) -> AsyncIterable["_models.PagingResult"]: """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_metadata.json index ab854483596..594cb3b4070 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_multiapi_service_client.py index ac695e9a5c3..0356341a2b2 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_multiapi_service_client.py @@ -6,22 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(object): """Service client for multiapi client testing. @@ -30,7 +30,8 @@ class MultiapiServiceClient(object): :vartype operation_group_one: multiapi.v0.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -47,26 +48,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v0.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v0._rest import operation_group_one + >>> request = operation_group_one.build_test_two_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/__init__.py new file mode 100644 index 00000000000..8e6cf7ef943 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_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. +# -------------------------------------------------------------------------- \ No newline at end of file diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..2baa4c76ce3 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "0.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..1071c641e92 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "0.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/_multiapi_service_client.py index ea118bdfc46..349b18f45df 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/_multiapi_service_client.py @@ -6,29 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MultiapiServiceClientConfiguration from .operations import OperationGroupOneOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MultiapiServiceClient(object): +class MultiapiServiceClient: """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations :vartype operation_group_one: multiapi.v0.aio.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -44,25 +45,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v0.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v0._rest import operation_group_one + >>> request = operation_group_one.build_test_two_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py index ebec8f90301..fa5246f242e 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,22 +59,13 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "0.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -83,3 +77,4 @@ async def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py index f7d9d942601..88610845ae0 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v0/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -61,22 +64,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "0.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,3 +82,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json index 0c39ff69b23..688b7914fc4 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -88,12 +88,12 @@ "operation_group_one": "OperationGroupOneOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.mgmt.core.polling.arm_polling\": [\"ARMPolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.mgmt.core.polling.async_arm_polling\": [\"AsyncARMPolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -105,55 +105,55 @@ }, "_test_lro_initial" : { "sync": { - "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.Product\"]\n", + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e Optional[\"_models.Product\"]:\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "begin_test_lro" : { "sync": { - "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapi.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.Product\"]\n", + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapi.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapi.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of\n cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapi.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "_test_lro_and_paging_initial" : { "sync": { - "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapi.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.PagingResult\"\n", + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapi.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e \"_models.PagingResult\":\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapi.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapi.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "begin_test_lro_and_paging" : { "sync": { - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapi.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[ItemPaged[\"_models.PagingResult\"]]\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapi.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { - "coroutine": false, - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "coroutine": true, + "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either\n PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_multiapi_service_client.py index 08c3b838f66..cac85d6b826 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_multiapi_service_client.py @@ -6,23 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -31,8 +30,10 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_one: multiapi.v1.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -49,26 +50,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/__init__.py new file mode 100644 index 00000000000..f9044715939 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/__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 ._request_builders_py3 import build_test_one_request + from ._request_builders_py3 import build_test_lro_request_initial + from ._request_builders_py3 import build_test_lro_and_paging_request_initial + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_lro_request_initial # type: ignore + from ._request_builders import build_test_lro_and_paging_request_initial # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_lro_request_initial', + 'build_test_lro_and_paging_request_initial', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..0212b812ffd --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/_request_builders.py @@ -0,0 +1,197 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..b9131d21981 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/_request_builders_py3.py @@ -0,0 +1,193 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..f984bfab1ee --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..7a4821c0604 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_multiapi_service_client.py index d5e2031d3fe..2be3abba6b3 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/_multiapi_service_client.py @@ -6,22 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -29,8 +28,10 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_one: multiapi.v1.aio.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -46,25 +47,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py index 880e9069a90..8233fa8d397 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,25 +47,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -76,6 +68,7 @@ async def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def _test_lro_initial( self, product: Optional["_models.Product"] = None, @@ -86,34 +79,26 @@ async def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -123,8 +108,10 @@ async def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + async def begin_test_lro( self, product: Optional["_models.Product"] = None, @@ -136,13 +123,16 @@ async def begin_test_lro( :type product: ~multiapi.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapi.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -160,8 +150,10 @@ async def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -182,6 +174,7 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + async def _test_lro_and_paging_initial( self, client_request_id: Optional[str] = None, @@ -193,32 +186,21 @@ async def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,8 +213,10 @@ async def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, @@ -247,49 +231,55 @@ async def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -306,8 +296,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -352,6 +342,7 @@ async def internal_get_next(next_link=None): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -371,23 +362,14 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,3 +381,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py index 38fe254146e..73bdd752821 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,22 +59,13 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -83,3 +77,4 @@ async def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py index 703bd18f819..33715f6e704 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -50,25 +52,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -81,6 +73,7 @@ def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def _test_lro_initial( self, product=None, # type: Optional["_models.Product"] @@ -92,34 +85,26 @@ def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -129,8 +114,10 @@ def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + def begin_test_lro( self, product=None, # type: Optional["_models.Product"] @@ -143,13 +130,15 @@ def begin_test_lro( :type product: ~multiapi.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapi.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -167,8 +156,10 @@ def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -189,6 +180,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + def _test_lro_and_paging_initial( self, client_request_id=None, # type: Optional[str] @@ -201,32 +193,21 @@ def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,8 +220,10 @@ def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def begin_test_lro_and_paging( self, client_request_id=None, # type: Optional[str] @@ -256,49 +239,55 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapi.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapi.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -315,8 +304,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -361,6 +350,7 @@ def internal_get_next(next_link=None): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -381,23 +371,14 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,3 +390,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py index 66da9b3e93a..0c8980863bd 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -61,22 +64,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,3 +82,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json index cd8189fced7..84bc38707da 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,12 +89,12 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.ModelTwo\"\n", "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapi.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -106,7 +106,7 @@ }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_multiapi_service_client.py index f1e2e5e6988..549add6da93 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapi.v2.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/__init__.py new file mode 100644 index 00000000000..47d95873c6d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_one_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..248aec13bdf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/_request_builders.py @@ -0,0 +1,113 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4cda774bfa7 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/_request_builders_py3.py @@ -0,0 +1,106 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..a1c3ce0967d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/__init__.py @@ -0,0 +1,19 @@ +# 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_test_two_request + from ._request_builders_py3 import build_test_three_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + from ._request_builders import build_test_three_request # type: ignore + +__all__ = [ + 'build_test_two_request', + 'build_test_three_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..aceec5b3a50 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,103 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_three_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..dc51f344320 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,101 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_three_request( + **kwargs: Any +) -> HttpRequest: + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..40936059a53 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/__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_test_four_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + +__all__ = [ + 'build_test_four_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..beab509ad89 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + parameter_one = kwargs.pop('parameter_one') # type: bool + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..ad79a8caadf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + parameter_one: bool, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_multiapi_service_client.py index ba9e3f14f69..502d50fa92f 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/_multiapi_service_client.py @@ -6,23 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -32,7 +30,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapi.v2.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +47,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py index 106a7d1ea0f..017573ca44c 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,25 +44,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -74,8 +66,10 @@ async def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -98,25 +92,15 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,3 +112,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py index f1d832d6f77..9503db97408 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +90,10 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + async def test_three( self, **kwargs: Any @@ -114,22 +110,13 @@ async def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,3 +128,4 @@ async def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py index 6cb55c7a26d..ba76784b706 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,23 +62,14 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,3 +81,4 @@ async def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py index 22f15312362..0443c55edb5 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -47,25 +49,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -79,8 +71,10 @@ def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -104,25 +98,15 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,3 +118,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py index 4dfee7c8c0c..dd4ebd3afd8 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,8 +95,10 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + def test_three( self, **kwargs # type: Any @@ -120,22 +116,13 @@ def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,3 +134,4 @@ def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py index 13f1695a670..9b7de1c3741 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,23 +67,14 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,3 +86,4 @@ def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json index b8fb8054929..037e47f530a 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,24 +89,24 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_paging" : { "sync": { - "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.PagingResult\"]\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~multiapi.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n", + "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.PagingResult\"]:\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapi.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_multiapi_service_client.py index b24fea56624..694bad85d57 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapi.v3.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/__init__.py new file mode 100644 index 00000000000..ac71d77c963 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_paging_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_paging_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_paging_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/_request_builders.py new file mode 100644 index 00000000000..51330488a14 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/_request_builders.py @@ -0,0 +1,102 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + greeting_in_french = kwargs.pop('greeting_in_french', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..ddae7737619 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/_request_builders_py3.py @@ -0,0 +1,95 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_paging_request( + **kwargs: Any +) -> HttpRequest: + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..689e60edb0d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..ffa8d8ef82c --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..c9663b12265 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/__init__.py @@ -0,0 +1,19 @@ +# 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_test_four_request + from ._request_builders_py3 import build_test_five_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + from ._request_builders import build_test_five_request # type: ignore + +__all__ = [ + 'build_test_four_request', + 'build_test_five_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..bca245b1aff --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,106 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_five_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..1dc882231b0 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_five_request( + **kwargs: Any +) -> HttpRequest: + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_multiapi_service_client.py index a2606d0882f..a8f7d231448 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/_multiapi_service_client.py @@ -6,23 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -32,7 +30,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapi.v3.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +47,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapi.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapi.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py index 58164d37ce1..c3738e040f0 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,24 +39,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -71,8 +71,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -106,27 +106,16 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,3 +127,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py index 65aeba63f10..b152abf0699 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,4 +90,6 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py index 424e0aa1a72..961d9f58899 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, IO, 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,8 +52,9 @@ async def test_four( :param input: Input parameter. :type input: IO or ~multiapi.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -61,38 +65,30 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,6 +101,7 @@ async def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + async def test_five( self, **kwargs: Any @@ -121,22 +118,13 @@ async def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,3 +136,4 @@ async def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py index 9aaf7b9345f..0707c3d2ea7 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -42,24 +44,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -76,8 +76,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -112,27 +112,16 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,3 +133,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py index ff0ec3e3732..2ce1f7762b4 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,4 +95,6 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py index c1ca76696c8..1012c690485 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,8 +57,9 @@ def test_four( :param input: Input parameter. :type input: IO or ~multiapi.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -66,38 +70,30 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,6 +106,7 @@ def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + def test_five( self, **kwargs # type: Any @@ -127,22 +124,13 @@ def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,3 +142,4 @@ def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py index 59038eadbd6..9067086b7bd 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import AzureKeyCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py index fa7519b1c58..4da7076819d 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py @@ -10,19 +10,13 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Iterable, Optional + + from azure.core.paging import ItemPaged + from azure.core.polling import LROPoller class MultiapiServiceClientOperationsMixin(object): @@ -32,19 +26,22 @@ def begin_test_lro( product=None, # type: Optional["_models.Product"] **kwargs # type: Any ): + # type: (...) -> LROPoller["_models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. :type product: ~multiapicredentialdefaultpolicy.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapicredentialdefaultpolicy.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -65,21 +62,27 @@ def begin_test_lro_and_paging( test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"] **kwargs # type: Any ): + # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -101,6 +104,7 @@ def test_different_calls( greeting_in_french=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """Has added parameters across the API versions. :param greeting_in_english: pass in 'hello' to pass test. @@ -137,6 +141,7 @@ def test_one( message=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """TestOne should be in an FirstVersionOperationsMixin. :param id: An int parameter. @@ -167,6 +172,7 @@ def test_paging( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.PagingResult"] """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_multiapi_service_client.py index e62c7032845..8ecaf61c23c 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_multiapi_service_client.py @@ -12,7 +12,6 @@ from typing import Any, Optional from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py index 37035258756..77c555417c0 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py @@ -9,16 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Optional -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling +from azure.core.async_paging import AsyncItemPaged +from azure.core.polling import AsyncLROPoller class MultiapiServiceClientOperationsMixin(object): @@ -34,13 +28,16 @@ async def begin_test_lro( :type product: ~multiapicredentialdefaultpolicy.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapicredentialdefaultpolicy.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -55,7 +52,7 @@ async def begin_test_lro( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.begin_test_lro(product, **kwargs) - def begin_test_lro_and_paging( + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None, @@ -66,16 +63,21 @@ def begin_test_lro_and_paging( :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -88,7 +90,7 @@ def begin_test_lro_and_paging( mixin_instance._serialize = Serializer(self._models_dict(api_version)) mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) - return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + return await mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) async def test_different_calls( self, @@ -162,12 +164,13 @@ async def test_one( def test_paging( self, **kwargs: Any - ) -> AsyncItemPaged["_models.PagingResult"]: + ) -> AsyncIterable["_models.PagingResult"]: """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult] :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('test_paging') diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json index 5327ff12d87..4a44386ef8f 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}", - "async_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}" + "sync_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}", + "async_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}" }, "global_parameters": { "sync": { @@ -88,12 +88,12 @@ "operation_group_one": "OperationGroupOneOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.mgmt.core.polling.arm_polling\": [\"ARMPolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.mgmt.core.polling.async_arm_polling\": [\"AsyncARMPolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -105,55 +105,55 @@ }, "_test_lro_initial" : { "sync": { - "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.Product\"]\n", + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e Optional[\"_models.Product\"]:\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "begin_test_lro" : { "sync": { - "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapicredentialdefaultpolicy.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.Product\"]\n", + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapicredentialdefaultpolicy.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapicredentialdefaultpolicy.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapicredentialdefaultpolicy.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of\n cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapicredentialdefaultpolicy.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "_test_lro_and_paging_initial" : { "sync": { - "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.PagingResult\"\n", + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e \"_models.PagingResult\":\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "begin_test_lro_and_paging" : { "sync": { - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[ItemPaged[\"_models.PagingResult\"]]\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { - "coroutine": false, - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "coroutine": true, + "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either\n PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_multiapi_service_client.py index f9a0179ab92..b48a4e5b08a 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_multiapi_service_client.py @@ -6,33 +6,35 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import AzureKeyCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapicredentialdefaultpolicy.v1.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapicredentialdefaultpolicy.v1.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -49,26 +51,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicredentialdefaultpolicy.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicredentialdefaultpolicy.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/__init__.py new file mode 100644 index 00000000000..f9044715939 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/__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 ._request_builders_py3 import build_test_one_request + from ._request_builders_py3 import build_test_lro_request_initial + from ._request_builders_py3 import build_test_lro_and_paging_request_initial + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_lro_request_initial # type: ignore + from ._request_builders import build_test_lro_and_paging_request_initial # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_lro_request_initial', + 'build_test_lro_and_paging_request_initial', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..0212b812ffd --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/_request_builders.py @@ -0,0 +1,197 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..b9131d21981 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/_request_builders_py3.py @@ -0,0 +1,193 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..f984bfab1ee --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..7a4821c0604 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_multiapi_service_client.py index d23b46db5fc..7da74a57ae1 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/_multiapi_service_client.py @@ -6,28 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from copy import deepcopy +from typing import Any, Awaitable, Optional from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations from .. import models - +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapicredentialdefaultpolicy.v1.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapicredentialdefaultpolicy.v1.aio.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -43,25 +45,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicredentialdefaultpolicy.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicredentialdefaultpolicy.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py index c95eba98a79..ceafa3364c9 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,25 +47,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -76,6 +68,7 @@ async def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def _test_lro_initial( self, product: Optional["_models.Product"] = None, @@ -86,34 +79,26 @@ async def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -123,8 +108,10 @@ async def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + async def begin_test_lro( self, product: Optional["_models.Product"] = None, @@ -136,13 +123,16 @@ async def begin_test_lro( :type product: ~multiapicredentialdefaultpolicy.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapicredentialdefaultpolicy.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -160,8 +150,10 @@ async def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -182,6 +174,7 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + async def _test_lro_and_paging_initial( self, client_request_id: Optional[str] = None, @@ -193,32 +186,21 @@ async def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,8 +213,10 @@ async def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, @@ -244,52 +228,59 @@ async def begin_test_lro_and_paging( :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -306,8 +297,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -352,6 +343,7 @@ async def internal_get_next(next_link=None): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -371,23 +363,14 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,3 +382,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py index 4370288b903..93bfe89ab0b 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,22 +59,13 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -83,3 +77,4 @@ async def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py index 95d141b401b..999c6aa22f4 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -50,25 +52,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -81,6 +73,7 @@ def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def _test_lro_initial( self, product=None, # type: Optional["_models.Product"] @@ -92,34 +85,26 @@ def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -129,8 +114,10 @@ def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + def begin_test_lro( self, product=None, # type: Optional["_models.Product"] @@ -143,13 +130,15 @@ def begin_test_lro( :type product: ~multiapicredentialdefaultpolicy.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapicredentialdefaultpolicy.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -167,8 +156,10 @@ def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -189,6 +180,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + def _test_lro_and_paging_initial( self, client_request_id=None, # type: Optional[str] @@ -201,32 +193,21 @@ def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,8 +220,10 @@ def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def begin_test_lro_and_paging( self, client_request_id=None, # type: Optional[str] @@ -253,52 +236,59 @@ def begin_test_lro_and_paging( :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -315,8 +305,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -361,6 +351,7 @@ def internal_get_next(next_link=None): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -381,23 +372,14 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,3 +391,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py index 486b070ecb6..b2e543ac4fe 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -61,22 +64,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,3 +82,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json index 7db7849a80f..7f0eadc658b 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}", - "async_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}" + "sync_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}", + "async_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}" }, "global_parameters": { "sync": { @@ -89,12 +89,12 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.ModelTwo\"\n", "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -106,7 +106,7 @@ }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_multiapi_service_client.py index aedbe98e34d..112167facbe 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_multiapi_service_client.py @@ -6,35 +6,36 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import AzureKeyCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapicredentialdefaultpolicy.v2.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapicredentialdefaultpolicy.v2.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapicredentialdefaultpolicy.v2.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapicredentialdefaultpolicy.v2.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +52,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicredentialdefaultpolicy.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicredentialdefaultpolicy.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/__init__.py new file mode 100644 index 00000000000..47d95873c6d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_one_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..248aec13bdf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/_request_builders.py @@ -0,0 +1,113 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4cda774bfa7 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/_request_builders_py3.py @@ -0,0 +1,106 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..a1c3ce0967d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/__init__.py @@ -0,0 +1,19 @@ +# 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_test_two_request + from ._request_builders_py3 import build_test_three_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + from ._request_builders import build_test_three_request # type: ignore + +__all__ = [ + 'build_test_two_request', + 'build_test_three_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..aceec5b3a50 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,103 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_three_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..dc51f344320 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,101 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_three_request( + **kwargs: Any +) -> HttpRequest: + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..40936059a53 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/__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_test_four_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + +__all__ = [ + 'build_test_four_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..beab509ad89 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + parameter_one = kwargs.pop('parameter_one') # type: bool + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..ad79a8caadf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + parameter_one: bool, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_multiapi_service_client.py index d43607fdfb2..9209c3650f2 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/_multiapi_service_client.py @@ -6,30 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from copy import deepcopy +from typing import Any, Awaitable, Optional from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations from .. import models - +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapicredentialdefaultpolicy.v2.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapicredentialdefaultpolicy.v2.aio.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapicredentialdefaultpolicy.v2.aio.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapicredentialdefaultpolicy.v2.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -45,27 +46,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicredentialdefaultpolicy.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicredentialdefaultpolicy.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py index bb61811609d..f412ea647fe 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,25 +44,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -74,8 +66,10 @@ async def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -98,25 +92,15 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,3 +112,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py index cb2991fc629..0f213328c49 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +90,10 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + async def test_three( self, **kwargs: Any @@ -114,22 +110,13 @@ async def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,3 +128,4 @@ async def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py index 386e78df1d4..5ab8748312c 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,23 +62,14 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,3 +81,4 @@ async def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py index e45f424a9b2..b109d0d60d1 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -47,25 +49,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -79,8 +71,10 @@ def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -104,25 +98,15 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,3 +118,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py index 86f20d3b46f..79b382b2135 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,8 +95,10 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + def test_three( self, **kwargs # type: Any @@ -120,22 +116,13 @@ def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,3 +134,4 @@ def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py index 52c92f79d8b..1ee4293b26f 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,23 +67,14 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,3 +86,4 @@ def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json index 346c56c272e..a5796547fef 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}", - "async_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}" + "sync_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}", + "async_imports": "{\"conditional\": {\"azurecore\": {\"azure.core.credentials\": [\"AzureKeyCredential\"]}, \"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}}" }, "global_parameters": { "sync": { @@ -89,24 +89,24 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_paging" : { "sync": { - "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.PagingResult\"]\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n", - "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.PagingResult\"]:\n", + "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_multiapi_service_client.py index 5fa699dcccb..07a58a8eeb1 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_multiapi_service_client.py @@ -6,35 +6,36 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import AzureKeyCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapicredentialdefaultpolicy.v3.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapicredentialdefaultpolicy.v3.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapicredentialdefaultpolicy.v3.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapicredentialdefaultpolicy.v3.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +52,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicredentialdefaultpolicy.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicredentialdefaultpolicy.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/__init__.py new file mode 100644 index 00000000000..ac71d77c963 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_paging_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_paging_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_paging_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/_request_builders.py new file mode 100644 index 00000000000..51330488a14 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/_request_builders.py @@ -0,0 +1,102 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + greeting_in_french = kwargs.pop('greeting_in_french', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..ddae7737619 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/_request_builders_py3.py @@ -0,0 +1,95 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_paging_request( + **kwargs: Any +) -> HttpRequest: + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..689e60edb0d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..ffa8d8ef82c --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..c9663b12265 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/__init__.py @@ -0,0 +1,19 @@ +# 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_test_four_request + from ._request_builders_py3 import build_test_five_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + from ._request_builders import build_test_five_request # type: ignore + +__all__ = [ + 'build_test_four_request', + 'build_test_five_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..bca245b1aff --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,106 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_five_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..1dc882231b0 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_five_request( + **kwargs: Any +) -> HttpRequest: + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_multiapi_service_client.py index 12c2ad05e2c..2c075c6edab 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/_multiapi_service_client.py @@ -6,30 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from copy import deepcopy +from typing import Any, Awaitable, Optional from azure.core.credentials import AzureKeyCredential -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations from .. import models - +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapicredentialdefaultpolicy.v3.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapicredentialdefaultpolicy.v3.aio.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapicredentialdefaultpolicy.v3.aio.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapicredentialdefaultpolicy.v3.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -45,27 +46,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicredentialdefaultpolicy.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicredentialdefaultpolicy.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py index 5a058c6e5da..259d984a7b5 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -29,7 +31,8 @@ def test_paging( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] @@ -37,24 +40,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -71,8 +72,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -106,27 +107,16 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,3 +128,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py index d24d7731d20..3ab49d0aca0 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,4 +90,6 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py index 8d04ee2c54a..d561345dcd6 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, IO, 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,8 +52,9 @@ async def test_four( :param input: Input parameter. :type input: IO or ~multiapicredentialdefaultpolicy.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -61,38 +65,30 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,6 +101,7 @@ async def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + async def test_five( self, **kwargs: Any @@ -121,22 +118,13 @@ async def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,3 +136,4 @@ async def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py index 472d51b348a..b9bb37c8913 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -42,24 +44,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -76,8 +76,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -112,27 +112,16 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,3 +133,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py index 031e8fd3a9a..c31cea10349 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,4 +95,6 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py index 12027e7ece4..4e17de5ceef 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,8 +57,9 @@ def test_four( :param input: Input parameter. :type input: IO or ~multiapicredentialdefaultpolicy.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -66,38 +70,30 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,6 +106,7 @@ def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + def test_five( self, **kwargs # type: Any @@ -127,22 +124,13 @@ def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,3 +142,4 @@ def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py index d9e009cd8a1..ed569f49245 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_operations_mixin.py index 5f2f70aa76f..7f06fd2c8d4 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_operations_mixin.py @@ -10,15 +10,10 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer 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 HttpRequest, HttpResponse if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + from typing import Any class MultiapiCustomBaseUrlServiceClientOperationsMixin(object): @@ -28,6 +23,7 @@ def test( id, # type: int **kwargs # type: Any ): + # type: (...) -> None """Should be a mixin operation. Put in 2 for the required parameter and have the correct api version of 2.0.0 to pass. diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py index dc512987ead..972947c53fb 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py @@ -12,7 +12,6 @@ from typing import Any, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from msrest import Deserializer, Serializer @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_operations_mixin.py index b8566af3749..26d6b425baa 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_operations_mixin.py @@ -9,12 +9,7 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -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, HttpRequest +from typing import Any class MultiapiCustomBaseUrlServiceClientOperationsMixin(object): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json index ca91748a983..c1303f1276f 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": false, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -87,12 +87,12 @@ "operation_groups": { }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}", "operations": { "test" : { "sync": { - "signature": "def test(\n self,\n id, # type: int\n **kwargs # type: Any\n):\n", + "signature": "def test(\n self,\n id, # type: int\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Should be a mixin operation. Put in 1 for the required parameter and have the correct api\nversion of 1.0.0 to pass.\n\n:param id: An int parameter. Put in 1 to pass.\n:type id: int\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_multiapi_custom_base_url_service_client.py index 3d53bd917ee..c7ebee2a8c8 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_multiapi_custom_base_url_service_client.py @@ -6,22 +6,22 @@ # 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 MultiapiCustomBaseUrlServiceClientConfiguration +from .operations import MultiapiCustomBaseUrlServiceClientOperationsMixin + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration -from .operations import MultiapiCustomBaseUrlServiceClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiCustomBaseUrlServiceClient(MultiapiCustomBaseUrlServiceClientOperationsMixin): """Service client for multiapi custom base url testing. @@ -45,27 +45,45 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicustombaseurl.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicustombaseurl.v1._rest import build_test_request + >>> request = build_test_request(id=id, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ + + request_copy = deepcopy(request) path_format_arguments = { 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/__init__.py new file mode 100644 index 00000000000..5b359d8437f --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/__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_test_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_request # type: ignore + +__all__ = [ + 'build_test_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..d9d7958c7ae --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/_request_builders.py @@ -0,0 +1,62 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Should be a mixin operation. Put in 1 for the required parameter and have the correct api + version of 1.0.0 to pass. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. Put in 1 to pass. + :paramtype id: int + :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 + """ + + id = kwargs.pop('id') # type: int + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/test') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..bcf03b7e6e7 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_rest/_request_builders_py3.py @@ -0,0 +1,56 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_request( + *, + id: int, + **kwargs: Any +) -> HttpRequest: + """Should be a mixin operation. Put in 1 for the required parameter and have the correct api + version of 1.0.0 to pass. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. Put in 1 to pass. + :paramtype id: int + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/test') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_multiapi_custom_base_url_service_client.py index 89da4313acb..06d986f01f4 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/_multiapi_custom_base_url_service_client.py @@ -6,20 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration from .operations import MultiapiCustomBaseUrlServiceClientOperationsMixin -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential class MultiapiCustomBaseUrlServiceClient(MultiapiCustomBaseUrlServiceClientOperationsMixin): """Service client for multiapi custom base url testing. @@ -42,26 +42,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicustombaseurl.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicustombaseurl.v1._rest import build_test_request + >>> request = build_test_request(id=id, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ + + request_copy = deepcopy(request) path_format_arguments = { 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py index fd96234c28a..bffa81ce944 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py @@ -5,14 +5,16 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,27 +41,17 @@ async def test( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test.metadata['url'] # type: ignore + + request = rest.build_test_request( + id=id, + template_url=self.test.metadata['url'], + )._to_pipeline_transport_request() path_format_arguments = { - 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request.url = self._client.format_url(request.url, **path_format_arguments) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -71,3 +63,4 @@ async def test( return cls(pipeline_response, None, {}) test.metadata = {'url': '/test'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py index 313a30b2183..d84b4547888 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/_multiapi_custom_base_url_service_client_operations.py @@ -5,14 +5,16 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -44,27 +46,17 @@ def test( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test.metadata['url'] # type: ignore + + request = rest.build_test_request( + id=id, + template_url=self.test.metadata['url'], + )._to_pipeline_transport_request() path_format_arguments = { - 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request.url = self._client.format_url(request.url, **path_format_arguments) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -76,3 +68,4 @@ def test( return cls(pipeline_response, None, {}) test.metadata = {'url': '/test'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json index 2645d898234..a89c680bf4e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": false, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiCustomBaseUrlServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiCustomBaseUrlServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -87,12 +87,12 @@ "operation_groups": { }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}", "operations": { "test" : { "sync": { - "signature": "def test(\n self,\n id, # type: int\n **kwargs # type: Any\n):\n", + "signature": "def test(\n self,\n id, # type: int\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Should be a mixin operation. Put in 2 for the required parameter and have the correct api\nversion of 2.0.0 to pass.\n\n:param id: An int parameter. Put in 2 to pass.\n:type id: int\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_multiapi_custom_base_url_service_client.py index 6dcfb8e4643..4e16c12ad69 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_multiapi_custom_base_url_service_client.py @@ -6,22 +6,22 @@ # 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 MultiapiCustomBaseUrlServiceClientConfiguration +from .operations import MultiapiCustomBaseUrlServiceClientOperationsMixin + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration -from .operations import MultiapiCustomBaseUrlServiceClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiCustomBaseUrlServiceClient(MultiapiCustomBaseUrlServiceClientOperationsMixin): """Service client for multiapi custom base url testing. @@ -45,27 +45,45 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicustombaseurl.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicustombaseurl.v2._rest import build_test_request + >>> request = build_test_request(id=id, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ + + request_copy = deepcopy(request) path_format_arguments = { 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/__init__.py new file mode 100644 index 00000000000..5b359d8437f --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/__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_test_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_request # type: ignore + +__all__ = [ + 'build_test_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..af91be63b41 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/_request_builders.py @@ -0,0 +1,62 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Should be a mixin operation. Put in 2 for the required parameter and have the correct api + version of 2.0.0 to pass. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. Put in 2 to pass. + :paramtype id: int + :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 + """ + + id = kwargs.pop('id') # type: int + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/test') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4d832a361e6 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_rest/_request_builders_py3.py @@ -0,0 +1,56 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_request( + *, + id: int, + **kwargs: Any +) -> HttpRequest: + """Should be a mixin operation. Put in 2 for the required parameter and have the correct api + version of 2.0.0 to pass. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. Put in 2 to pass. + :paramtype id: int + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/test') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_multiapi_custom_base_url_service_client.py index 64392ee71b6..24987f4ccd3 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/_multiapi_custom_base_url_service_client.py @@ -6,20 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MultiapiCustomBaseUrlServiceClientConfiguration from .operations import MultiapiCustomBaseUrlServiceClientOperationsMixin -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential class MultiapiCustomBaseUrlServiceClient(MultiapiCustomBaseUrlServiceClientOperationsMixin): """Service client for multiapi custom base url testing. @@ -42,26 +42,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapicustombaseurl.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapicustombaseurl.v2._rest import build_test_request + >>> request = build_test_request(id=id, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ + + request_copy = deepcopy(request) path_format_arguments = { 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py index 0197b22097b..05961036926 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py @@ -5,14 +5,16 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,27 +41,17 @@ async def test( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test.metadata['url'] # type: ignore + + request = rest.build_test_request( + id=id, + template_url=self.test.metadata['url'], + )._to_pipeline_transport_request() path_format_arguments = { - 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request.url = self._client.format_url(request.url, **path_format_arguments) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -71,3 +63,4 @@ async def test( return cls(pipeline_response, None, {}) test.metadata = {'url': '/test'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py index 49b5fed1263..c08e279b2d2 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/_multiapi_custom_base_url_service_client_operations.py @@ -5,14 +5,16 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -44,27 +46,17 @@ def test( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test.metadata['url'] # type: ignore + + request = rest.build_test_request( + id=id, + template_url=self.test.metadata['url'], + )._to_pipeline_transport_request() path_format_arguments = { - 'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request.url = self._client.format_url(request.url, **path_format_arguments) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -76,3 +68,4 @@ def test( return cls(pipeline_response, None, {}) test.metadata = {'url': '/test'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py index 44e4723dcab..4a1f4671cc0 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py index b2c702145dc..1c1fa4fcb62 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py @@ -10,18 +10,13 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Iterable, Optional + + from azure.core.paging import ItemPaged + from azure.core.polling import LROPoller class MultiapiServiceClientOperationsMixin(object): @@ -31,19 +26,22 @@ def begin_test_lro( product=None, # type: Optional["_models.Product"] **kwargs # type: Any ): + # type: (...) -> LROPoller["_models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. :type product: ~multiapidataplane.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapidataplane.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -64,6 +62,7 @@ def begin_test_lro_and_paging( test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"] **kwargs # type: Any ): + # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: @@ -72,13 +71,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapidataplane.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapidataplane.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -100,6 +103,7 @@ def test_different_calls( greeting_in_french=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """Has added parameters across the API versions. :param greeting_in_english: pass in 'hello' to pass test. @@ -136,6 +140,7 @@ def test_one( message=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """TestOne should be in an FirstVersionOperationsMixin. :param id: An int parameter. @@ -166,6 +171,7 @@ def test_paging( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.PagingResult"] """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_multiapi_service_client.py index d4bac2d5de7..4547e1ffba6 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_multiapi_service_client.py @@ -12,7 +12,6 @@ from typing import Any, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from msrest import Deserializer, Serializer @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py index 1713634807d..4601e2f2047 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py @@ -9,15 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Optional -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling +from azure.core.async_paging import AsyncItemPaged +from azure.core.polling import AsyncLROPoller class MultiapiServiceClientOperationsMixin(object): @@ -33,13 +28,16 @@ async def begin_test_lro( :type product: ~multiapidataplane.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapidataplane.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -54,7 +52,7 @@ async def begin_test_lro( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.begin_test_lro(product, **kwargs) - def begin_test_lro_and_paging( + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None, @@ -68,13 +66,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -87,7 +89,7 @@ def begin_test_lro_and_paging( mixin_instance._serialize = Serializer(self._models_dict(api_version)) mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) - return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + return await mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) async def test_different_calls( self, @@ -161,7 +163,7 @@ async def test_one( def test_paging( self, **kwargs: Any - ) -> AsyncItemPaged["_models.PagingResult"]: + ) -> AsyncIterable["_models.PagingResult"]: """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json index 76186dadafc..13adae5ad77 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": false, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -88,12 +88,12 @@ "operation_group_one": "OperationGroupOneOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.core.polling.base_polling\": [\"LROBasePolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.core.polling.async_base_polling\": [\"AsyncLROBasePolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -105,55 +105,55 @@ }, "_test_lro_initial" : { "sync": { - "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.Product\"]\n", + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e Optional[\"_models.Product\"]:\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "begin_test_lro" : { "sync": { - "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapidataplane.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.Product\"]\n", + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapidataplane.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapidataplane.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapidataplane.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False\n for this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of\n cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapidataplane.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "_test_lro_and_paging_initial" : { "sync": { - "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.PagingResult\"\n", + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e \"_models.PagingResult\":\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapidataplane.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "begin_test_lro_and_paging" : { "sync": { - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapidataplane.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[ItemPaged[\"_models.PagingResult\"]]\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapidataplane.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { - "coroutine": false, - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "coroutine": true, + "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False\n for this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either\n PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_multiapi_service_client.py index 6fc283a08c2..f12c7d8dbe8 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_multiapi_service_client.py @@ -6,23 +6,22 @@ # 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 MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -31,8 +30,10 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_one: multiapidataplane.v1.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -49,26 +50,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapidataplane.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapidataplane.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/__init__.py new file mode 100644 index 00000000000..f9044715939 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/__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 ._request_builders_py3 import build_test_one_request + from ._request_builders_py3 import build_test_lro_request_initial + from ._request_builders_py3 import build_test_lro_and_paging_request_initial + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_lro_request_initial # type: ignore + from ._request_builders import build_test_lro_and_paging_request_initial # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_lro_request_initial', + 'build_test_lro_and_paging_request_initial', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..0212b812ffd --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/_request_builders.py @@ -0,0 +1,197 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..b9131d21981 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/_request_builders_py3.py @@ -0,0 +1,193 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..f984bfab1ee --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..7a4821c0604 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_multiapi_service_client.py index 40d19313dd6..156069bca72 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/_multiapi_service_client.py @@ -6,22 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -29,8 +28,10 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_one: multiapidataplane.v1.aio.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -46,25 +47,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapidataplane.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapidataplane.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py index 53f2c4ba8c9..504c1d7a5c4 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py @@ -5,17 +5,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.polling.async_base_polling import AsyncLROBasePolling +from azure.core.rest import HttpRequest -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,25 +46,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -75,6 +67,7 @@ async def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def _test_lro_initial( self, product: Optional["_models.Product"] = None, @@ -85,34 +78,26 @@ async def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) deserialized = None if response.status_code == 200: @@ -122,8 +107,10 @@ async def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + async def begin_test_lro( self, product: Optional["_models.Product"] = None, @@ -135,13 +122,16 @@ async def begin_test_lro( :type product: ~multiapidataplane.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapidataplane.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -159,8 +149,10 @@ async def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -181,6 +173,7 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + async def _test_lro_and_paging_initial( self, client_request_id: Optional[str] = None, @@ -192,32 +185,21 @@ async def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,8 +212,10 @@ async def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, @@ -246,49 +230,55 @@ async def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -305,8 +295,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response @@ -351,6 +341,7 @@ async def internal_get_next(next_link=None): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -370,23 +361,14 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -398,3 +380,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py index 1de35d17adf..011ad4485e7 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_operation_group_one_operations.py @@ -5,14 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,22 +58,13 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -82,3 +76,4 @@ async def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py index 48c2454c2a1..27047c1d582 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py @@ -5,17 +5,19 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.polling.base_polling import LROBasePolling +from azure.core.rest import HttpRequest -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -49,25 +51,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -80,6 +72,7 @@ def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def _test_lro_initial( self, product=None, # type: Optional["_models.Product"] @@ -91,34 +84,26 @@ def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) deserialized = None if response.status_code == 200: @@ -128,8 +113,10 @@ def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + def begin_test_lro( self, product=None, # type: Optional["_models.Product"] @@ -142,13 +129,15 @@ def begin_test_lro( :type product: ~multiapidataplane.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapidataplane.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -166,8 +155,10 @@ def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -188,6 +179,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + def _test_lro_and_paging_initial( self, client_request_id=None, # type: Optional[str] @@ -200,32 +192,21 @@ def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -238,8 +219,10 @@ def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def begin_test_lro_and_paging( self, client_request_id=None, # type: Optional[str] @@ -255,49 +238,55 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapidataplane.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapidataplane.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -314,8 +303,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response @@ -360,6 +349,7 @@ def internal_get_next(next_link=None): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -380,23 +370,14 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,3 +389,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py index 19b94877e55..39f9b646164 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_operation_group_one_operations.py @@ -5,14 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -60,22 +63,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,3 +81,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json index b4e586e4acb..eca472f5709 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": false, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,12 +89,12 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.ModelTwo\"\n", "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapidataplane.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -106,7 +106,7 @@ }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_multiapi_service_client.py index c80fbfffa36..1e018073ab5 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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 MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapidataplane.v2.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapidataplane.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapidataplane.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/__init__.py new file mode 100644 index 00000000000..47d95873c6d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_one_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..248aec13bdf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/_request_builders.py @@ -0,0 +1,113 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4cda774bfa7 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/_request_builders_py3.py @@ -0,0 +1,106 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..a1c3ce0967d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/__init__.py @@ -0,0 +1,19 @@ +# 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_test_two_request + from ._request_builders_py3 import build_test_three_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + from ._request_builders import build_test_three_request # type: ignore + +__all__ = [ + 'build_test_two_request', + 'build_test_three_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..aceec5b3a50 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,103 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_three_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..dc51f344320 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,101 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_three_request( + **kwargs: Any +) -> HttpRequest: + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..40936059a53 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/__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_test_four_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + +__all__ = [ + 'build_test_four_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..beab509ad89 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + parameter_one = kwargs.pop('parameter_one') # type: bool + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..ad79a8caadf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + parameter_one: bool, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_multiapi_service_client.py index f7f8cc84d8b..696711c1854 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/_multiapi_service_client.py @@ -6,23 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -32,7 +30,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapidataplane.v2.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +47,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapidataplane.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapidataplane.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py index 320a4a2b4ea..7a6cc94e750 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py @@ -5,14 +5,16 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,25 +43,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -73,8 +65,10 @@ async def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -97,25 +91,15 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -127,3 +111,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py index 905c0c52bc7..cd69cc29f19 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_one_operations.py @@ -5,14 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,30 +61,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,8 +89,10 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + async def test_three( self, **kwargs: Any @@ -113,22 +109,13 @@ async def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,3 +127,4 @@ async def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py index 0f3d88b1c47..03ddd75af0e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_operation_group_two_operations.py @@ -5,14 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,23 +61,14 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,3 +80,4 @@ async def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py index 299274facd3..69e87806cec 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py @@ -5,14 +5,16 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -46,25 +48,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -78,8 +70,10 @@ def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -103,25 +97,15 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -133,3 +117,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py index 2689023cb9f..d582757a2e6 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_one_operations.py @@ -5,14 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -63,30 +66,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,8 +94,10 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + def test_three( self, **kwargs # type: Any @@ -119,22 +115,13 @@ def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,3 +133,4 @@ def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py index d78f1c3e0ac..4985c9386c4 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_operation_group_two_operations.py @@ -5,14 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -63,23 +66,14 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -91,3 +85,4 @@ def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json index f266f3b9932..0a036430f1d 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": false, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,24 +89,24 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_paging" : { "sync": { - "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.PagingResult\"]\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~multiapidataplane.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n", + "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.PagingResult\"]:\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_multiapi_service_client.py index 24a6184a676..db984f20622 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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 MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapidataplane.v3.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapidataplane.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapidataplane.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/__init__.py new file mode 100644 index 00000000000..ac71d77c963 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_paging_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_paging_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_paging_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/_request_builders.py new file mode 100644 index 00000000000..51330488a14 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/_request_builders.py @@ -0,0 +1,102 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + greeting_in_french = kwargs.pop('greeting_in_french', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..ddae7737619 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/_request_builders_py3.py @@ -0,0 +1,95 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_paging_request( + **kwargs: Any +) -> HttpRequest: + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..689e60edb0d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..ffa8d8ef82c --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..c9663b12265 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/__init__.py @@ -0,0 +1,19 @@ +# 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_test_four_request + from ._request_builders_py3 import build_test_five_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + from ._request_builders import build_test_five_request # type: ignore + +__all__ = [ + 'build_test_four_request', + 'build_test_five_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..bca245b1aff --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,106 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_five_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..1dc882231b0 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_five_request( + **kwargs: Any +) -> HttpRequest: + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_multiapi_service_client.py index 5838f9560f3..4ee129e2971 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/_multiapi_service_client.py @@ -6,23 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -32,7 +30,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapidataplane.v3.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +47,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapidataplane.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapidataplane.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py index 15f0cb364a1..17d93b0cf47 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -36,24 +38,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -70,8 +70,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response @@ -105,27 +105,16 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,3 +126,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py index ece5941a7d7..fd576c41796 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_one_operations.py @@ -5,14 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,30 +61,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,4 +89,6 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py index 44c831cf7e3..adedd16180a 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_operation_group_two_operations.py @@ -5,14 +5,17 @@ # 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, IO, 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,8 +51,9 @@ async def test_four( :param input: Input parameter. :type input: IO or ~multiapidataplane.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -60,38 +64,30 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,6 +100,7 @@ async def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + async def test_five( self, **kwargs: Any @@ -120,22 +117,13 @@ async def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,3 +135,4 @@ async def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py index 15709831798..43e15cbaec1 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -41,24 +43,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -75,8 +75,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response @@ -111,27 +111,16 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,3 +132,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py index fe33a3c75fe..81302c2c017 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_one_operations.py @@ -5,14 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -63,30 +66,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,4 +94,6 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py index 70551fb2934..b4dfdbaf586 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_operation_group_two_operations.py @@ -5,14 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -53,8 +56,9 @@ def test_four( :param input: Input parameter. :type input: IO or ~multiapidataplane.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -65,38 +69,30 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,6 +105,7 @@ def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + def test_five( self, **kwargs # type: Any @@ -126,22 +123,13 @@ def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -153,3 +141,4 @@ def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py index d63cf120947..62f41a83d96 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py index 3faec31f425..e0cd889ebe8 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py @@ -10,19 +10,13 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Iterable, Optional + + from azure.core.paging import ItemPaged + from azure.core.polling import LROPoller class MultiapiServiceClientOperationsMixin(object): @@ -32,19 +26,22 @@ def begin_test_lro( product=None, # type: Optional["_models.Product"] **kwargs # type: Any ): + # type: (...) -> LROPoller["_models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. :type product: ~multiapinoasync.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapinoasync.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -65,6 +62,7 @@ def begin_test_lro_and_paging( test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"] **kwargs # type: Any ): + # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: @@ -73,13 +71,17 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapinoasync.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapinoasync.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -101,6 +103,7 @@ def test_different_calls( greeting_in_french=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """Has added parameters across the API versions. :param greeting_in_english: pass in 'hello' to pass test. @@ -137,6 +140,7 @@ def test_one( message=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """TestOne should be in an FirstVersionOperationsMixin. :param id: An int parameter. @@ -167,6 +171,7 @@ def test_paging( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.PagingResult"] """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json index 0752a89037c..092f007e839 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -88,12 +88,12 @@ "operation_group_one": "OperationGroupOneOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.mgmt.core.polling.arm_polling\": [\"ARMPolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.mgmt.core.polling.async_arm_polling\": [\"AsyncARMPolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -105,55 +105,55 @@ }, "_test_lro_initial" : { "sync": { - "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.Product\"]\n", + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e Optional[\"_models.Product\"]:\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "begin_test_lro" : { "sync": { - "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapinoasync.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.Product\"]\n", + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapinoasync.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapinoasync.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of\n cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapinoasync.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "_test_lro_and_paging_initial" : { "sync": { - "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.PagingResult\"\n", + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e \"_models.PagingResult\":\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "begin_test_lro_and_paging" : { "sync": { - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapinoasync.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[ItemPaged[\"_models.PagingResult\"]]\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapinoasync.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { - "coroutine": false, - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapinoasync.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "coroutine": true, + "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either\n PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapinoasync.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_multiapi_service_client.py index bb69183e29b..4794e8d76f3 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_multiapi_service_client.py @@ -6,23 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -31,8 +30,10 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_one: multiapinoasync.v1.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -49,26 +50,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapinoasync.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapinoasync.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/__init__.py new file mode 100644 index 00000000000..f9044715939 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/__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 ._request_builders_py3 import build_test_one_request + from ._request_builders_py3 import build_test_lro_request_initial + from ._request_builders_py3 import build_test_lro_and_paging_request_initial + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_lro_request_initial # type: ignore + from ._request_builders import build_test_lro_and_paging_request_initial # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_lro_request_initial', + 'build_test_lro_and_paging_request_initial', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..0212b812ffd --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/_request_builders.py @@ -0,0 +1,197 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..b9131d21981 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/_request_builders_py3.py @@ -0,0 +1,193 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..f984bfab1ee --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..7a4821c0604 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py index deb8bd335ae..2676a13a7a2 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -50,25 +52,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -81,6 +73,7 @@ def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def _test_lro_initial( self, product=None, # type: Optional["_models.Product"] @@ -92,34 +85,26 @@ def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -129,8 +114,10 @@ def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + def begin_test_lro( self, product=None, # type: Optional["_models.Product"] @@ -143,13 +130,15 @@ def begin_test_lro( :type product: ~multiapinoasync.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapinoasync.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -167,8 +156,10 @@ def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -189,6 +180,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + def _test_lro_and_paging_initial( self, client_request_id=None, # type: Optional[str] @@ -201,32 +193,21 @@ def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,8 +220,10 @@ def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def begin_test_lro_and_paging( self, client_request_id=None, # type: Optional[str] @@ -256,49 +239,55 @@ def begin_test_lro_and_paging( :type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapinoasync.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapinoasync.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -315,8 +304,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -361,6 +350,7 @@ def internal_get_next(next_link=None): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -381,23 +371,14 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,3 +390,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py index 291d562661f..8c598cc24eb 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -61,22 +64,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,3 +82,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json index ea58425746d..238ae403d7a 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,12 +89,12 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.ModelTwo\"\n", "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapinoasync.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -106,7 +106,7 @@ }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_multiapi_service_client.py index f6bd12b6603..a49df236ffb 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapinoasync.v2.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapinoasync.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapinoasync.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/__init__.py new file mode 100644 index 00000000000..47d95873c6d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_one_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..248aec13bdf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/_request_builders.py @@ -0,0 +1,113 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4cda774bfa7 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/_request_builders_py3.py @@ -0,0 +1,106 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..a1c3ce0967d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/__init__.py @@ -0,0 +1,19 @@ +# 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_test_two_request + from ._request_builders_py3 import build_test_three_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + from ._request_builders import build_test_three_request # type: ignore + +__all__ = [ + 'build_test_two_request', + 'build_test_three_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..aceec5b3a50 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,103 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_three_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..dc51f344320 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,101 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_three_request( + **kwargs: Any +) -> HttpRequest: + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..40936059a53 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/__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_test_four_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + +__all__ = [ + 'build_test_four_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..beab509ad89 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + parameter_one = kwargs.pop('parameter_one') # type: bool + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..ad79a8caadf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + parameter_one: bool, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py index 335613e4aa7..5514ac1ff21 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -47,25 +49,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -79,8 +71,10 @@ def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -104,25 +98,15 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,3 +118,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py index ee8bc42ac80..0f05afc2846 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,8 +95,10 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + def test_three( self, **kwargs # type: Any @@ -120,22 +116,13 @@ def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,3 +134,4 @@ def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py index 7bf734513ca..520859d86ef 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,23 +67,14 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,3 +86,4 @@ def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json index ce4328254da..6f4d81b5a91 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,24 +89,24 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_paging" : { "sync": { - "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.PagingResult\"]\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~multiapinoasync.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n", + "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.PagingResult\"]:\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapinoasync.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_multiapi_service_client.py index ffe643b5ec8..15c82bab371 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_multiapi_service_client.py @@ -6,24 +6,22 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. @@ -34,7 +32,8 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): :vartype operation_group_two: multiapinoasync.v3.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +50,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapinoasync.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapinoasync.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/__init__.py new file mode 100644 index 00000000000..ac71d77c963 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_paging_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_paging_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_paging_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/_request_builders.py new file mode 100644 index 00000000000..51330488a14 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/_request_builders.py @@ -0,0 +1,102 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + greeting_in_french = kwargs.pop('greeting_in_french', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..ddae7737619 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/_request_builders_py3.py @@ -0,0 +1,95 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_paging_request( + **kwargs: Any +) -> HttpRequest: + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..689e60edb0d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..ffa8d8ef82c --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..c9663b12265 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/__init__.py @@ -0,0 +1,19 @@ +# 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_test_four_request + from ._request_builders_py3 import build_test_five_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + from ._request_builders import build_test_five_request # type: ignore + +__all__ = [ + 'build_test_four_request', + 'build_test_five_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..bca245b1aff --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,106 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_five_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..1dc882231b0 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_five_request( + **kwargs: Any +) -> HttpRequest: + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py index d9a9345b375..2eccb3c7cbe 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -42,24 +44,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -76,8 +76,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -112,27 +112,16 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,3 +133,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py index 67c8765a763..27ad2b2e449 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,4 +95,6 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py index dd0592aeced..cfccb798e8c 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,8 +57,9 @@ def test_four( :param input: Input parameter. :type input: IO or ~multiapinoasync.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -66,38 +70,30 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,6 +106,7 @@ def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + def test_five( self, **kwargs # type: Any @@ -127,22 +124,13 @@ def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,3 +142,4 @@ def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py index 5d369b047e6..19092702482 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py index 31379430c28..6d70a1617e9 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py @@ -10,19 +10,13 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Iterable, Optional + + from azure.core.paging import ItemPaged + from azure.core.polling import LROPoller class MultiapiServiceClientOperationsMixin(object): @@ -32,19 +26,22 @@ def begin_test_lro( product=None, # type: Optional["_models.Product"] **kwargs # type: Any ): + # type: (...) -> LROPoller["_models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. :type product: ~multiapiwithsubmodule.submodule.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapiwithsubmodule.submodule.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -65,21 +62,27 @@ def begin_test_lro_and_paging( test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"] **kwargs # type: Any ): + # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -101,6 +104,7 @@ def test_different_calls( greeting_in_french=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """Has added parameters across the API versions. :param greeting_in_english: pass in 'hello' to pass test. @@ -137,6 +141,7 @@ def test_one( message=None, # type: Optional[str] **kwargs # type: Any ): + # type: (...) -> None """TestOne should be in an FirstVersionOperationsMixin. :param id: An int parameter. @@ -167,6 +172,7 @@ def test_paging( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.PagingResult"] """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_multiapi_service_client.py index 9c0828134bd..719403f4e20 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_multiapi_service_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py index bce32140912..809e3f548e4 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py @@ -9,16 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Optional -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling +from azure.core.async_paging import AsyncItemPaged +from azure.core.polling import AsyncLROPoller class MultiapiServiceClientOperationsMixin(object): @@ -34,13 +28,16 @@ async def begin_test_lro( :type product: ~multiapiwithsubmodule.submodule.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapiwithsubmodule.submodule.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') if api_version == '1.0.0': @@ -55,7 +52,7 @@ async def begin_test_lro( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.begin_test_lro(product, **kwargs) - def begin_test_lro_and_paging( + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None, @@ -66,16 +63,21 @@ def begin_test_lro_and_paging( :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro_and_paging') if api_version == '1.0.0': @@ -88,7 +90,7 @@ def begin_test_lro_and_paging( mixin_instance._serialize = Serializer(self._models_dict(api_version)) mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) - return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + return await mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) async def test_different_calls( self, @@ -162,12 +164,13 @@ async def test_one( def test_paging( self, **kwargs: Any - ) -> AsyncItemPaged["_models.PagingResult"]: + ) -> AsyncIterable["_models.PagingResult"]: """Returns ModelThree with optionalProperty 'paged'. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult] :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('test_paging') diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json index 94c43f5c587..9e4f18b6bbf 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -88,12 +88,12 @@ "operation_group_one": "OperationGroupOneOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.mgmt.core.polling.arm_polling\": [\"ARMPolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.mgmt.core.polling.async_arm_polling\": [\"AsyncARMPolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -105,55 +105,55 @@ }, "_test_lro_initial" : { "sync": { - "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.Product\"]\n", + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e Optional[\"_models.Product\"]:\n", - "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "begin_test_lro" : { "sync": { - "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapiwithsubmodule.submodule.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.Product\"]\n", + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~multiapiwithsubmodule.submodule.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n", - "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapiwithsubmodule.submodule.v1.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either Product or the result of\n cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~multiapiwithsubmodule.submodule.v1.models.Product]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "product" }, "_test_lro_and_paging_initial" : { "sync": { - "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.PagingResult\"\n", + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e \"_models.PagingResult\":\n", - "doc": "\"\"\"\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "begin_test_lro_and_paging" : { "sync": { - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[ItemPaged[\"_models.PagingResult\"]]\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { - "coroutine": false, - "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", - "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" + "coroutine": true, + "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options:\n ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either\n PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_multiapi_service_client.py index 7eaf6860c59..4622741faef 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_multiapi_service_client.py @@ -6,33 +6,35 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapiwithsubmodule.submodule.v1.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapiwithsubmodule.submodule.v1.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -49,26 +51,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapiwithsubmodule.submodule.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapiwithsubmodule.submodule.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/__init__.py new file mode 100644 index 00000000000..f9044715939 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/__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 ._request_builders_py3 import build_test_one_request + from ._request_builders_py3 import build_test_lro_request_initial + from ._request_builders_py3 import build_test_lro_and_paging_request_initial + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_lro_request_initial # type: ignore + from ._request_builders import build_test_lro_and_paging_request_initial # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_lro_request_initial', + 'build_test_lro_and_paging_request_initial', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/_request_builders.py new file mode 100644 index 00000000000..0212b812ffd --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/_request_builders.py @@ -0,0 +1,197 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + client_request_id = kwargs.pop('client_request_id', None) # type: Optional[str] + maxresults = kwargs.pop('maxresults', None) # type: Optional[int] + timeout = kwargs.pop('timeout', 30) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..b9131d21981 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/_request_builders_py3.py @@ -0,0 +1,193 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an FirstVersionOperationsMixin. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_lro_request_initial( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """Put in whatever shape of Product you want, will return a Product with id equal to 100. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lro') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_lro_and_paging_request_initial( + *, + client_request_id: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = 30, + **kwargs: Any +) -> HttpRequest: + """A long-running paging operation that includes a nextLink that has 10 pages. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword client_request_id: + :paramtype client_request_id: str + :keyword maxresults: Sets the maximum number of items to return in the response. + :paramtype maxresults: int + :keyword timeout: Sets the maximum time that the server can spend processing the request, in + seconds. The default is 30 seconds. + :paramtype timeout: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/lroAndPaging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if maxresults is not None: + header_parameters['maxresults'] = _SERIALIZER.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = _SERIALIZER.header("timeout", timeout, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..f984bfab1ee --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,56 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..7a4821c0604 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,50 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_multiapi_service_client.py index 6f4ad67410f..dba0233b253 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/_multiapi_service_client.py @@ -6,31 +6,33 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapiwithsubmodule.submodule.v1.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapiwithsubmodule.submodule.v1.aio.operations.OperationGroupOneOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -46,25 +48,42 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapiwithsubmodule.submodule.v1.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapiwithsubmodule.submodule.v1._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py index fc673e06fec..040a9c72750 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,25 +47,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -76,6 +68,7 @@ async def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def _test_lro_initial( self, product: Optional["_models.Product"] = None, @@ -86,34 +79,26 @@ async def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -123,8 +108,10 @@ async def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + async def begin_test_lro( self, product: Optional["_models.Product"] = None, @@ -136,13 +123,16 @@ async def begin_test_lro( :type product: ~multiapiwithsubmodule.submodule.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Product or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~multiapiwithsubmodule.submodule.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -160,8 +150,10 @@ async def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -182,6 +174,7 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + async def _test_lro_and_paging_initial( self, client_request_id: Optional[str] = None, @@ -193,32 +186,21 @@ async def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,8 +213,10 @@ async def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def begin_test_lro_and_paging( self, client_request_id: Optional[str] = None, @@ -244,52 +228,59 @@ async def begin_test_lro_and_paging( :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns an iterator like instance of either + PagingResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -306,8 +297,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -352,6 +343,7 @@ async def internal_get_next(next_link=None): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -371,23 +363,14 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,3 +382,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py index 662bc0f1a31..0fcc9e5ae35 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,22 +59,13 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -83,3 +77,4 @@ async def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py index a4c2d039f57..7519964e281 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py @@ -5,18 +5,20 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -50,25 +52,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -81,6 +73,7 @@ def test_one( test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def _test_lro_initial( self, product=None, # type: Optional["_models.Product"] @@ -92,34 +85,26 @@ def _test_lro_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._test_lro_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if product is not None: - body_content = self._serialize.body(product, 'Product') + json = self._serialize.body(product, 'Product') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest.build_test_lro_request_initial( + content_type=content_type, + json=json, + template_url=self._test_lro_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -129,8 +114,10 @@ def _test_lro_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore + def begin_test_lro( self, product=None, # type: Optional["_models.Product"] @@ -143,13 +130,15 @@ def begin_test_lro( :type product: ~multiapiwithsubmodule.submodule.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Product or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~multiapiwithsubmodule.submodule.v1.models.Product] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"] @@ -167,8 +156,10 @@ def begin_test_lro( kwargs.pop('error_map', None) kwargs.pop('content_type', None) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Product', pipeline_response) if cls: @@ -189,6 +180,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore + def _test_lro_and_paging_initial( self, client_request_id=None, # type: Optional[str] @@ -201,32 +193,21 @@ def _test_lro_and_paging_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _maxresults = None _timeout = None if test_lro_and_paging_options is not None: _maxresults = test_lro_and_paging_options.maxresults _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - - # Construct URL - url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self._test_lro_and_paging_initial.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,8 +220,10 @@ def _test_lro_and_paging_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def begin_test_lro_and_paging( self, client_request_id=None, # type: Optional[str] @@ -253,52 +236,59 @@ def begin_test_lro_and_paging( :param client_request_id: :type client_request_id: str :param test_lro_and_paging_options: Parameter group. - :type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions + :type test_lro_and_paging_options: + ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either PagingResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]] + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _maxresults = None - _timeout = None - if test_lro_and_paging_options is not None: - _maxresults = test_lro_and_paging_options.maxresults - _timeout = test_lro_and_paging_options.timeout - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') - if _maxresults is not None: - header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int') - if _timeout is not None: - header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_lro_and_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=self.begin_test_lro_and_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _maxresults = None + _timeout = None + if test_lro_and_paging_options is not None: + _maxresults = test_lro_and_paging_options.maxresults + _timeout = test_lro_and_paging_options.timeout + + request = rest.build_test_lro_and_paging_request_initial( + client_request_id=client_request_id, + maxresults=_maxresults, + timeout=_timeout, + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -315,8 +305,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -361,6 +351,7 @@ def internal_get_next(next_link=None): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -381,23 +372,14 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,3 +391,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py index 323aecba747..30d18ede475 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -61,22 +64,13 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "1.0.0" - accept = "application/json" + + request = rest_operation_group_one.build_test_two_request( + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,3 +82,4 @@ def test_two( return cls(pipeline_response, None, {}) test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json index 344b24756c5..cb7010a4311 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,12 +89,12 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "test_one" : { "sync": { - "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.ModelTwo\"\n", "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -106,7 +106,7 @@ }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_multiapi_service_client.py index a6f0c97626c..fbbf9bcec40 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_multiapi_service_client.py @@ -6,35 +6,36 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapiwithsubmodule.submodule.v2.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapiwithsubmodule.submodule.v2.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapiwithsubmodule.submodule.v2.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapiwithsubmodule.submodule.v2.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +52,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapiwithsubmodule.submodule.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapiwithsubmodule.submodule.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/__init__.py new file mode 100644 index 00000000000..47d95873c6d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_one_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_one_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_one_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/_request_builders.py new file mode 100644 index 00000000000..248aec13bdf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/_request_builders.py @@ -0,0 +1,113 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_one_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + id = kwargs.pop('id') # type: int + message = kwargs.pop('message', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..4cda774bfa7 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/_request_builders_py3.py @@ -0,0 +1,106 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_one_request( + *, + id: int, + message: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword id: An int parameter. + :paramtype id: int + :keyword message: An optional string parameter. + :paramtype message: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testOneEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['id'] = _SERIALIZER.query("id", id, 'int') + if message is not None: + query_parameters['message'] = _SERIALIZER.query("message", message, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..a1c3ce0967d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/__init__.py @@ -0,0 +1,19 @@ +# 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_test_two_request + from ._request_builders_py3 import build_test_three_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + from ._request_builders import build_test_three_request # type: ignore + +__all__ = [ + 'build_test_two_request', + 'build_test_three_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..aceec5b3a50 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,103 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_three_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..dc51f344320 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,101 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelTwo parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelTwo parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_three_request( + **kwargs: Any +) -> HttpRequest: + """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testThreeEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..40936059a53 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/__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_test_four_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + +__all__ = [ + 'build_test_four_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..beab509ad89 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + parameter_one = kwargs.pop('parameter_one') # type: bool + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..ad79a8caadf --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + parameter_one: bool, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter_one: A boolean parameter. + :paramtype parameter_one: bool + :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 + """ + + api_version = "2.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameterOne'] = _SERIALIZER.query("parameter_one", parameter_one, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_multiapi_service_client.py index b1918c4abc9..4beead683c0 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/_multiapi_service_client.py @@ -6,33 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapiwithsubmodule.submodule.v2.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapiwithsubmodule.submodule.v2.aio.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapiwithsubmodule.submodule.v2.aio.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapiwithsubmodule.submodule.v2.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +49,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapiwithsubmodule.submodule.v2.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapiwithsubmodule.submodule.v2._rest import build_test_one_request + >>> request = build_test_one_request(id=id, message=message, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py index 7108e3e110c..a23650e3199 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,25 +44,15 @@ async def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -74,8 +66,10 @@ async def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + async def test_different_calls( self, greeting_in_english: str, @@ -98,25 +92,15 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,3 +112,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py index 2bbd9698cd6..18271a01e36 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +90,10 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + async def test_three( self, **kwargs: Any @@ -114,22 +110,13 @@ async def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,3 +128,4 @@ async def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py index 35dfc0500af..8a83f11e2b2 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,23 +62,14 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -87,3 +81,4 @@ async def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py index 8440038598d..a30fb88b4c9 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py @@ -5,15 +5,17 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -47,25 +49,15 @@ def test_one( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_one.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['id'] = self._serialize.query("id", id, 'int') - if message is not None: - query_parameters['message'] = self._serialize.query("message", message, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_one_request( + id=id, + message=message, + template_url=self.test_one.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -79,8 +71,10 @@ def test_one( return cls(pipeline_response, deserialized, {}) return deserialized + test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + def test_different_calls( self, greeting_in_english, # type: str @@ -104,25 +98,15 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,3 +118,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py index 5299f6e0acd..9b595cc1fc2 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelTwo') + json = self._serialize.body(parameter_one, 'ModelTwo') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,8 +95,10 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + def test_three( self, **kwargs # type: Any @@ -120,22 +116,13 @@ def test_three( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_three.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = rest_operation_group_one.build_test_three_request( + template_url=self.test_three.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,3 +134,4 @@ def test_three( return cls(pipeline_response, None, {}) test_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py index 19bb156ff0c..f970a2e1c16 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,23 +67,14 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2.0.0" - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + parameter_one=parameter_one, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,3 +86,4 @@ def test_four( return cls(pipeline_response, None, {}) test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json index 2b94d17fa00..9e9c94364fa 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -89,24 +89,24 @@ "operation_group_two": "OperationGroupTwoOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Optional\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "test_paging" : { "sync": { - "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.PagingResult\"]\n", "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n", - "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.PagingResult\"]:\n", + "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" }, "test_different_calls" : { "sync": { - "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_multiapi_service_client.py index 313095c7fa0..198afbc5825 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_multiapi_service_client.py @@ -6,35 +6,36 @@ # 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.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapiwithsubmodule.submodule.v3.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapiwithsubmodule.submodule.v3.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapiwithsubmodule.submodule.v3.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapiwithsubmodule.submodule.v3.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -51,28 +52,44 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapiwithsubmodule.submodule.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapiwithsubmodule.submodule.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/__init__.py new file mode 100644 index 00000000000..ac71d77c963 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_test_paging_request + from ._request_builders_py3 import build_test_different_calls_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_paging_request # type: ignore + from ._request_builders import build_test_different_calls_request # type: ignore + +__all__ = [ + 'build_test_paging_request', + 'build_test_different_calls_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/_request_builders.py new file mode 100644 index 00000000000..51330488a14 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/_request_builders.py @@ -0,0 +1,102 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_paging_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + greeting_in_english = kwargs.pop('greeting_in_english') # type: str + greeting_in_chinese = kwargs.pop('greeting_in_chinese', None) # type: Optional[str] + greeting_in_french = kwargs.pop('greeting_in_french', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..ddae7737619 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/_request_builders_py3.py @@ -0,0 +1,95 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_paging_request( + **kwargs: Any +) -> HttpRequest: + """Returns ModelThree with optionalProperty 'paged'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/paging') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_test_different_calls_request( + *, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """Has added parameters across the API versions. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword greeting_in_english: pass in 'hello' to pass test. + :paramtype greeting_in_english: str + :keyword greeting_in_chinese: pass in 'nihao' to pass test. + :paramtype greeting_in_chinese: str + :keyword greeting_in_french: pass in 'bonjour' to pass test. + :paramtype greeting_in_french: str + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/testDifferentCalls') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['greetingInEnglish'] = _SERIALIZER.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = _SERIALIZER.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = _SERIALIZER.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/__init__.py new file mode 100644 index 00000000000..e685f3bc613 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/__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_test_two_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_two_request # type: ignore + +__all__ = [ + 'build_test_two_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/_request_builders.py new file mode 100644 index 00000000000..689e60edb0d --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_two_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/_request_builders_py3.py new file mode 100644 index 00000000000..ffa8d8ef82c --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_one/_request_builders_py3.py @@ -0,0 +1,65 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_two_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. A ModelThree parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). A ModelThree parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/one/testTwoEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/__init__.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/__init__.py new file mode 100644 index 00000000000..c9663b12265 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/__init__.py @@ -0,0 +1,19 @@ +# 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_test_four_request + from ._request_builders_py3 import build_test_five_request +except (SyntaxError, ImportError): + from ._request_builders import build_test_four_request # type: ignore + from ._request_builders import build_test_five_request # type: ignore + +__all__ = [ + 'build_test_four_request', + 'build_test_five_request', +] diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/_request_builders.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/_request_builders.py new file mode 100644 index 00000000000..bca245b1aff --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/_request_builders.py @@ -0,0 +1,106 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_test_four_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_test_five_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/_request_builders_py3.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/_request_builders_py3.py new file mode 100644 index 00000000000..1dc882231b0 --- /dev/null +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_rest/operation_group_two/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_test_four_request( + *, + json: Any = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + """TestFour should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFourEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_five_request( + **kwargs: Any +) -> HttpRequest: + """TestFive should be in OperationGroupTwoOperations. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + api_version = "3.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multiapi/two/testFiveEndpoint') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_multiapi_service_client.py index f8687a477b9..85d3b38a723 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/_multiapi_service_client.py @@ -6,33 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MultiapiServiceClientConfiguration +from .operations import MultiapiServiceClientOperationsMixin, OperationGroupOneOperations, OperationGroupTwoOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MultiapiServiceClientConfiguration -from .operations import MultiapiServiceClientOperationsMixin -from .operations import OperationGroupOneOperations -from .operations import OperationGroupTwoOperations -from .. import models - - class MultiapiServiceClient(MultiapiServiceClientOperationsMixin): """Service client for multiapi client testing. :ivar operation_group_one: OperationGroupOneOperations operations - :vartype operation_group_one: multiapiwithsubmodule.submodule.v3.aio.operations.OperationGroupOneOperations + :vartype operation_group_one: + multiapiwithsubmodule.submodule.v3.aio.operations.OperationGroupOneOperations :ivar operation_group_two: OperationGroupTwoOperations operations - :vartype operation_group_two: multiapiwithsubmodule.submodule.v3.aio.operations.OperationGroupTwoOperations + :vartype operation_group_two: + multiapiwithsubmodule.submodule.v3.aio.operations.OperationGroupTwoOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL + :type base_url: str """ def __init__( @@ -48,27 +49,43 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operation_group_one = OperationGroupOneOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_group_two = OperationGroupTwoOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_group_one = OperationGroupOneOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_group_two = OperationGroupTwoOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + We have helper methods to create requests specific to this service in `multiapiwithsubmodule.submodule.v3.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multiapiwithsubmodule.submodule.v3._rest import build_test_paging_request + >>> request = build_test_paging_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py index db557cf9d80..0a22adf9782 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import _rest as rest, models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -29,7 +31,8 @@ def test_paging( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PagingResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"] @@ -37,24 +40,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request async def extract_data(pipeline_response): @@ -71,8 +72,8 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -106,27 +107,16 @@ async def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,3 +128,4 @@ async def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py index 70dca672534..04ad73f5a14 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_one as rest_operation_group_one T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +62,21 @@ async def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,4 +90,6 @@ async def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py index 277a407ab02..e17b634ddf5 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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, IO, 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, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._rest import operation_group_two as rest_operation_group_two T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,8 +52,9 @@ async def test_four( :param input: Input parameter. :type input: IO or ~multiapiwithsubmodule.submodule.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -61,38 +65,30 @@ async def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,6 +101,7 @@ async def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + async def test_five( self, **kwargs: Any @@ -121,22 +118,13 @@ async def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,3 +136,4 @@ async def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py index 571432f24b0..7fff6113206 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py @@ -5,16 +5,18 @@ # 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.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import _rest as rest, models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -42,24 +44,22 @@ def test_paging( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.test_paging.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + + request = rest.build_test_paging_request( + template_url=self.test_paging.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = rest.build_test_paging_request( + template_url=next_link, + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + request.method = "GET" return request def extract_data(pipeline_response): @@ -76,8 +76,8 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response @@ -112,27 +112,16 @@ def test_different_calls( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" - - # Construct URL - url = self.test_different_calls.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') - if greeting_in_chinese is not None: - header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') - if greeting_in_french is not None: - header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest.build_test_different_calls_request( + greeting_in_english=greeting_in_english, + greeting_in_chinese=greeting_in_chinese, + greeting_in_french=greeting_in_french, + template_url=self.test_different_calls.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,3 +133,4 @@ def test_different_calls( return cls(pipeline_response, None, {}) test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py index 44b973e7e07..c6194dca377 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_one_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_one as rest_operation_group_one if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -64,30 +67,21 @@ def test_two( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.test_two.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameter_one is not None: - body_content = self._serialize.body(parameter_one, 'ModelThree') + json = self._serialize.body(parameter_one, 'ModelThree') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + json = None + + request = rest_operation_group_one.build_test_two_request( + content_type=content_type, + json=json, + template_url=self.test_two.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,4 +95,6 @@ def test_two( return cls(pipeline_response, deserialized, {}) return deserialized + test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore + diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py index cf15b007b16..27a4255cfb3 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_operation_group_two_operations.py @@ -5,15 +5,18 @@ # 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._rest import operation_group_two as rest_operation_group_two if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,8 +57,9 @@ def test_four( :param input: Input parameter. :type input: IO or ~multiapiwithsubmodule.submodule.v3.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." :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 @@ -66,38 +70,30 @@ def test_four( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_four.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = input - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: + content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']: + content = input + elif content_type.split(";")[0] in ['application/json']: if input is not None: - body_content = self._serialize.body(input, 'SourcePath') - else: - body_content = None - body_content_kwargs['content'] = body_content + json = self._serialize.body(input, 'SourcePath') else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = rest_operation_group_two.build_test_four_request( + content_type=content_type, + json=json, + content=content, + template_url=self.test_four.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,6 +106,7 @@ def test_four( test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore + def test_five( self, **kwargs # type: Any @@ -127,22 +124,13 @@ def test_five( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "3.0.0" - accept = "application/json" + + request = rest_operation_group_two.build_test_five_request( + template_url=self.test_five.metadata['url'], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) - # Construct URL - url = self.test_five.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,3 +142,4 @@ def test_five( return cls(pipeline_response, None, {}) test_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore + diff --git a/test/services/azure-ai-formrecognizer/README.md b/test/services/azure-ai-formrecognizer/README.md deleted file mode 100644 index 4c8a916166e..00000000000 --- a/test/services/azure-ai-formrecognizer/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Azure Form Recognizer for Python - -> see https://aka.ms/autorest - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - -### Settings -``` yaml -input-file: https://raw.githubusercontent.com/iscai-msft/azure-rest-api-specs/working_form_recognizer/specification/cognitiveservices/data-plane/FormRecognizer/preview/v2.0/FormRecognizer.json -output-folder: _generated -package-name: azure-ai-formrecognizer -namespace: azure.ai.formrecognizer -no-namespace-folders: true -license-header: MICROSOFT_MIT_NO_VERSION -enable-xml: true -vanilla: true -clear-output-folder: true -python: true -add-credentials: true -payload-flattening-threshold: 2 -basic-setup-py: true -package-version: 2.0.0 -credential-scopes: https://cognitiveservices.azure.com/.default -``` \ No newline at end of file diff --git a/test/services/azure-ai-textanalytics/README.md b/test/services/azure-ai-textanalytics/README.md deleted file mode 100644 index cc7f18b4b29..00000000000 --- a/test/services/azure-ai-textanalytics/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Azure Text Analytics for Python - -> see https://aka.ms/autorest - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - -### Settings -``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cognitiveservices/data-plane/TextAnalytics/stable/v2.1/TextAnalytics.json -output-folder: _generated -package-name: azure-ai-textanalytics -namespace: azure.ai.textanalytics -no-namespace-folders: true -license-header: MICROSOFT_MIT_NO_VERSION -enable-xml: true -vanilla: true -clear-output-folder: true -python: true -add-credentials: true -payload-flattening-threshold: 2 -credential-scopes: https://cognitiveservices.azure.com/.default -``` \ No newline at end of file diff --git a/test/services/azure-ai-textanalytics/test_textanalytics.py b/test/services/azure-ai-textanalytics/test_textanalytics.py deleted file mode 100644 index 722f9402670..00000000000 --- a/test/services/azure-ai-textanalytics/test_textanalytics.py +++ /dev/null @@ -1,23 +0,0 @@ -import logging - -from azure.identity import DefaultAzureCredential -from azure.cognitiveservices.language.textanalytics import TextAnalyticsClient - -def main(): - client = TextAnalyticsClient( - endpoint="https://krpratic-textanalytics.cognitiveservices.azure.com/", - credential=DefaultAzureCredential() - ) - - response = client.languages( - documents=[{ - 'id': 1, - 'text': 'I had a wonderful experience! The rooms were wonderful and the staff was helpful.' - }] - ) - - assert response.documents[0].detected_languages[0].name == "English" - -if __name__ == "__main__": - logging.basicConfig(level=logging.DEBUG) - main() \ No newline at end of file diff --git a/test/services/azure-graphrbac/README.md b/test/services/azure-graphrbac/README.md deleted file mode 100644 index 6aaa7b3214f..00000000000 --- a/test/services/azure-graphrbac/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Azure GraphRBAC for Python - -> see https://aka.ms/autorest - -## Suppression - -``` yaml -directive: - - suppress: D5001 - reason: this spec never has examples. It is owned by the SDK group and we already have CLI commands testing it - - suppress: R2058 - reason: existing since the spec started - - suppress: R3016 - reason: existing since the spec started -``` - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - -### Settings -``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/graphrbac/data-plane/Microsoft.GraphRbac/stable/1.6/graphrbac.json -output-folder: _generated -package-name: azure-graphrbac -namespace: azure.graphrbac -no-namespace-folders: true -license-header: MICROSOFT_MIT_NO_VERSION -add-credentials: true -credential-scopes: https://graph.windows.net/ -payload-flattening-threshold: 2 -package-version: 0.61.1 -``` \ No newline at end of file diff --git a/test/services/azure-keyvault/README.md b/test/services/azure-keyvault/README.md deleted file mode 100644 index 2d2f05e7062..00000000000 --- a/test/services/azure-keyvault/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Azure Text Analytics for Python - -> see https://aka.ms/autorest - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - -### Settings -``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/keyvault/data-plane/Microsoft.KeyVault/stable/7.0/keyvault.json -output-folder: _generated -package-name: azure-keyvault -namespace: azure.keyvault -no-namespace-folders: true -license-header: MICROSOFT_MIT_NO_VERSION -enable-xml: true -vanilla: true -clear-output-folder: true -python: true -add-credentials: true -payload-flattening-threshold: 2 -``` \ No newline at end of file diff --git a/test/services/azure-mgmt-network/README.md b/test/services/azure-mgmt-network/README.md deleted file mode 100644 index b5742f63c7b..00000000000 --- a/test/services/azure-mgmt-network/README.md +++ /dev/null @@ -1,1153 +0,0 @@ -# Azure Mgmt Network for Python - -> see https://aka.ms/autorest - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - ---- -# Code Generation - -### Settings -``` yaml -title: NetworkManagementClient -description: Network Client -openapi-type: arm -package-name: azure-mgmt-network -license-header: MICROSOFT_MIT_NO_VERSION -azure-arm: true -clear-output-folder: true -no-namespace-folders: true -pyload-flattening-threshold: 2 -mutiapi: true -directive: - - suppress: RequiredPropertiesMissingInResourceModel - from: applicationGateway.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: applicationSecurityGroup.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: azureFirewall.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: azureFirewallFqdnTag.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: bastionHost.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: checkDnsAvailability.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: ddosCustomPolicy.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: ddosProtectionPlan.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: endpointService.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: expressRouteCircuit.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: expressRouteCrossConnection.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: expressRouteGateway.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: expressRoutePort.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: firewallPolicy.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: ipGroups.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: loadBalancer.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: natGateway.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: networkInterface.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: networkSecurityGroup.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: networkWatcher.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: operation.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: publicIpAddress.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: publicIpPrefix.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: routeFilter.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: routeTable.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: serviceCommunity.json - reason: name, id and type properties are inherited from the upper level - - suppress: AvoidNestedProperties - where: $.definitions.ServiceTagInformation.properties.properties - reason: No x-ms-client-flatten by design - - suppress: RequiredPropertiesMissingInResourceModel - from: usage.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: virtualNetwork.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: serviceEndpointPolicy.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: virtualNetworkTap.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: virtualRouter.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: virtualNetworkGateway.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: privateEndpoint.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: privateLinkService.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: networkProfile.json - reason: name, id and type properties are inherited from the upper level - - suppress: RequiredPropertiesMissingInResourceModel - from: availableDelegations.json - reason: name, id and type properties are inherited from the upper level - - suppress: TrackedResourceListByImmediateParent - reason: Another list APIs naming approach is used over the specs - - suppress: EnumInsteadOfBoolean - reason: Booleans are used by networking APIs - - suppress: GetInOperationName - where: $.paths["/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability"].get.operationId - reason: Customized verb is used for API - - suppress: GetInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/CheckIPAddressAvailability"].get.operationId - reason: Customized verb is used for API - - suppress: PutInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ExpressRoutePorts/{expressRoutePortName}/links/{linkName}"].put.operationId - reason: Child resource is auto-created when top-level resource is created. - - suppress: PutInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey"].put.operationId - reason: Customized verb is used for API - - suppress: PostOperationIdContainsUrlVerb - from: networkWatcher.json - reason: Customized verbs are used for API - - suppress: PostOperationIdContainsUrlVerb - from: expressRouteCircuit.json - reason: Customized verbs are used for API - - suppress: PostOperationIdContainsUrlVerb - from: expressRouteCrossConnection.json - reason: Customized verbs are used for API - - suppress: OperationIdNounVerb - from: vmssPublicIpAddress.json - reason: VMSS specs have custom naming - - suppress: OperationIdNounVerb - from: vmssNetworkInterface.json - reason: VMSS specs have custom naming - - suppress: BodyTopLevelProperties - from: virtualNetworkGateway.json - reason: shipped. fixing this causes breaking change in resource - - suppress: RequiredPropertiesMissingInResourceModel - from: webapplicationfirewall.json - reason: name, id and type properties are inherited from the upper level - - suppress: PostOperationIdContainsUrlVerb - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/getBackendHealthOnDemand"].post.operationId - reason: Customized verb is used for API - - suppress: PostOperationIdContainsUrlVerb - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/vpnConfiguration"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendhealth"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}/effectiveRouteTable"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/query"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/networkConfigurationDiagnostic"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/CheckIPAddressAvailability"].get.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getVpnClientConnectionHealth"].post.operationId - reason: Customized verb is used for API - - suppress: ListInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/supportedSecurityProviders"].get.operationId - reason: Customized verb is used for API - - suppress: GetInOperationName - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/supportedSecurityProviders"].get.operationId - reason: Customized verb is used for API -``` - -```yaml $(multiapi) -batch: - - tag: package-2019-11 - - tag: package-2019-09 - - tag: package-2019-08 - - tag: package-2019-07 - - tag: package-2019-06 - - tag: package-2019-04 - - tag: package-2019-02 - - tag: package-2018-12 - - tag: package-2018-11 - - tag: package-2018-10 - - tag: package-2018-08 - - tag: package-2018-07 - - tag: package-2018-06 - - tag: package-2018-04 - - tag: package-2018-02 - - tag: package-2018-01 - - tag: package-2017-11 - - tag: package-2017-10 - - tag: package-2017-09 - - tag: package-2017-08 - - tag: package-2017-06 - - tag: package-2017-03 - - tag: package-2016-12 - - tag: package-2016-09 - - tag: package-2015-06split -``` - -### Tag: package-2019-11 - -``` yaml $(tag) == 'package-2019-11' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/availableServiceAliases.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/bastionHost.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/firewallPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/ipGroups.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/privateEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/privateLinkService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/serviceTags.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/virtualRouter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-11-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_11_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_11_01 -package-version: '2019-11-01' -``` - -### Tag: package-2019-09 -``` yaml $(tag) == 'package-2019-09' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/availableServiceAliases.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/bastionHost.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/firewallPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/ipGroups.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkWatcherConnectionMonitorV1.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/privateEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/privateLinkService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/serviceTags.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/virtualRouter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-09-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_09_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_09_01 -package-version: '2019-09-01' -``` - -### Tag: package-2019-08 -``` yaml $(tag) == 'package-2019-08' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/availableServiceAliases.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/bastionHost.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/firewallPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkWatcherConnectionMonitorV1.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/privateEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/privateLinkService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/serviceTags.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/virtualRouter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-08-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_08_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_08_01 -package-version: '2019-08-01' -``` - -### Tag: package-2019-07 -``` yaml $(tag) == 'package-2019-07' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/bastionHost.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/firewallPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkWatcherConnectionMonitorV1.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/privateEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/privateLinkService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/serviceTags.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/virtualRouter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-07-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_07_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_07_01 -package-version: '2019-07-01' -``` - -### Tag: package-2019-06 -``` yaml $(tag) == 'package-2019-06' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/bastionHost.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/firewallPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/networkWatcherConnectionMonitorV1.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/privateEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/privateLinkService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/serviceTags.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-06-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_06_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_06_01 -package-version: '2019-06-01' -``` - -### Tag: package-2019-04 -``` yaml $(tag) == 'package-2019-04' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/bastionHost.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/privateEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/privateLinkService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/serviceTags.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-04-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_04_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_04_01 -package-version: '2019-04-01' -``` - -### Tag: package-2019-02 -``` yaml $(tag) == 'package-2019-02' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/interfaceEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/natGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2019-02-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2019_02_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_02_01 -package-version: '2019-02-01' -``` - -### Tag: package-2018-12 -``` yaml $(tag) == 'package-2018-12' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/interfaceEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/vmssPublicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-12-01/webapplicationfirewall.json -namespace: azure.mgmt.network.v2018_12_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_12_01 -package-version: '2018-12-01' -``` - -### Tag: package-2018-11 -``` yaml $(tag) == 'package-2018-11' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/ddosCustomPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/interfaceEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_11_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_11_01 -package-version: '2018-11-01' -``` - -### Tag: package-2018-10 -``` yaml $(tag) == 'package-2018-10' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/interfaceEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-10-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_10_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_10_01 -package-version: '2018-10-01' -``` - -### Tag: package-2018-08 -``` yaml $(tag) == 'package-2018-08' -input-file: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/applicationGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/applicationSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/availableDelegations.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/azureFirewall.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/azureFirewallFqdnTag.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/checkDnsAvailability.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/ddosProtectionPlan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/endpointService.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/expressRouteCircuit.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/expressRouteCrossConnection.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/expressRouteGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/expressRoutePort.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/interfaceEndpoint.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/loadBalancer.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/network.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/networkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/networkProfile.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/networkSecurityGroup.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/networkWatcher.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/operation.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/publicIpAddress.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/publicIpPrefix.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/routeFilter.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/routeTable.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/serviceCommunity.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/serviceEndpointPolicy.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/usage.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/virtualNetwork.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/virtualNetworkTap.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/virtualNetworkGateway.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/virtualWan.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/vmssNetworkInterface.json - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-08-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_08_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_08_01 -package-version: '2018-08-01' -``` - -### Tag: package-2018-07 -``` yaml $(tag) == 'package-2018-07' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/azureFirewall.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/ddosProtectionPlan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/expressRouteCrossConnection.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/publicIpPrefix.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/virtualWan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/vmssPublicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-07-01/serviceEndpointPolicy.json -namespace: azure.mgmt.network.v2018_07_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_07_01 -package-version: '2018-07-01' -``` - -### Tag: package-2018-06 -``` yaml $(tag) == 'package-2018-06' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/azureFirewall.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/ddosProtectionPlan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/expressRouteCrossConnection.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/virtualWan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-06-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_06_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_06_01 -package-version: '2018-06-01' -``` - -### Tag: package-2018-04 -``` yaml $(tag) == 'package-2018-04' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/azureFirewall.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/ddosProtectionPlan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/expressRouteCrossConnection.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/virtualWan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-04-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_04_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_04_01 -package-version: '2018-04-01' -``` - -### Tag: package-2018-02 -``` yaml $(tag) == 'package-2018-02' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/ddosProtectionPlan.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/expressRouteCrossConnection.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-02-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_02_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_02_01 -package-version: '2018-02-01' -``` - -### Tag: package-2018-01 -``` yaml $(tag) == 'package-2018-01' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2018-01-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2018_01_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2018_01_01 -package-version: '2018-01-01' -``` - -### Tag: package-2017-11 -``` yaml $(tag) == 'package-2017-11' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-11-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2017_11_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2017_11_01 -package-version: '2017-11-01' -``` - -### Tag: package-2017-10 -``` yaml $(tag) == 'package-2017-10' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-10-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2017_10_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2017_10_01 -package-version: '2017-10-01' -``` - -### Tag: package-2017-09 -``` yaml $(tag) == 'package-2017-09' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/applicationSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/operation.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-09-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2017_09_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2017_09_01 -package-version: '2017-09-01' -``` - -### Tag: package-2017-08 -``` yaml $(tag) == 'package-2017-08' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-08-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2017_08_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2017_08_01 -package-version: '2017-08-01' -``` - -### Tag: package-2017-06 -``` yaml $(tag) == 'package-2017-06' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/endpointService.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-06-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2017_06_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2017_06_01 -package-version: '2017-06-01' -``` - -### Tag: package-2017-03 -``` yaml $(tag) == 'package-2017-03' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2017-03-01/vmssPublicIpAddress.json -namespace: azure.mgmt.network.v2017_03_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2017_03_01 -package-version: '2017-03-01' -``` - -### Tag: package-2016-12 -``` yaml $(tag) == 'package-2016-12' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/routeFilter.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/serviceCommunity.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-12-01/virtualNetworkGateway.json -namespace: azure.mgmt.network.v2016_12_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2016_12_01 -package-version: '2016-12-01' -``` - -### Tag: package-2016-09 -``` yaml $(tag) == 'package-2016-09' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/vmssNetworkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/networkWatcher.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2016-09-01/virtualNetworkGateway.json -namespace: azure.mgmt.network.v2016_09_01 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2016_09_01 -package-version: '2016-09-01' -``` - -### Tag: package-2015-06split - -The -``` yaml $(tag) == 'package-2015-06split' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/applicationGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/checkDnsAvailability.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/expressRouteCircuit.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/loadBalancer.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/network.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/networkInterface.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/networkSecurityGroup.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/publicIpAddress.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/routeTable.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/usage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/virtualNetwork.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/virtualNetworkGateway.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/network/resource-manager/Microsoft.Network/stable/2015-06-15/vmssNetworkInterface.json -namespace: azure.mgmt.network.v2015_06_15 -output-folder: F:/azure-sdk-for-python/sdk/network/azure-mgmt-network/azure/mgmt/network/v2015_06_15 -package-version: '2015-06-15' -``` \ No newline at end of file diff --git a/test/services/azure-mgmt-resources#features/README.md b/test/services/azure-mgmt-resources#features/README.md deleted file mode 100644 index 82c98ad018b..00000000000 --- a/test/services/azure-mgmt-resources#features/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Azure Mgmt Resources (Features) for Python - -> see https://aka.ms/autorest - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - ---- -# Code Generation - -### Settings -``` yaml -azure-arm: true -license-header: MICROSOFT_MIT_NO_VERSION -package-name: azure-mgmt-resource -payload-flattening-threshold: 2 -clear-output-folder: true -no-namespace-folders: true -verbose: true -debug: true -multiapi: true -``` - -```yaml $(multiapi) -batch: - - tag: package-features-2015-12 -``` -### Tag: package-features-2015-12 -``` yaml $(tag) == 'package-features-2015-12' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/resources/resource-manager/Microsoft.Features/stable/2015-12-01/features.json -namespace: azure.mgmt.resource.features.v2015_12_01 -output-folder: F:/azure-sdk-for-python/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01 -package-version: '2015-12-01' -``` \ No newline at end of file diff --git a/test/services/azure-mgmt-storage/README.md b/test/services/azure-mgmt-storage/README.md deleted file mode 100644 index c3419e79af6..00000000000 --- a/test/services/azure-mgmt-storage/README.md +++ /dev/null @@ -1,164 +0,0 @@ -# Azure Mgmt Storage for Python - -> see https://aka.ms/autorest - -### Setup -```ps -cd C:\work -git clone --recursive https://github.com/Azure/autorest.python.git -cd autorest.python -git checkout azure-core -npm install -``` - -### Generation -```ps -cd -autorest --use=C:/work/autorest.python --version=2.0.4280 -``` - ---- -# Code Generation - -### Settings -``` yaml -package-name: azure-mgmt-storage -license-header: MICROSOFT_MIT_NO_VERSION -azure-arm: true -clear-output-folder: true -no-namespace-folders: true -python: true -payload-flattening-threshold: 2 -multiapi: true -``` - -```yaml $(multiapi) -batch: - - tag: package-2019-06 - - tag: package-2019-04 - - tag: package-2018-11 - - tag: package-2018-07 - - tag: package-2018-03 - - tag: package-2018-02 - - tag: package-2017-10 - - tag: package-2017-06 - - tag: package-2016-12 - - tag: package-2016-01 - - tag: package-2015-06 -``` -### Tag: package-2019-06 -``` yaml $(tag) == 'package-2019-06' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/storage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/blob.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/file.json -namespace: azure.mgmt.storage.v2019_06_01 -output-folder: generated/azure/mgmt/storage/v2019_06_01 -package-version: '2019-06-01' -``` - -### Tag: package-2019-04 -``` yaml $(tag) == 'package-2019-04' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-04-01/storage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-04-01/blob.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-04-01/file.json -namespace: azure.mgmt.storage.v2019_04_01 -output-folder: generated/azure/mgmt/storage/v2019_04_01 -package-version: '2019-04-01' -``` - -### Tag: package-2018-11 - -``` yaml $(tag) == 'package-2018-11' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-11-01/storage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-11-01/blob.json -namespace: azure.mgmt.storage.v2018_11_01 -output-folder: generated/azure/mgmt/storage/v2018_11_01 -package-version: '2018-11-01' -``` - -### Tag: package-2018-07 - -``` yaml $(tag) == 'package-2018-07' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-07-01/storage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-07-01/blob.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/preview/2018-03-01-preview/managementpolicy.json -namespace: azure.mgmt.storage.v2018_07_01 -output-folder: generated/azure/mgmt/storage/v2018_07_01 -package-version: '2018-07-01' -``` - -### Tag: package-2018-03 - -``` yaml $(tag) == 'package-2018-03' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/preview/2018-03-01-preview/storage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/preview/2018-03-01-preview/blob.json -namespace: azure.mgmt.storage.v2018_03_01_preview -output-folder: generated/azure/mgmt/storage/v2018_03_01_preview -package-version: '2018-03-01-preview' -``` - -### Tag: package-2018-02 - -``` yaml $(tag) == 'package-2018-02' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-02-01/storage.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-02-01/blob.json -namespace: azure.mgmt.storage.v2018_02_01 -output-folder: generated/azure/mgmt/storage/v2018_02_01 -package-version: '2018-02-01' -``` - -### Tag: package-2017-10 - -``` yaml $(tag) == 'package-2017-10' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2017-10-01/storage.json -namespace: azure.mgmt.storage.v2017_10_01 -output-folder: generated/azure/mgmt/storage/v2017_10_01 -package-version: '2017-10-01' -``` - -### Tag: package-2017-06 - -``` yaml $(tag) == 'package-2017-06' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2017-06-01/storage.json -namespace: azure.mgmt.storage.v2017_06_01 -output-folder: generated/azure/mgmt/storage/v2017_06_01 -package-version: '2017-06-01' -``` - -### Tag: package-2016-12 - -``` yaml $(tag) == 'package-2016-12' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2016-12-01/storage.json -namespace: azure.mgmt.storage.v2016_12_01 -output-folder: generated/azure/mgmt/storage/v2016_12_01 -package-version: '2016-12-01' -``` - -### Tag: package-2016-01 - -``` yaml $(tag) == 'package-2016-01' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2016-01-01/storage.json -namespace: azure.mgmt.storage.v2016_01_01 -output-folder: generated/azure/mgmt/storage/v2016_01_01 -package-version: '2016-01-01' -``` - -### Tag: package-2015-06 - -``` yaml $(tag) == 'package-2015-06' -input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2015-06-15/storage.json -namespace: azure.mgmt.storage.v2015_06_15 -output-folder: generated/azure/mgmt/storage/v2015_06_15 -package-version: '2015-06-15' -``` \ No newline at end of file diff --git a/test/services/azure-search/README.md b/test/services/azure-search/README.md deleted file mode 100644 index a5f860ef3b5..00000000000 --- a/test/services/azure-search/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# SearchServiceClient - -> see https://aka.ms/autorest - -This is the AutoRest configuration file for SearchServiceClient. - - ---- -## Getting Started - -To build the SDK for SearchServiceClient, simply [Install AutoRest](https://aka.ms/autorest/install) and in this folder, run: - -> `autorest` - -To see additional help and options, run: - -> `autorest --help` ---- - -## Configuration -### Basic Information -These are the global settings for SearchServiceClient. - -``` yaml -opt-in-extensible-enums: true -openapi-type: data-plane -tag: package-2019-05 -``` ---- -# Code Generation - -!!! READ THIS !!! -This swagger is ready for C# and Java. -!!! READ THIS !!! - -https://github.com/Azure/autorest.csharp/blob/6398c8a58af4aaac10e1680ccb58aeb11a86c825/samples/CognitiveSearch/readme.md - -### Settings -``` yaml -title: AzureSearch -input-file: -#- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/search/data-plane/Microsoft.Azure.Search.Service/stable/2019-05-06/searchservice.json -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/search/data-plane/Microsoft.Azure.Search.Data/stable/2019-05-06/searchindex.json -output-folder: _generated -package-name: azure-search -namespace: azure.search -no-namespace-folders: true -license-header: MICROSOFT_MIT_NO_VERSION -enable-xml: true -clear-output-folder: true -python: true -payload-flattening-threshold: 2 -``` \ No newline at end of file diff --git a/test/unittests/test_optional_return_type.py b/test/unittests/test_optional_return_type.py index 4d20cc5cf2d..508914a75cd 100644 --- a/test/unittests/test_optional_return_type.py +++ b/test/unittests/test_optional_return_type.py @@ -5,7 +5,10 @@ # -------------------------------------------------------------------------- import pytest -from autorest.codegen.models import Operation, LROOperation, PagingOperation, SchemaResponse, CodeModel +from autorest.codegen.models import ( + Operation, LROOperation, PagingOperation, SchemaResponse, ParameterList +) + @pytest.fixture def operation(): @@ -13,11 +16,9 @@ def operation(): yaml_data={}, name="optional_return_type_test", description="Operation to test optional return types", - url="http://www.optional_return_type.com", - method="method", - multipart=False, api_versions=set(["2020-05-01"]), - requests=[] + parameters=ParameterList(), + multiple_media_type_parameters=ParameterList(), ) @pytest.fixture @@ -26,11 +27,9 @@ def lro_operation(): yaml_data={}, name="lro_optional_return_type_test", description="LRO Operation to test optional return types", - url="http://www.optional_return_type.com", - method="method", - multipart=False, api_versions=set(["2020-05-01"]), - requests=[] + parameters=ParameterList(), + multiple_media_type_parameters=ParameterList(), ) @pytest.fixture @@ -39,11 +38,9 @@ def paging_operation(): yaml_data={"extensions": {"x-ms-pageable": {}}}, name="paging_optional_return_type_test", description="Paging Operation to test optional return types", - url="http://www.optional_return_type.com", - method="method", - multipart=False, api_versions=set(["2020-05-01"]), - requests=[] + parameters=ParameterList(), + multiple_media_type_parameters=ParameterList(), ) def test_success_with_body_and_fail_no_body(operation): @@ -103,10 +100,6 @@ def test_lro_operation(lro_operation): assert lro_operation.has_optional_return_type is False - lro_initial_function = CodeModel._lro_initial_function(lro_operation) - - assert lro_initial_function.has_optional_return_type is True - def test_paging_operation(paging_operation): paging_operation.responses = [ SchemaResponse( diff --git a/test/unittests/test_sort_schema.py b/test/unittests/test_sort_schema.py index c34d2fc36c9..a0187354a43 100644 --- a/test/unittests/test_sort_schema.py +++ b/test/unittests/test_sort_schema.py @@ -9,7 +9,14 @@ @pytest.fixture def code_model(): - return CodeModel(options={}) + return CodeModel( + show_builders=False, + show_models=True, + show_operations=True, + show_send_request=False, + only_path_and_body_params_positional=False, + options={}, + ) def get_schemas_in_dict_form(schemas): dict_schemas = {} diff --git a/test/vanilla/AcceptanceTests.cs b/test/vanilla/AcceptanceTests.cs deleted file mode 100644 index 1efba33fea3..00000000000 --- a/test/vanilla/AcceptanceTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System.IO; -using AutoRest.Swagger.Tests; -using Xunit; - -namespace AutoRest.Python.Tests -{ - [Collection("AutoRest Python Tests")] - public static class AcceptanceTests - { - private static string ExpectedPath(string file) - { - return Path.Combine("Expected", "AcceptanceTests", file); - } - - private static string SwaggerPath(string file) - { - return Path.Combine("Swagger", file); - } - - [Fact] - public static void SampleTestForGeneratingPython() - { - SwaggerSpecHelper.RunTests( - SwaggerPath("body-complex.json"), ExpectedPath("BodyComplex"), plugin:"Python"); - } - } -} diff --git a/test/vanilla/AcceptanceTests/asynctests/test_file.py b/test/vanilla/AcceptanceTests/asynctests/test_file.py deleted file mode 100644 index 9a262fa111a..00000000000 --- a/test/vanilla/AcceptanceTests/asynctests/test_file.py +++ /dev/null @@ -1,147 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - -from async_generator import yield_, async_generator -import unittest -import subprocess -import sys -import isodate -import tempfile -import io -from datetime import date, datetime, timedelta -import os -from os.path import dirname, pardir, join, realpath - -from msrest.exceptions import DeserializationError - -from bodyfile.aio import AutoRestSwaggerBATFileService - -import pytest - -cwd = dirname(realpath(__file__)) - - -@pytest.fixture -@async_generator -async def client(connection_data_block_size=None): - async with AutoRestSwaggerBATFileService( - base_url="http://localhost:3000", connection_data_block_size=connection_data_block_size - ) as client: - await yield_(client) - -@pytest.fixture -def callback(): - def _callback(response, data_stream, headers): - assert not data_stream.response.internal_response._released - return data_stream - return _callback - -class TestFile(object): - @pytest.mark.asyncio - @pytest.mark.parametrize('client', [1000], indirect=True) - async def test_get_file(self, client): - file_length = 0 - with io.BytesIO() as file_handle: - stream = await client.files.get_file() - total = len(stream) - assert not stream.response.internal_response._released - - async for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - print("Downloading... {}%".format(int(file_length*100/total))) - file_handle.write(data) - - assert file_length != 0 - - sample_file = realpath( - join(cwd, pardir, pardir, pardir, pardir, - "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) - - with open(sample_file, 'rb') as data: - sample_data = hash(data.read()) - assert sample_data == hash(file_handle.getvalue()) - - @pytest.mark.asyncio - @pytest.mark.parametrize('client', [4096], indirect=True) - async def test_get_empty_file(self, client): - file_length = 0 - with io.BytesIO() as file_handle: - stream = await client.files.get_empty_file() - assert len(stream) == 0 - assert not stream.response.internal_response._released - - async for data in stream: - file_length += len(data) - file_handle.write(data) - - assert file_length == 0 - - @pytest.mark.asyncio - @pytest.mark.parametrize('client', [4096], indirect=True) - async def test_files_long_running(self, client): - file_length = 0 - stream = await client.files.get_file_large() - async for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - - assert file_length == 3000 * 1024 * 1024 - - @pytest.mark.asyncio - @pytest.mark.parametrize('client', [None], indirect=True) - async def test_get_file_with_callback(self, client, callback): - file_length = 0 - with io.BytesIO() as file_handle: - stream = await client.files.get_file(cls=callback) - assert len(stream) > 0 - async for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - file_handle.write(data) - - assert file_length != 0 - - sample_file = realpath( - join(cwd, pardir, pardir, pardir, pardir, - "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) - - with open(sample_file, 'rb') as data: - sample_data = hash(data.read()) - assert sample_data == hash(file_handle.getvalue()) - - @pytest.mark.asyncio - @pytest.mark.parametrize('client', [None], indirect=True) - async def test_get_empty_file_with_callback(self, client, callback): - file_length = 0 - with io.BytesIO() as file_handle: - stream = await client.files.get_empty_file(cls=callback) - async for data in stream: - file_length += len(data) - file_handle.write(data) - - assert stream.response.internal_response._released - assert file_length == 0 diff --git a/test/vanilla/AcceptanceTests/asynctests/test_send_request.py b/test/vanilla/AcceptanceTests/asynctests/test_send_request.py deleted file mode 100644 index 9a2a2f3b0e8..00000000000 --- a/test/vanilla/AcceptanceTests/asynctests/test_send_request.py +++ /dev/null @@ -1,247 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 io -import json -import pytest -from azure.core.pipeline.transport import HttpRequest - -from os.path import dirname, pardir, join, realpath -import pytest - -cwd = dirname(realpath(__file__)) - -class TestSendRequest(object): - - @pytest.mark.asyncio - async def test_send_request_with_body_get_model_deserialize(self): - from bodycomplex.aio import AutoRestComplexTestService - from bodycomplex.models import Siamese - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - request = HttpRequest("GET", "/complex/inheritance/valid", - headers={ - 'Accept': 'application/json' - }, - ) - - response = await client._send_request(request) - await response.load_body() - deserialized = Siamese.deserialize(response) - assert 2 == deserialized.id - assert "Siameeee" == deserialized.name - assert -1 == deserialized.hates[1].id - assert "Tomato" == deserialized.hates[1].name - - @pytest.mark.asyncio - async def test_send_request_with_body_get_direct_json(self): - from bodycomplex.aio import AutoRestComplexTestService - from bodycomplex.models import Siamese - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - request = HttpRequest("GET", "/complex/inheritance/valid", - headers={ - 'Accept': 'application/json' - }, - ) - - response = await client._send_request(request) - - data = b'' - async for chunk in response.stream_download(None): - data += chunk - json_response = json.loads(data.decode('utf-8')) - assert 2 == json_response['id'] - assert "Siameeee" == json_response['name'] - assert - 1 == json_response['hates'][1]['id'] - assert "Tomato" == json_response['hates'][1]['name'] - - @pytest.mark.asyncio - async def test_send_request_with_body_put_json_dumps(self): - from bodycomplex.aio import AutoRestComplexTestService - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - siamese_body = { - "id": 2, - "name": "Siameeee", - "color": "green", - "hates": - [ - { - "id": 1, - "name": "Potato", - "food": "tomato" - }, - { - "id": -1, - "name": "Tomato", - "food": "french fries" - } - ], - "breed": "persian" - } - - request = HttpRequest("PUT", "/complex/inheritance/valid", - headers={ - 'Content-Type': 'application/json' - } - ) - request.set_json_body(siamese_body) - - response = await client._send_request(request) - assert response.status_code == 200 - - @pytest.mark.asyncio - async def test_send_request_with_body_serialize(self): - from bodycomplex.aio import AutoRestComplexTestService - from bodycomplex.models import Siamese, Dog - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - siamese = Siamese( - id=2, - name="Siameeee", - color="green", - hates=[ - Dog( - id=1, - name="Potato", - food="tomato" - ), - Dog( - id=-1, - name="Tomato", - food="french fries" - ) - ], - breed="persian" - ) - - request = HttpRequest("PUT", "/complex/inheritance/valid", - headers={ - 'Content-Type': 'application/json' - } - ) - request.set_json_body(siamese.serialize()) - - response = await client._send_request(request) - assert response.status_code == 200 - - @pytest.mark.asyncio - async def test_send_request_with_stream(self): - from bodyfile.aio import AutoRestSwaggerBATFileService - - client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000", connection_data_block_size=1000) - file_length = 0 - with io.BytesIO() as file_handle: - - request = HttpRequest("GET", "http://localhost:3000/files/stream/nonempty", - headers={ - 'Accept': 'image/png, application/json' - }, - ) - - response = await client._send_request(request, stream=True) - assert response.status_code == 200 - - stream = response.stream_download(None) - - total = len(stream) - assert not stream.response.internal_response._released - - async for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - print("Downloading... {}%".format(int(file_length*100/total))) - file_handle.write(data) - - assert file_length != 0 - - sample_file = realpath( - join(cwd, pardir, pardir, pardir, pardir, - "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) - - with open(sample_file, 'rb') as data: - sample_data = hash(data.read()) - assert sample_data == hash(file_handle.getvalue()) - - @pytest.mark.asyncio - async def test_send_request_put_stream(self): - from bodyformdata.aio import AutoRestSwaggerBATFormDataService - - client = AutoRestSwaggerBATFormDataService( - base_url="http://localhost:3000", - ) - - test_string = "Upload file test case" - test_bytes = bytearray(test_string, encoding='utf-8') - with io.BytesIO(test_bytes) as stream_data: - request = HttpRequest("PUT", '/formdata/stream/uploadfile', - headers={ - 'Content-Type': 'application/octet-stream' - }, - data=stream_data, - ) - response = await client._send_request(request) - assert response.status_code == 200 - - @pytest.mark.asyncio - async def test_send_request_with_client_path_format_arguments(self): - from validation.aio import AutoRestValidationTest - - client = AutoRestValidationTest("mySubscriptionId", base_url="http://localhost:3000") - - request = HttpRequest("GET", "/fakepath/{subscriptionId}/123/150", - headers={ - 'Accept': 'application/json' - }, - ) - - response = await client._send_request(request) - assert response.request.url == 'http://localhost:3000/fakepath/mySubscriptionId/123/150' - - @pytest.mark.asyncio - async def test_send_request_full_url(self): - from bodycomplex import AutoRestComplexTestService - from bodycomplex.models import Siamese - - client = AutoRestComplexTestService(base_url="http://fakeUrl") - - request = HttpRequest("GET", "http://localhost:3000/complex/inheritance/valid", - headers={ - 'Accept': 'application/json' - }, - ) - - response = client._send_request(request) - - deserialized = Siamese.deserialize(response) - assert 2 == deserialized.id - assert "Siameeee" == deserialized.name - assert -1 == deserialized.hates[1].id - assert "Tomato" == deserialized.hates[1].name \ No newline at end of file diff --git a/test/vanilla/AcceptanceTests/asynctests/test_url.py b/test/vanilla/AcceptanceTests/asynctests/test_url.py deleted file mode 100644 index 359c44ab503..00000000000 --- a/test/vanilla/AcceptanceTests/asynctests/test_url.py +++ /dev/null @@ -1,284 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - -from async_generator import yield_, async_generator -import unittest -import subprocess -import sys -import isodate -import tempfile -from datetime import date, datetime, timedelta -import os -from os.path import dirname, pardir, join, realpath - -from msrest.exceptions import DeserializationError, ValidationError - -from url.aio import AutoRestUrlTestService -from urlmulticollectionformat.aio import AutoRestUrlMutliCollectionFormatTestService -from url.models import UriColor - -import pytest - - -@pytest.fixture -@async_generator -async def client(): - async with AutoRestUrlTestService('', base_url="http://localhost:3000") as client: - await yield_(client) - -@pytest.fixture -@async_generator -async def multi_client(): - async with AutoRestUrlMutliCollectionFormatTestService("http://localhost:3000") as client: - await yield_(client) - -@pytest.fixture -def test_array_query(): - return ["ArrayQuery1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] - -class TestUrl(object): - - @pytest.mark.asyncio - async def test_byte_empty_and_null(self, client): - await client.paths.byte_empty() - - with pytest.raises(ValidationError): - await client.paths.byte_null(None) - - @pytest.mark.asyncio - async def test_byte_multi_byte(self, client): - u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') - await client.paths.byte_multi_byte(u_bytes) - - @pytest.mark.asyncio - async def test_date_null(self, client): - with pytest.raises(ValidationError): - await client.paths.date_null(None) - - @pytest.mark.asyncio - async def test_date_time_null(self, client): - with pytest.raises(ValidationError): - await client.paths.date_time_null(None) - - @pytest.mark.asyncio - async def test_date_time_valid(self, client): - await client.paths.date_time_valid() - - @pytest.mark.asyncio - async def test_date_valid(self, client): - await client.paths.date_valid() - - @pytest.mark.asyncio - async def test_unix_time_url(self, client): - await client.paths.unix_time_url(datetime(year=2016, month=4, day=13)) - - @pytest.mark.asyncio - async def test_double_decimal(self, client): - await client.paths.double_decimal_negative() - await client.paths.double_decimal_positive() - - @pytest.mark.asyncio - async def test_float_scientific(self, client): - await client.paths.float_scientific_negative() - await client.paths.float_scientific_positive() - - @pytest.mark.asyncio - async def test_get_boolean(self, client): - await client.paths.get_boolean_false() - await client.paths.get_boolean_true() - - @pytest.mark.asyncio - async def test_int(self, client): - await client.paths.get_int_negative_one_million() - await client.paths.get_int_one_million() - - @pytest.mark.asyncio - async def test_get_long(self, client): - await client.paths.get_negative_ten_billion() - await client.paths.get_ten_billion() - - @pytest.mark.asyncio - async def test_string_empty_and_null(self, client): - await client.paths.string_empty() - - with pytest.raises(ValidationError): - await client.paths.string_null(None) - - @pytest.mark.asyncio - async def test_array_csv_in_path(self, client): - test_array = ["ArrayPath1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] - await client.paths.array_csv_in_path(test_array) - - @pytest.mark.asyncio - async def test_string_url_encoded(self, client): - await client.paths.string_url_encoded() - - @pytest.mark.asyncio - async def test_paths_unicode(self, client): - await client.paths.string_unicode() - - @pytest.mark.asyncio - async def test_string_url_non_encoded(self, client): - await client.paths.string_url_non_encoded() - - @pytest.mark.asyncio - async def test_enum_valid(self, client): - await client.paths.enum_valid(UriColor.green_color) - - @pytest.mark.asyncio - async def test_enum_null(self, client): - with pytest.raises(ValidationError): - await client.paths.enum_null(None) - - @pytest.mark.asyncio - async def test_base64_url(self, client): - await client.paths.base64_url("lorem".encode()) - - @pytest.mark.asyncio - async def test_queries_byte(self, client): - await client.queries.byte_empty() - u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') - await client.queries.byte_multi_byte(u_bytes) - await client.queries.byte_null() - - @pytest.mark.asyncio - async def test_queries_date(self, client): - await client.queries.date_null() - await client.queries.date_valid() - - @pytest.mark.asyncio - async def test_queries_date_time(self, client): - await client.queries.date_time_null() - await client.queries.date_time_valid() - - @pytest.mark.asyncio - async def test_queries_double(self, client): - await client.queries.double_null() - await client.queries.double_decimal_negative() - await client.queries.double_decimal_positive() - - @pytest.mark.asyncio - async def test_queries_float_scientific(self, client): - await client.queries.float_scientific_negative() - await client.queries.float_scientific_positive() - await client.queries.float_null() - - @pytest.mark.asyncio - async def test_queries_boolean(self, client): - await client.queries.get_boolean_false() - await client.queries.get_boolean_true() - await client.queries.get_boolean_null() - - @pytest.mark.asyncio - async def test_queries_int(self, client): - await client.queries.get_int_negative_one_million() - await client.queries.get_int_one_million() - await client.queries.get_int_null() - - @pytest.mark.asyncio - async def test_queries_long(self, client): - await client.queries.get_negative_ten_billion() - await client.queries.get_ten_billion() - await client.queries.get_long_null() - - @pytest.mark.asyncio - async def test_queries_string(self, client): - await client.queries.string_empty() - await client.queries.string_null() - await client.queries.string_url_encoded() - - @pytest.mark.asyncio - async def test_queries_enum(self, client): - await client.queries.enum_valid(UriColor.green_color) - await client.queries.enum_null(None) - - @pytest.mark.asyncio - async def test_queries_unicode(self, client): - await client.queries.string_unicode() - - @pytest.mark.asyncio - async def test_array_string_csv(self, client, test_array_query): - await client.queries.array_string_csv_empty([]) - await client.queries.array_string_csv_null(None) - await client.queries.array_string_csv_valid(test_array_query) - - @pytest.mark.asyncio - async def test_array_string_miscellaneous(self, client, test_array_query): - await client.queries.array_string_pipes_valid(test_array_query) - await client.queries.array_string_ssv_valid(test_array_query) - await client.queries.array_string_tsv_valid(test_array_query) - - @pytest.mark.asyncio - async def test_array_string_multi(self, multi_client, test_array_query): - await multi_client.queries.array_string_multi_empty([]) - await multi_client.queries.array_string_multi_null() - await multi_client.queries.array_string_multi_valid(test_array_query) - - @pytest.mark.asyncio - async def test_array_string_no_collection_format(self, client): - await client.queries.array_string_no_collection_format_empty(['hello', 'nihao', 'bonjour']) - - @pytest.mark.asyncio - async def test_get_all_with_values(self, client): - client._config.global_string_path = "globalStringPath" - client._config.global_string_query = "globalStringQuery" - await client.path_items.get_all_with_values( - "pathItemStringPath", - "localStringPath", - "pathItemStringQuery", - "localStringQuery", - ) - - @pytest.mark.asyncio - async def test_get_global_and_local_query_null(self, client): - client._config.global_string_path = "globalStringPath" - await client.path_items.get_global_and_local_query_null( - "pathItemStringPath", - "localStringPath", - "pathItemStringQuery", - None, - ) - - @pytest.mark.asyncio - async def test_get_global_query_null(self, client): - client._config.global_string_path = "globalStringPath" - await client.path_items.get_global_query_null( - "pathItemStringPath", - "localStringPath", - "pathItemStringQuery", - "localStringQuery", - ) - - @pytest.mark.asyncio - async def test_get_local_path_item_query_null(self, client): - client._config.global_string_path = "globalStringPath" - client._config.global_string_query = "globalStringQuery" - await client.path_items.get_local_path_item_query_null( - "pathItemStringPath", - "localStringPath", - None, - None, - ) diff --git a/test/vanilla/AcceptanceTests/conftest.py b/test/vanilla/AcceptanceTests/conftest.py deleted file mode 100644 index 37c36f7c481..00000000000 --- a/test/vanilla/AcceptanceTests/conftest.py +++ /dev/null @@ -1,93 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 glob -import sys -import subprocess -import os -import signal -from os.path import dirname, realpath -from unittest import TestLoader, TextTestRunner - -from os.path import dirname, pardir, join, realpath - -from azure.core.pipeline.policies import SansIOHTTPPolicy - -import pytest - - -cwd = dirname(realpath(__file__)) - -#Ideally this would be in a common helper library shared between the tests -def start_server_process(): - cmd = "node {}/../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) - if os.name == 'nt': #On windows, subprocess creation works without being in the shell - return subprocess.Popen(cmd) - - return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True - -#Ideally this would be in a common helper library shared between the tests -def terminate_server_process(process): - if os.name == 'nt': - process.kill() - else: - os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups - -@pytest.fixture(scope="session") -def testserver(): - """Start the Autorest testserver.""" - server = start_server_process() - yield - terminate_server_process(server) - -# Ignore collection of async tests for Python 2 -collect_ignore = [] -if sys.version_info < (3,5): - collect_ignore.append("asynctests") - - -class CookiePolicy(SansIOHTTPPolicy): - def __init__(self, *args, **kwargs): - self._current_cookie = None - - def on_request(self, request, **kwargs): - # type: (PipelineRequest, Any) -> None - http_request = request.http_request - if self._current_cookie: - http_request.headers["Cookie"] = self._current_cookie - self._current_cookie = None - - def on_response(self, request, response, **kwargs): - # type: (PipelineRequest, PipelineResponse, Any) -> None - http_response = response.http_response - - if "Set-Cookie" in http_response.headers: - self._current_cookie = http_response.headers["Set-Cookie"] - -@pytest.fixture() -def cookie_policy(): - return CookiePolicy() - diff --git a/test/vanilla/AcceptanceTests/test_file.py b/test/vanilla/AcceptanceTests/test_file.py deleted file mode 100644 index 44592572c18..00000000000 --- a/test/vanilla/AcceptanceTests/test_file.py +++ /dev/null @@ -1,149 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 unittest -import subprocess -import sys -import isodate -import tempfile -import io -from datetime import date, datetime, timedelta -import os -from os.path import dirname, pardir, join, realpath - -from msrest.exceptions import DeserializationError - -from bodyfile import AutoRestSwaggerBATFileService - -import pytest - -cwd = dirname(realpath(__file__)) - - -@pytest.fixture -def client(connection_data_block_size): - with AutoRestSwaggerBATFileService( - base_url="http://localhost:3000", connection_data_block_size=connection_data_block_size) as client: - yield client - -@pytest.fixture -def callback(): - def _callback(response, data_stream, headers): - assert not data_stream.response.internal_response._content_consumed - return data_stream - return _callback - -class TestFile(object): - - @pytest.mark.parametrize('connection_data_block_size', [1000]) - def test_get_file(self, client): - file_length = 0 - with io.BytesIO() as file_handle: - stream = client.files.get_file() - total = len(stream) - assert not stream.response.internal_response._content_consumed - - for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - print("Downloading... {}%".format(int(file_length*100/total))) - file_handle.write(data) - - assert file_length != 0 - - sample_file = realpath( - join(cwd, pardir, pardir, pardir, - "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) - - with open(sample_file, 'rb') as data: - sample_data = hash(data.read()) - assert sample_data == hash(file_handle.getvalue()) - - @pytest.mark.parametrize('connection_data_block_size', [4096]) - def test_get_empty_file(self, client): - file_length = 0 - with io.BytesIO() as file_handle: - stream = client.files.get_empty_file() - assert len(stream) == 0 - assert not stream.response.internal_response._content_consumed - - for data in stream: - file_length += len(data) - file_handle.write(data) - - assert file_length == 0 - - @pytest.mark.parametrize('connection_data_block_size', [4096]) - def test_files_long_running(self, client): - file_length = 0 - stream = client.files.get_file_large() - for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - - assert file_length == 3000 * 1024 * 1024 - - @pytest.mark.parametrize('connection_data_block_size', [None]) - def test_get_file_with_callback(self, client, callback): - file_length = 0 - with io.BytesIO() as file_handle: - stream = client.files.get_file(cls=callback) - assert len(stream) > 0 - for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - file_handle.write(data) - - assert file_length != 0 - - sample_file = realpath( - join(cwd, pardir, pardir, pardir, - "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) - - with open(sample_file, 'rb') as data: - sample_data = hash(data.read()) - assert sample_data == hash(file_handle.getvalue()) - - @pytest.mark.parametrize('connection_data_block_size', [None]) - def test_get_empty_file_with_callback(self, client, callback): - file_length = 0 - with io.BytesIO() as file_handle: - stream = client.files.get_empty_file(cls=callback) - for data in stream: - file_length += len(data) - file_handle.write(data) - - assert file_length == 0 - - def test_models(self): - from bodyfile.models import Error - - if sys.version_info >= (3,5): - from bodyfile.models._models_py3 import Error as ErrorPy3 - assert Error == ErrorPy3 - else: - from bodyfile.models._models import Error as ErrorPy2 - assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_http.py b/test/vanilla/AcceptanceTests/test_http.py deleted file mode 100644 index a701712f433..00000000000 --- a/test/vanilla/AcceptanceTests/test_http.py +++ /dev/null @@ -1,429 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 unittest -import subprocess -import sys -import isodate -import tempfile -import requests -from datetime import date, datetime, timedelta -import os -from os.path import dirname, pardir, join, realpath - -import requests - -from azure.core.exceptions import HttpResponseError -from azure.core.pipeline.policies import ContentDecodePolicy, RetryPolicy, HeadersPolicy, RedirectPolicy -from msrest.exceptions import DeserializationError - -from httpinfrastructure import AutoRestHttpInfrastructureTestService -from httpinfrastructure.models import MyException, B, C, D - -import pytest - - -@pytest.fixture() -def client(cookie_policy): - """Create a AutoRestHttpInfrastructureTestService client with test server credentials.""" - policies = [ - HeadersPolicy(), - ContentDecodePolicy(), - RedirectPolicy(), - RetryPolicy(), - cookie_policy - ] - with AutoRestHttpInfrastructureTestService(base_url="http://localhost:3000", policies=policies) as client: - yield client - - -class TestHttp(object): - - def assert_status(self, code, func, *args, **kwargs): - def return_status(pipeline_response, data, headers): - return pipeline_response.http_response.status_code - kwargs['cls'] = return_status - status_code = func(*args, **kwargs) - assert status_code == code - - def assert_raises_with_message(self, msg, func, *args, **kwargs): - try: - func(*args, **kwargs) - pytest.fail() - - except HttpResponseError as err: - assert err.message == msg - - def assert_raises_with_model(self, code, model, func, *args, **kwargs): - try: - func(*args, **kwargs) - pytest.fail() - - except HttpResponseError as err: - if err.model: - assert isinstance(err.model, model) - assert err.response.status_code == code - - def assert_raises_with_status(self, code, func, *args, **kwargs): - try: - func(*args, **kwargs) - pytest.fail() - - except HttpResponseError as err: - - assert err.response.status_code == code - - def assert_raises_with_status_and_message(self, code, msg, func, *args, **kwargs): - try: - func(*args, **kwargs) - pytest.fail() - - except HttpResponseError as err: - assert err.model.message == msg - assert msg in err.message - assert msg in str(err) - assert err.response.status_code == code - - def assert_raises_with_status_and_response_contains(self, code, msg, func, *args, **kwargs): - try: - func(*args, **kwargs) - pytest.fail() - - except HttpResponseError as err: - assert err.response.status_code == code - assert msg in err.response.text() - - def test_get200_model204(self, client): - r = client.multiple_responses.get200_model204_no_model_default_error200_valid() - assert '200' == r.status_code - - self.assert_raises_with_status(201, - client.multiple_responses.get200_model204_no_model_default_error201_invalid) - - self.assert_raises_with_status(202, - client.multiple_responses.get200_model204_no_model_default_error202_none) - - assert client.multiple_responses.get200_model204_no_model_default_error204_valid() is None - - self.assert_raises_with_status_and_message(400, "client error", - client.multiple_responses.get200_model204_no_model_default_error400_valid) - - def test_get200_model201(self, client): - self.assert_status(200, client.multiple_responses.get200_model201_model_default_error200_valid) - - b_model = client.multiple_responses.get200_model201_model_default_error201_valid() - assert b_model is not None - assert b_model.status_code == "201" - assert b_model.text_status_code == "Created" - - self.assert_raises_with_status_and_message(400, "client error", - client.multiple_responses.get200_model201_model_default_error400_valid) - - def test_get200_model_a201_model_c404(self, client): - a_model = client.multiple_responses.get200_model_a201_model_c404_model_d_default_error200_valid() - assert a_model is not None - assert a_model.status_code == "200" - - c_model = client.multiple_responses.get200_model_a201_model_c404_model_d_default_error201_valid() - assert c_model is not None - assert c_model.http_code == "201" - - d_model = client.multiple_responses.get200_model_a201_model_c404_model_d_default_error404_valid() - assert d_model is not None - assert d_model.http_status_code == "404" - - self.assert_raises_with_status_and_message(400, "client error", - client.multiple_responses.get200_model_a201_model_c404_model_d_default_error400_valid) - - def test_get202_none204(self, client): - client.multiple_responses.get202_none204_none_default_error202_none() - client.multiple_responses.get202_none204_none_default_error204_none() - - self.assert_raises_with_status_and_message(400, "client error", - client.multiple_responses.get202_none204_none_default_error400_valid) - - client.multiple_responses.get202_none204_none_default_none202_invalid() - client.multiple_responses.get202_none204_none_default_none204_none() - - self.assert_raises_with_status(400, - client.multiple_responses.get202_none204_none_default_none400_none) - - self.assert_raises_with_status(400, - client.multiple_responses.get202_none204_none_default_none400_invalid) - - def test_get_default_model_a200(self, client): - self.assert_status(200, client.multiple_responses.get_default_model_a200_valid) - - assert client.multiple_responses.get_default_model_a200_none() is None - client.multiple_responses.get_default_model_a200_valid() - client.multiple_responses.get_default_model_a200_none() - - def test_get_default_model_a400(self, client): - self.assert_raises_with_model(400, MyException, - client.multiple_responses.get_default_model_a400_valid) - - self.assert_raises_with_model(400, MyException, - client.multiple_responses.get_default_model_a400_none) - - def test_get_default_none200(self, client): - client.multiple_responses.get_default_none200_invalid() - client.multiple_responses.get_default_none200_none() - - def test_get_default_none400(self, client): - self.assert_raises_with_status(400, - client.multiple_responses.get_default_none400_invalid) - - self.assert_raises_with_status(400, - client.multiple_responses.get_default_none400_none) - - def test_get200_model_a200(self, client): - assert client.multiple_responses.get200_model_a200_none() is None - - self.assert_status(200, client.multiple_responses.get200_model_a200_valid) - - assert client.multiple_responses.get200_model_a200_invalid().status_code is None - - def test_get200_model_a400(self, client): - self.assert_raises_with_status(400, - client.multiple_responses.get200_model_a400_none) - self.assert_raises_with_status(400, - client.multiple_responses.get200_model_a400_valid) - self.assert_raises_with_status(400, - client.multiple_responses.get200_model_a400_invalid) - - def test_get200_model_a202(self, client): - self.assert_raises_with_status(202, - client.multiple_responses.get200_model_a202_valid) - - def test_server_error_status_codes_501(self, client): - - self.assert_raises_with_status(requests.codes.not_implemented, - client.http_server_failure.head501) - - self.assert_raises_with_status(requests.codes.not_implemented, - client.http_server_failure.get501) - - def test_server_error_status_codes_505(self, client): - self.assert_raises_with_status(requests.codes.http_version_not_supported, - client.http_server_failure.post505) - - self.assert_raises_with_status(requests.codes.http_version_not_supported, - client.http_server_failure.delete505) - - def test_retry_status_codes_408(self, client): - client.http_retry.head408() - - def test_retry_status_codes_502(self, client): - client.http_retry.get502() - - # TODO, 4042586: Support options operations in swagger modeler - #client.http_retry.options429() - - def test_retry_status_codes_500(self, client): - client.http_retry.put500() - client.http_retry.patch500() - - def test_retry_status_codes_503(self, client): - client.http_retry.post503() - client.http_retry.delete503() - - def test_retry_status_codes_504(self, client): - client.http_retry.put504() - client.http_retry.patch504() - - def test_error_status_codes_400(self, client): - self.assert_raises_with_status(requests.codes.bad_request, - client.http_client_failure.head400) - - self.assert_raises_with_status(requests.codes.bad_request, - client.http_client_failure.get400) - - # TODO, 4042586: Support options operations in swagger modeler - #self.assert_raises_with_status(requests.codes.bad_request, - # client.http_client_failure.options400) - - self.assert_raises_with_status(requests.codes.bad_request, - client.http_client_failure.put400) - - self.assert_raises_with_status(requests.codes.bad_request, - client.http_client_failure.patch400) - - self.assert_raises_with_status(requests.codes.bad_request, - client.http_client_failure.post400) - - self.assert_raises_with_status(requests.codes.bad_request, - client.http_client_failure.delete400) - - def test_error_status_codes_401(self, client): - self.assert_raises_with_status(requests.codes.unauthorized, - client.http_client_failure.head401) - - def test_error_status_codes_402(self, client): - self.assert_raises_with_status(requests.codes.payment_required, - client.http_client_failure.get402) - - def test_error_status_codes_403(self, client): - # TODO, 4042586: Support options operations in swagger modeler - #self.assert_raises_with_status(requests.codes.forbidden, - # client.http_client_failure.options403) - - self.assert_raises_with_status(requests.codes.forbidden, - client.http_client_failure.get403) - - def test_error_status_codes_404(self, client): - self.assert_raises_with_status(requests.codes.not_found, - client.http_client_failure.put404) - - def test_error_status_codes_405(self, client): - self.assert_raises_with_status(requests.codes.method_not_allowed, - client.http_client_failure.patch405) - - def test_error_status_codes_406(self, client): - self.assert_raises_with_status(requests.codes.not_acceptable, - client.http_client_failure.post406) - - def test_error_status_codes_407(self, client): - self.assert_raises_with_status(requests.codes.proxy_authentication_required, - client.http_client_failure.delete407) - - def test_error_status_codes_409(self, client): - self.assert_raises_with_status(requests.codes.conflict, - client.http_client_failure.put409) - - def test_error_status_codes_410(self, client): - self.assert_raises_with_status(requests.codes.gone, - client.http_client_failure.head410) - - def test_error_status_codes_411(self, client): - self.assert_raises_with_status(requests.codes.length_required, - client.http_client_failure.get411) - - # TODO, 4042586: Support options operations in swagger modeler - #self.assert_raises_with_status(requests.codes.precondition_failed, - # client.http_client_failure.options412) - - self.assert_raises_with_status(requests.codes.precondition_failed, - client.http_client_failure.get412) - - self.assert_raises_with_status(requests.codes.request_entity_too_large, - client.http_client_failure.put413) - - self.assert_raises_with_status(requests.codes.request_uri_too_large, - client.http_client_failure.patch414) - - self.assert_raises_with_status(requests.codes.unsupported_media, - client.http_client_failure.post415) - - self.assert_raises_with_status(requests.codes.requested_range_not_satisfiable, - client.http_client_failure.get416) - - self.assert_raises_with_status(requests.codes.expectation_failed, - client.http_client_failure.delete417) - - self.assert_raises_with_status(429, - client.http_client_failure.head429) - - def test_redirect_to_300(self, client): - self.assert_status(200, client.http_redirects.get300) - - def test_redirect_to_301(self, client): - self.assert_status(200, client.http_redirects.head301) - self.assert_status(200, client.http_redirects.get301) - self.assert_status(requests.codes.moved_permanently, client.http_redirects.put301) - - def test_redirect_to_302(self, client): - self.assert_status(200, client.http_redirects.head302) - self.assert_status(200, client.http_redirects.get302) - self.assert_status(requests.codes.found, client.http_redirects.patch302) - - def test_redicret_to_303(self, client): - self.assert_status(200, client.http_redirects.post303) - - def test_redirect_to_307(self, client): - self.assert_status(200, client.http_redirects.head307) - self.assert_status(200, client.http_redirects.get307) - - # TODO, 4042586: Support options operations in swagger modeler - #self.assert_status(200, client.http_redirects.options307) - self.assert_status(200, client.http_redirects.put307) - self.assert_status(200, client.http_redirects.post307) - self.assert_status(200, client.http_redirects.patch307) - self.assert_status(200, client.http_redirects.delete307) - - - - def test_bad_request_status_assert(self, client): - self.assert_raises_with_message("Operation returned an invalid status 'Bad Request'", - client.http_failure.get_empty_error) - - def test_no_error_model_status_assert(self, client): - self.assert_raises_with_status_and_response_contains(requests.codes.bad_request, "NoErrorModel", - client.http_failure.get_no_model_error) - - def test_success_status_codes_200(self, client): - client.http_success.head200() - assert client.http_success.get200() - client.http_success.put200() - client.http_success.post200() - client.http_success.patch200() - client.http_success.delete200() - - # TODO, 4042586: Support options operations in swagger modeler - #assert client.http_success.options200() - - def test_success_status_codes_201(self, client): - client.http_success.put201() - client.http_success.post201() - - def test_success_status_codes_202(self, client): - client.http_success.put202() - client.http_success.post202() - client.http_success.patch202() - client.http_success.delete202() - - def test_success_status_codes_204(self, client): - client.http_success.head204() - client.http_success.put204() - client.http_success.post204() - client.http_success.delete204() - client.http_success.patch204() - - def test_success_status_codes_404(self, client): - client.http_success.head404() - - def test_empty_no_content(self, client): - self.assert_raises_with_status(requests.codes.bad_request, - client.http_failure.get_no_model_empty) - - def test_models(self): - from httpinfrastructure.models import Error - - if sys.version_info >= (3,5): - from httpinfrastructure.models._models_py3 import Error as ErrorPy3 - assert Error == ErrorPy3 - else: - from httpinfrastructure.models._models import Error as ErrorPy2 - assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_send_request.py b/test/vanilla/AcceptanceTests/test_send_request.py deleted file mode 100644 index 93b13ac838e..00000000000 --- a/test/vanilla/AcceptanceTests/test_send_request.py +++ /dev/null @@ -1,237 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 io -import json - -from azure.core.pipeline.transport import HttpRequest - -from os.path import dirname, pardir, join, realpath -import pytest - -cwd = dirname(realpath(__file__)) - - -class TestSendRequest(object): - - def test_send_request_with_body_get_model_deserialize(self): - from bodycomplex import AutoRestComplexTestService - from bodycomplex.models import Siamese - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - request = HttpRequest("GET", "/complex/inheritance/valid", - headers={ - 'Accept': 'application/json' - }, - ) - - response = client._send_request(request) - - deserialized = Siamese.deserialize(response) - assert 2 == deserialized.id - assert "Siameeee" == deserialized.name - assert -1 == deserialized.hates[1].id - assert "Tomato" == deserialized.hates[1].name - - def test_send_request_with_body_get_direct_json(self): - from bodycomplex import AutoRestComplexTestService - from bodycomplex.models import Siamese - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - request = HttpRequest("GET", "/complex/inheritance/valid", - headers={ - 'Accept': 'application/json' - }, - ) - - response = client._send_request(request) - - data = b''.join([chunk for chunk in response.stream_download(None)]).decode('utf-8') - json_response = json.loads(data) - assert 2 == json_response['id'] - assert "Siameeee" == json_response['name'] - assert - 1 == json_response['hates'][1]['id'] - assert "Tomato" == json_response['hates'][1]['name'] - - def test_send_request_with_body_put_json_dumps(self): - from bodycomplex import AutoRestComplexTestService - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - siamese_body = { - "id": 2, - "name": "Siameeee", - "color": "green", - "hates": - [ - { - "id": 1, - "name": "Potato", - "food": "tomato" - }, - { - "id": -1, - "name": "Tomato", - "food": "french fries" - } - ], - "breed": "persian" - } - - request = HttpRequest("PUT", "/complex/inheritance/valid", - headers={ - 'Content-Type': 'application/json' - } - ) - request.set_json_body(siamese_body) - - response = client._send_request(request) - assert response.status_code == 200 - - def test_send_request_with_body_serialize(self): - from bodycomplex import AutoRestComplexTestService - from bodycomplex.models import Siamese, Dog - - client = AutoRestComplexTestService(base_url="http://localhost:3000") - - siamese = Siamese( - id=2, - name="Siameeee", - color="green", - hates=[ - Dog( - id=1, - name="Potato", - food="tomato" - ), - Dog( - id=-1, - name="Tomato", - food="french fries" - ) - ], - breed="persian" - ) - - request = HttpRequest("PUT", "/complex/inheritance/valid", - headers={ - 'Content-Type': 'application/json' - } - ) - request.set_json_body(siamese.serialize()) - response = client._send_request(request) - assert response.status_code == 200 - - def test_send_request_get_stream(self): - from bodyfile import AutoRestSwaggerBATFileService - - client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000", connection_data_block_size=1000) - file_length = 0 - with io.BytesIO() as file_handle: - - request = HttpRequest("GET", "/files/stream/nonempty", - headers={ - 'Accept': 'image/png, application/json' - }, - ) - - response = client._send_request(request, stream=True) - assert response.status_code == 200 - - stream = response.stream_download(None) # want to make pipeline client an optional param in azure-core - - total = len(stream) - assert not stream.response.internal_response._content_consumed - - for data in stream: - assert 0 < len(data) <= stream.block_size - file_length += len(data) - print("Downloading... {}%".format(int(file_length*100/total))) - file_handle.write(data) - - assert file_length != 0 - - sample_file = realpath( - join(cwd, pardir, pardir, pardir, - "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) - - with open(sample_file, 'rb') as data: - sample_data = hash(data.read()) - assert sample_data == hash(file_handle.getvalue()) - - def test_send_request_put_stream(self): - from bodyformdata import AutoRestSwaggerBATFormDataService - - client = AutoRestSwaggerBATFormDataService( - base_url="http://localhost:3000", - ) - - test_string = "Upload file test case" - test_bytes = bytearray(test_string, encoding='utf-8') - with io.BytesIO(test_bytes) as stream_data: - request = HttpRequest("PUT", '/formdata/stream/uploadfile', - headers={ - 'Content-Type': 'application/octet-stream' - }, - data=stream_data, - ) - response = client._send_request(request) - assert response.status_code == 200 - - def test_send_request_with_client_path_format_arguments(self): - from validation import AutoRestValidationTest - - client = AutoRestValidationTest("mySubscriptionId", base_url="http://localhost:3000") - - request = HttpRequest("GET", "/fakepath/{subscriptionId}/123/150", - headers={ - 'Accept': 'application/json' - }, - ) - - response = client._send_request(request) - assert response.request.url == 'http://localhost:3000/fakepath/mySubscriptionId/123/150' - - def test_send_request_full_url(self): - from bodycomplex import AutoRestComplexTestService - from bodycomplex.models import Siamese - - client = AutoRestComplexTestService(base_url="http://fakeUrl") - - request = HttpRequest("GET", "http://localhost:3000/complex/inheritance/valid", - headers={ - 'Accept': 'application/json' - }, - ) - - response = client._send_request(request) - - deserialized = Siamese.deserialize(response) - assert 2 == deserialized.id - assert "Siameeee" == deserialized.name - assert -1 == deserialized.hates[1].id - assert "Tomato" == deserialized.hates[1].name diff --git a/test/vanilla/AcceptanceTests/test_zzz.py b/test/vanilla/AcceptanceTests/test_zzz.py deleted file mode 100644 index 3165114d450..00000000000 --- a/test/vanilla/AcceptanceTests/test_zzz.py +++ /dev/null @@ -1,90 +0,0 @@ -# -------------------------------------------------------------------------- -# -# 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 sys -import datetime -import os -import platform -import warnings - -from report import AutoRestReportService - - -class TestAcceptance(object): - - def test_ensure_coverage(self): - client = AutoRestReportService(base_url="http://localhost:3000") - report = client.get_report(platform.python_version()) - optional_report = client.get_optional_report(platform.python_version()) - - # Add tests that wont be supported due to the nature of Python here - not_supported = {} - - # Please add missing features or failing tests here - missing_features_or_bugs = { - 'ConstantsInBody': 1, # https://github.com/Azure/autorest.modelerfour/issues/83 - "LLCRequiredToOptional": 1, # adding in LLC PR - } - - print("Coverage:") - self._print_report(report, not_supported, missing_features_or_bugs) - - missing_features_or_bugs = { - "putDateTimeMaxLocalNegativeOffset": 1, # Python doesn't support year 1000 - "putDateTimeMinLocalPositiveOffset": 1, # Python doesn't support BC time - '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: - missing_features_or_bugs[name] = 1; # https://github.com/Azure/azure-sdk-for-python/pull/9322 - if "Multiapi" in name: - # multiapi 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) - - - def _print_report(self, report, not_supported=None, missing_features_or_bugs=None): - if not_supported: - report.update(not_supported) - for s in not_supported.keys(): - print("IGNORING {0}".format(s)) - - if missing_features_or_bugs: - report.update(missing_features_or_bugs) - for s in missing_features_or_bugs.keys(): - print("PENDING {0}".format(s)) - - failed = [k for k, v in report.items() if v == 0] - for s in failed: - print("FAILED TO EXECUTE {0}".format(s)) - - total_tests = len(report) - warnings.warn ("The test coverage is {0}/{1}.".format(total_tests - len(failed), total_tests)) - - assert 0 == len(failed) diff --git a/test/vanilla/Expected/AcceptanceTests/.gitattributes b/test/vanilla/Expected/AcceptanceTests/.gitattributes deleted file mode 100644 index aa9962141fb..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.py eol=lf \ No newline at end of file diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_additional_properties_client.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_additional_properties_client.py deleted file mode 100644 index be3c4685160..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_additional_properties_client.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AdditionalPropertiesClientConfiguration -from .operations import PetsOperations -from . import models - - -class AdditionalPropertiesClient(object): - """Test Infrastructure for AutoRest. - - :ivar pets: PetsOperations operations - :vartype pets: additionalproperties.operations.PetsOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AdditionalPropertiesClientConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.pets = PetsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AdditionalPropertiesClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_additional_properties_client.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_additional_properties_client.py deleted file mode 100644 index 1f45976e10b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_additional_properties_client.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AdditionalPropertiesClientConfiguration -from .operations import PetsOperations -from .. import models - - -class AdditionalPropertiesClient(object): - """Test Infrastructure for AutoRest. - - :ivar pets: PetsOperations operations - :vartype pets: additionalproperties.aio.operations.PetsOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AdditionalPropertiesClientConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.pets = PetsOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AdditionalPropertiesClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py deleted file mode 100644 index 866f2e84b14..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py +++ /dev/null @@ -1,346 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PetsOperations: - """PetsOperations 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: ~additionalproperties.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 create_ap_true(self, create_parameters: "_models.PetAPTrue", **kwargs: Any) -> "_models.PetAPTrue": - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPTrue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPTrue, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPTrue - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPTrue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPTrue") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPTrue", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_true.metadata = {"url": "/additionalProperties/true"} # type: ignore - - @distributed_trace_async - async def create_cat_ap_true(self, create_parameters: "_models.CatAPTrue", **kwargs: Any) -> "_models.CatAPTrue": - """Create a CatAPTrue which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.CatAPTrue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CatAPTrue, or the result of cls(response) - :rtype: ~additionalproperties.models.CatAPTrue - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.CatAPTrue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_cat_ap_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "CatAPTrue") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("CatAPTrue", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_cat_ap_true.metadata = {"url": "/additionalProperties/true-subclass"} # type: ignore - - @distributed_trace_async - async def create_ap_object(self, create_parameters: "_models.PetAPObject", **kwargs: Any) -> "_models.PetAPObject": - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPObject - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPObject, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPObject - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPObject"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPObject") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPObject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_object.metadata = {"url": "/additionalProperties/type/object"} # type: ignore - - @distributed_trace_async - async def create_ap_string(self, create_parameters: "_models.PetAPString", **kwargs: Any) -> "_models.PetAPString": - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPString - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPString, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPString - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPString"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPString") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPString", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_string.metadata = {"url": "/additionalProperties/type/string"} # type: ignore - - @distributed_trace_async - async def create_ap_in_properties( - self, create_parameters: "_models.PetAPInProperties", **kwargs: Any - ) -> "_models.PetAPInProperties": - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPInProperties - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPInProperties, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPInProperties - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInProperties"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_in_properties.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPInProperties") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPInProperties", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_in_properties.metadata = {"url": "/additionalProperties/in/properties"} # type: ignore - - @distributed_trace_async - async def create_ap_in_properties_with_ap_string( - self, create_parameters: "_models.PetAPInPropertiesWithAPString", **kwargs: Any - ) -> "_models.PetAPInPropertiesWithAPString": - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPInPropertiesWithAPString - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPInPropertiesWithAPString, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPInPropertiesWithAPString - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInPropertiesWithAPString"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_in_properties_with_ap_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPInPropertiesWithAPString") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPInPropertiesWithAPString", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_in_properties_with_ap_string.metadata = {"url": "/additionalProperties/in/properties/with/additionalProperties/string"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py deleted file mode 100644 index 754d2741cf3..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py +++ /dev/null @@ -1,376 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PetsOperations(object): - """PetsOperations 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: ~additionalproperties.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 create_ap_true( - self, - create_parameters, # type: "_models.PetAPTrue" - **kwargs # type: Any - ): - # type: (...) -> "_models.PetAPTrue" - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPTrue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPTrue, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPTrue - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPTrue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPTrue") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPTrue", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_true.metadata = {"url": "/additionalProperties/true"} # type: ignore - - @distributed_trace - def create_cat_ap_true( - self, - create_parameters, # type: "_models.CatAPTrue" - **kwargs # type: Any - ): - # type: (...) -> "_models.CatAPTrue" - """Create a CatAPTrue which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.CatAPTrue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CatAPTrue, or the result of cls(response) - :rtype: ~additionalproperties.models.CatAPTrue - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.CatAPTrue"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_cat_ap_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "CatAPTrue") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("CatAPTrue", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_cat_ap_true.metadata = {"url": "/additionalProperties/true-subclass"} # type: ignore - - @distributed_trace - def create_ap_object( - self, - create_parameters, # type: "_models.PetAPObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.PetAPObject" - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPObject - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPObject, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPObject - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPObject"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPObject") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPObject", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_object.metadata = {"url": "/additionalProperties/type/object"} # type: ignore - - @distributed_trace - def create_ap_string( - self, - create_parameters, # type: "_models.PetAPString" - **kwargs # type: Any - ): - # type: (...) -> "_models.PetAPString" - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPString - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPString, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPString - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPString"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPString") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPString", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_string.metadata = {"url": "/additionalProperties/type/string"} # type: ignore - - @distributed_trace - def create_ap_in_properties( - self, - create_parameters, # type: "_models.PetAPInProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.PetAPInProperties" - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPInProperties - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPInProperties, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPInProperties - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInProperties"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_in_properties.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPInProperties") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPInProperties", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_in_properties.metadata = {"url": "/additionalProperties/in/properties"} # type: ignore - - @distributed_trace - def create_ap_in_properties_with_ap_string( - self, - create_parameters, # type: "_models.PetAPInPropertiesWithAPString" - **kwargs # type: Any - ): - # type: (...) -> "_models.PetAPInPropertiesWithAPString" - """Create a Pet which contains more properties than what is defined. - - :param create_parameters: - :type create_parameters: ~additionalproperties.models.PetAPInPropertiesWithAPString - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAPInPropertiesWithAPString, or the result of cls(response) - :rtype: ~additionalproperties.models.PetAPInPropertiesWithAPString - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInPropertiesWithAPString"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_ap_in_properties_with_ap_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_parameters, "PetAPInPropertiesWithAPString") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAPInPropertiesWithAPString", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_ap_in_properties_with_ap_string.metadata = {"url": "/additionalProperties/in/properties/with/additionalProperties/string"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/setup.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/setup.py deleted file mode 100644 index 683ec3268f7..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "additionalpropertiesclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AdditionalPropertiesClient", - author_email="", - url="", - keywords=["Swagger", "AdditionalPropertiesClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.py deleted file mode 100644 index 33f52a30e0c..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AnythingClientConfiguration -from .operations import AnythingClientOperationsMixin - - -class AnythingClient(AnythingClientOperationsMixin): - """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AnythingClientConfiguration(**kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AnythingClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py deleted file mode 100644 index bbbc9610eaa..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py +++ /dev/null @@ -1,62 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - -from ._configuration import AnythingClientConfiguration -from .operations import AnythingClientOperationsMixin - - -class AnythingClient(AnythingClientOperationsMixin): - """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AnythingClientConfiguration(**kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AnythingClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py deleted file mode 100644 index f2a0a078dfa..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py +++ /dev/null @@ -1,278 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AnythingClientOperationsMixin: - @distributed_trace_async - async def get_object(self, **kwargs: Any) -> Any: - """Basic get that returns an object as anything. Returns object { 'message': 'An object was - successfully returned' }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_object.metadata = {"url": "/anything/object"} # type: ignore - - @distributed_trace_async - async def put_object(self, input: Any, **kwargs: Any) -> None: - """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything - else to get an object error. - - :param input: Pass in {'foo': 'bar'} for a 200, anything else for an object error. - :type input: any - :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/json") - - # Construct URL - url = self.put_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_object.metadata = {"url": "/anything/object"} # type: ignore - - @distributed_trace_async - async def get_string(self, **kwargs: Any) -> Any: - """Basic get that returns an string as anything. Returns string 'foo'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string.metadata = {"url": "/anything/string"} # type: ignore - - @distributed_trace_async - async def put_string(self, input: Any, **kwargs: Any) -> None: - """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to - get an object error. - - :param input: Pass in 'anything' for a 200, anything else for an object error. - :type input: any - :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/json") - - # Construct URL - url = self.put_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_string.metadata = {"url": "/anything/string"} # type: ignore - - @distributed_trace_async - async def get_array(self, **kwargs: Any) -> Any: - """Basic get that returns an array as anything. Returns string ['foo', 'bar']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array.metadata = {"url": "/anything/array"} # type: ignore - - @distributed_trace_async - async def put_array(self, input: Any, **kwargs: Any) -> None: - """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else - to get an object error. - - :param input: Pass in ['foo', 'bar'] for a 200, anything else for an object error. - :type input: any - :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/json") - - # Construct URL - url = self.put_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_array.metadata = {"url": "/anything/array"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py deleted file mode 100644 index f076092a8fa..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py +++ /dev/null @@ -1,306 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -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]] - - -class AnythingClientOperationsMixin(object): - @distributed_trace - def get_object( - self, **kwargs # type: Any - ): - # type: (...) -> Any - """Basic get that returns an object as anything. Returns object { 'message': 'An object was - successfully returned' }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_object.metadata = {"url": "/anything/object"} # type: ignore - - @distributed_trace - def put_object( - self, - input, # type: Any - **kwargs # type: Any - ): - # type: (...) -> None - """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything - else to get an object error. - - :param input: Pass in {'foo': 'bar'} for a 200, anything else for an object error. - :type input: any - :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/json") - - # Construct URL - url = self.put_object.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_object.metadata = {"url": "/anything/object"} # type: ignore - - @distributed_trace - def get_string( - self, **kwargs # type: Any - ): - # type: (...) -> Any - """Basic get that returns an string as anything. Returns string 'foo'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string.metadata = {"url": "/anything/string"} # type: ignore - - @distributed_trace - def put_string( - self, - input, # type: Any - **kwargs # type: Any - ): - # type: (...) -> None - """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to - get an object error. - - :param input: Pass in 'anything' for a 200, anything else for an object error. - :type input: any - :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/json") - - # Construct URL - url = self.put_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_string.metadata = {"url": "/anything/string"} # type: ignore - - @distributed_trace - def get_array( - self, **kwargs # type: Any - ): - # type: (...) -> Any - """Basic get that returns an array as anything. Returns string ['foo', 'bar']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array.metadata = {"url": "/anything/array"} # type: ignore - - @distributed_trace - def put_array( - self, - input, # type: Any - **kwargs # type: Any - ): - # type: (...) -> None - """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else - to get an object error. - - :param input: Pass in ['foo', 'bar'] for a 200, anything else for an object error. - :type input: any - :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/json") - - # Construct URL - url = self.put_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_array.metadata = {"url": "/anything/array"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/setup.py b/test/vanilla/Expected/AcceptanceTests/Anything/setup.py deleted file mode 100644 index aad55e23843..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Anything/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "anythingclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AnythingClient", - author_email="", - url="", - keywords=["Swagger", "AnythingClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/_auto_rest_swagger_bat_array_service.py b/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/_auto_rest_swagger_bat_array_service.py deleted file mode 100644 index cddcd3a7b3a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/_auto_rest_swagger_bat_array_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATArrayServiceConfiguration -from .operations import ArrayOperations -from . import models - - -class AutoRestSwaggerBATArrayService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar array: ArrayOperations operations - :vartype array: bodyarray.operations.ArrayOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATArrayService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_auto_rest_swagger_bat_array_service.py b/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_auto_rest_swagger_bat_array_service.py deleted file mode 100644 index b45e9cb0042..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_auto_rest_swagger_bat_array_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATArrayServiceConfiguration -from .operations import ArrayOperations -from .. import models - - -class AutoRestSwaggerBATArrayService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar array: ArrayOperations operations - :vartype array: bodyarray.aio.operations.ArrayOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATArrayService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py deleted file mode 100644 index a3c2f2391d2..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py +++ /dev/null @@ -1,3018 +0,0 @@ -# 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 datetime -from typing import Any, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArrayOperations: - """ArrayOperations 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: ~bodyarray.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 get_null(self, **kwargs: Any) -> List[int]: - """Get null array value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/array/null"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> List[int]: - """Get invalid array [1, 2, 3. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/array/invalid"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> List[int]: - """Get empty array value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace_async - async def put_empty(self, array_body: List[str], **kwargs: Any) -> None: - """Set array value empty []. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace_async - async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: - """Get boolean array value [true, false, false, true]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace_async - async def put_boolean_tfft(self, array_body: List[bool], **kwargs: Any) -> None: - """Set array value empty [true, false, false, true]. - - :param array_body: - :type array_body: list[bool] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bool]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace_async - async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: - """Get boolean array value [true, null, false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore - - @distributed_trace_async - async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: - """Get boolean array value [true, 'boolean', false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore - - @distributed_trace_async - async def get_integer_valid(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def put_integer_valid(self, array_body: List[int], **kwargs: Any) -> None: - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[int] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[int]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore - - @distributed_trace_async - async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore - - @distributed_trace_async - async def get_long_valid(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def put_long_valid(self, array_body: List[int], **kwargs: Any) -> None: - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[long] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[long]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: - """Get long array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore - - @distributed_trace_async - async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: - """Get long array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore - - @distributed_trace_async - async def get_float_valid(self, **kwargs: Any) -> List[float]: - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def put_float_valid(self, array_body: List[float], **kwargs: Any) -> None: - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore - - @distributed_trace_async - async def get_double_valid(self, **kwargs: Any) -> List[float]: - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def put_double_valid(self, array_body: List[float], **kwargs: Any) -> None: - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore - - @distributed_trace_async - async def get_string_valid(self, **kwargs: Any) -> List[str]: - """Get string array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_string_valid(self, array_body: List[str], **kwargs: Any) -> None: - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.FooEnum"]]: - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of FooEnum, or the result of cls(response) - :rtype: list[str or ~bodyarray.models.FooEnum] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_enum_valid(self, array_body: List[Union[str, "_models.FooEnum"]], **kwargs: Any) -> None: - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~bodyarray.models.FooEnum] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.Enum0"]]: - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Enum0, or the result of cls(response) - :rtype: list[str or ~bodyarray.models.Enum0] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_string_enum_valid(self, array_body: List[Union[str, "_models.Enum1"]], **kwargs: Any) -> None: - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~bodyarray.models.Enum1] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_string_with_null(self, **kwargs: Any) -> List[str]: - """Get string array value ['foo', null, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore - - @distributed_trace_async - async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: - """Get string array value ['foo', 123, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore - - @distributed_trace_async - async def get_uuid_valid(self, **kwargs: Any) -> List[str]: - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace_async - async def put_uuid_valid(self, array_body: List[str], **kwargs: Any) -> None: - """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace_async - async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: - """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace_async - async def put_date_valid(self, array_body: List[datetime.date], **kwargs: Any) -> None: - """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :param array_body: - :type array_body: list[~datetime.date] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[date]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace_async - async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: - """Get date array value ['2012-01-01', null, '1776-07-04']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: - """Get date array value ['2011-03-22', 'date']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace_async - async def put_date_time_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: - """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[iso-8601]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace_async - async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date array value ['2000-12-01t00:00:01z', null]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date array value ['2000-12-01t00:00:01z', 'date-time']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', - 'Wed, 12 Oct 1492 10:15:01 GMT']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[rfc-1123]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace_async - async def put_date_time_rfc1123_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: - """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 - Oct 1492 10:15:01 GMT']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[rfc-1123]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace_async - async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: - """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of timedelta, or the result of cls(response) - :rtype: list[~datetime.timedelta] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[duration]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace_async - async def put_duration_valid(self, array_body: List[datetime.timedelta], **kwargs: Any) -> None: - """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :param array_body: - :type array_body: list[~datetime.timedelta] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[duration]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace_async - async def get_byte_valid(self, **kwargs: Any) -> List[bytearray]: - """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded - in base64. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace_async - async def put_byte_valid(self, array_body: List[bytearray], **kwargs: Any) -> None: - """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each - elementencoded in base 64. - - :param array_body: - :type array_body: list[bytearray] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bytearray]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace_async - async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytearray]: - """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_base64_url(self, **kwargs: Any) -> List[bytes]: - """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with - the items base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytes, or the result of cls(response) - :rtype: list[bytes] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[base64]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore - - @distributed_trace_async - async def get_complex_null(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore - - @distributed_trace_async - async def get_complex_empty(self, **kwargs: Any) -> List["_models.Product"]: - """Get empty array of complex type []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore - - @distributed_trace_async - async def get_complex_item_null(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore - - @distributed_trace_async - async def get_complex_item_empty(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore - - @distributed_trace_async - async def get_complex_valid(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, - {'integer': 5, 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace_async - async def put_complex_valid(self, array_body: List["_models.Product"], **kwargs: Any) -> None: - """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, - 'string': '4'}, {'integer': 5, 'string': '6'}]. - - :param array_body: - :type array_body: list[~bodyarray.models.Product] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[Product]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace_async - async def get_array_null(self, **kwargs: Any) -> List[List[str]]: - """Get a null array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_null.metadata = {"url": "/array/array/null"} # type: ignore - - @distributed_trace_async - async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: - """Get an empty array []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore - - @distributed_trace_async - async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: - """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore - - @distributed_trace_async - async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: - """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore - - @distributed_trace_async - async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: - """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace_async - async def put_array_valid(self, array_body: List[List[str]], **kwargs: Any) -> None: - """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :param array_body: - :type array_body: list[list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[[str]]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace_async - async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries with value null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore - - @distributed_trace_async - async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore - - @distributed_trace_async - async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore - - @distributed_trace_async - async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore - - @distributed_trace_async - async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore - - @distributed_trace_async - async def put_dictionary_valid(self, array_body: List[Dict[str, str]], **kwargs: Any) -> None: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :param array_body: - :type array_body: list[dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[{str}]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py deleted file mode 100644 index 12b82270806..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py +++ /dev/null @@ -1,3265 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class ArrayOperations(object): - """ArrayOperations 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: ~bodyarray.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get null array value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/array/null"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get invalid array [1, 2, 3. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/array/invalid"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get empty array value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace - def put_empty( - self, - array_body, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty []. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace - def get_boolean_tfft( - self, **kwargs # type: Any - ): - # type: (...) -> List[bool] - """Get boolean array value [true, false, false, true]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace - def put_boolean_tfft( - self, - array_body, # type: List[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty [true, false, false, true]. - - :param array_body: - :type array_body: list[bool] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bool]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace - def get_boolean_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[bool] - """Get boolean array value [true, null, false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore - - @distributed_trace - def get_boolean_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[bool] - """Get boolean array value [true, 'boolean', false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore - - @distributed_trace - def get_integer_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace - def put_integer_valid( - self, - array_body, # type: List[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[int] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[int]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace - def get_int_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore - - @distributed_trace - def get_int_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore - - @distributed_trace - def get_long_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace - def put_long_valid( - self, - array_body, # type: List[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[long] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[long]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace - def get_long_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get long array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore - - @distributed_trace - def get_long_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get long array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore - - @distributed_trace - def get_float_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def put_float_valid( - self, - array_body, # type: List[float] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def get_float_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore - - @distributed_trace - def get_float_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore - - @distributed_trace - def get_double_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def put_double_valid( - self, - array_body, # type: List[float] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def get_double_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore - - @distributed_trace - def get_double_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore - - @distributed_trace - def get_string_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get string array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_string_valid( - self, - array_body, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_enum_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[Union[str, "_models.FooEnum"]] - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of FooEnum, or the result of cls(response) - :rtype: list[str or ~bodyarray.models.FooEnum] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_enum_valid( - self, - array_body, # type: List[Union[str, "_models.FooEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~bodyarray.models.FooEnum] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_string_enum_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[Union[str, "_models.Enum0"]] - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Enum0, or the result of cls(response) - :rtype: list[str or ~bodyarray.models.Enum0] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_string_enum_valid( - self, - array_body, # type: List[Union[str, "_models.Enum1"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~bodyarray.models.Enum1] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_string_with_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get string array value ['foo', null, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore - - @distributed_trace - def get_string_with_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get string array value ['foo', 123, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore - - @distributed_trace - def get_uuid_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace - def put_uuid_valid( - self, - array_body, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace - def get_uuid_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore - - @distributed_trace - def get_date_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.date] - """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace - def put_date_valid( - self, - array_body, # type: List[datetime.date] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :param array_body: - :type array_body: list[~datetime.date] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[date]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace - def get_date_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.date] - """Get date array value ['2012-01-01', null, '1776-07-04']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore - - @distributed_trace - def get_date_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.date] - """Get date array value ['2011-03-22', 'date']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore - - @distributed_trace - def get_date_time_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace - def put_date_time_valid( - self, - array_body, # type: List[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[iso-8601]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace - def get_date_time_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date array value ['2000-12-01t00:00:01z', null]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore - - @distributed_trace - def get_date_time_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date array value ['2000-12-01t00:00:01z', 'date-time']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore - - @distributed_trace - def get_date_time_rfc1123_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', - 'Wed, 12 Oct 1492 10:15:01 GMT']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[rfc-1123]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace - def put_date_time_rfc1123_valid( - self, - array_body, # type: List[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 - Oct 1492 10:15:01 GMT']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[rfc-1123]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace - def get_duration_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.timedelta] - """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of timedelta, or the result of cls(response) - :rtype: list[~datetime.timedelta] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[duration]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace - def put_duration_valid( - self, - array_body, # type: List[datetime.timedelta] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :param array_body: - :type array_body: list[~datetime.timedelta] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[duration]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace - def get_byte_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[bytearray] - """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded - in base64. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace - def put_byte_valid( - self, - array_body, # type: List[bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each - elementencoded in base 64. - - :param array_body: - :type array_body: list[bytearray] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bytearray]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace - def get_byte_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[bytearray] - """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore - - @distributed_trace - def get_base64_url( - self, **kwargs # type: Any - ): - # type: (...) -> List[bytes] - """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with - the items base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytes, or the result of cls(response) - :rtype: list[bytes] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[base64]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore - - @distributed_trace - def get_complex_null( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore - - @distributed_trace - def get_complex_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get empty array of complex type []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore - - @distributed_trace - def get_complex_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore - - @distributed_trace - def get_complex_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore - - @distributed_trace - def get_complex_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, - {'integer': 5, 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~bodyarray.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace - def put_complex_valid( - self, - array_body, # type: List["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, - 'string': '4'}, {'integer': 5, 'string': '6'}]. - - :param array_body: - :type array_body: list[~bodyarray.models.Product] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[Product]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace - def get_array_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get a null array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_null.metadata = {"url": "/array/array/null"} # type: ignore - - @distributed_trace - def get_array_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an empty array []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore - - @distributed_trace - def get_array_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore - - @distributed_trace - def get_array_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore - - @distributed_trace - def get_array_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace - def put_array_valid( - self, - array_body, # type: List[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :param array_body: - :type array_body: list[list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[[str]]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace - def get_dictionary_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries with value null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore - - @distributed_trace - def get_dictionary_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore - - @distributed_trace - def get_dictionary_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore - - @distributed_trace - def get_dictionary_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore - - @distributed_trace - def get_dictionary_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore - - @distributed_trace - def put_dictionary_valid( - self, - array_body, # type: List[Dict[str, str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :param array_body: - :type array_body: list[dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[{str}]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyArray/setup.py deleted file mode 100644 index 3e920bf63ba..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArray/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatarrayservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATArrayService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATArrayService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/setup.py deleted file mode 100644 index 3e920bf63ba..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatarrayservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATArrayService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATArrayService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_auto_rest_swagger_bat_array_service.py b/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_auto_rest_swagger_bat_array_service.py deleted file mode 100644 index 15725d9998a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_auto_rest_swagger_bat_array_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATArrayServiceConfiguration -from .operations import ArrayOperations -from . import models - - -class AutoRestSwaggerBATArrayService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar array: ArrayOperations operations - :vartype array: vanilla.body.array.operations.ArrayOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATArrayService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_auto_rest_swagger_bat_array_service.py b/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_auto_rest_swagger_bat_array_service.py deleted file mode 100644 index 16f604a53f9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_auto_rest_swagger_bat_array_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATArrayServiceConfiguration -from .operations import ArrayOperations -from .. import models - - -class AutoRestSwaggerBATArrayService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar array: ArrayOperations operations - :vartype array: vanilla.body.array.aio.operations.ArrayOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATArrayService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py deleted file mode 100644 index 099f9186dcb..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py +++ /dev/null @@ -1,3018 +0,0 @@ -# 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 datetime -from typing import Any, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArrayOperations: - """ArrayOperations 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: ~vanilla.body.array.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 get_null(self, **kwargs: Any) -> List[int]: - """Get null array value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/array/null"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> List[int]: - """Get invalid array [1, 2, 3. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/array/invalid"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> List[int]: - """Get empty array value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace_async - async def put_empty(self, array_body: List[str], **kwargs: Any) -> None: - """Set array value empty []. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace_async - async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: - """Get boolean array value [true, false, false, true]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace_async - async def put_boolean_tfft(self, array_body: List[bool], **kwargs: Any) -> None: - """Set array value empty [true, false, false, true]. - - :param array_body: - :type array_body: list[bool] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bool]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace_async - async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: - """Get boolean array value [true, null, false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore - - @distributed_trace_async - async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: - """Get boolean array value [true, 'boolean', false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore - - @distributed_trace_async - async def get_integer_valid(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def put_integer_valid(self, array_body: List[int], **kwargs: Any) -> None: - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[int] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[int]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore - - @distributed_trace_async - async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore - - @distributed_trace_async - async def get_long_valid(self, **kwargs: Any) -> List[int]: - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def put_long_valid(self, array_body: List[int], **kwargs: Any) -> None: - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[long] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[long]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: - """Get long array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore - - @distributed_trace_async - async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: - """Get long array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore - - @distributed_trace_async - async def get_float_valid(self, **kwargs: Any) -> List[float]: - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def put_float_valid(self, array_body: List[float], **kwargs: Any) -> None: - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore - - @distributed_trace_async - async def get_double_valid(self, **kwargs: Any) -> List[float]: - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def put_double_valid(self, array_body: List[float], **kwargs: Any) -> None: - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore - - @distributed_trace_async - async def get_string_valid(self, **kwargs: Any) -> List[str]: - """Get string array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_string_valid(self, array_body: List[str], **kwargs: Any) -> None: - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.FooEnum"]]: - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of FooEnum, or the result of cls(response) - :rtype: list[str or ~vanilla.body.array.models.FooEnum] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_enum_valid(self, array_body: List[Union[str, "_models.FooEnum"]], **kwargs: Any) -> None: - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~vanilla.body.array.models.FooEnum] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.Enum0"]]: - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Enum0, or the result of cls(response) - :rtype: list[str or ~vanilla.body.array.models.Enum0] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_string_enum_valid(self, array_body: List[Union[str, "_models.Enum1"]], **kwargs: Any) -> None: - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~vanilla.body.array.models.Enum1] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_string_with_null(self, **kwargs: Any) -> List[str]: - """Get string array value ['foo', null, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore - - @distributed_trace_async - async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: - """Get string array value ['foo', 123, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore - - @distributed_trace_async - async def get_uuid_valid(self, **kwargs: Any) -> List[str]: - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace_async - async def put_uuid_valid(self, array_body: List[str], **kwargs: Any) -> None: - """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace_async - async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: - """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace_async - async def put_date_valid(self, array_body: List[datetime.date], **kwargs: Any) -> None: - """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :param array_body: - :type array_body: list[~datetime.date] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[date]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace_async - async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: - """Get date array value ['2012-01-01', null, '1776-07-04']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: - """Get date array value ['2011-03-22', 'date']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace_async - async def put_date_time_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: - """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[iso-8601]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace_async - async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date array value ['2000-12-01t00:00:01z', null]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date array value ['2000-12-01t00:00:01z', 'date-time']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: - """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', - 'Wed, 12 Oct 1492 10:15:01 GMT']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[rfc-1123]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace_async - async def put_date_time_rfc1123_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: - """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 - Oct 1492 10:15:01 GMT']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[rfc-1123]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace_async - async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: - """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of timedelta, or the result of cls(response) - :rtype: list[~datetime.timedelta] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[duration]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace_async - async def put_duration_valid(self, array_body: List[datetime.timedelta], **kwargs: Any) -> None: - """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :param array_body: - :type array_body: list[~datetime.timedelta] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[duration]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace_async - async def get_byte_valid(self, **kwargs: Any) -> List[bytearray]: - """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded - in base64. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace_async - async def put_byte_valid(self, array_body: List[bytearray], **kwargs: Any) -> None: - """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each - elementencoded in base 64. - - :param array_body: - :type array_body: list[bytearray] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bytearray]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace_async - async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytearray]: - """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_base64_url(self, **kwargs: Any) -> List[bytes]: - """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with - the items base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytes, or the result of cls(response) - :rtype: list[bytes] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[base64]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore - - @distributed_trace_async - async def get_complex_null(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore - - @distributed_trace_async - async def get_complex_empty(self, **kwargs: Any) -> List["_models.Product"]: - """Get empty array of complex type []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore - - @distributed_trace_async - async def get_complex_item_null(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore - - @distributed_trace_async - async def get_complex_item_empty(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore - - @distributed_trace_async - async def get_complex_valid(self, **kwargs: Any) -> List["_models.Product"]: - """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, - {'integer': 5, 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace_async - async def put_complex_valid(self, array_body: List["_models.Product"], **kwargs: Any) -> None: - """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, - 'string': '4'}, {'integer': 5, 'string': '6'}]. - - :param array_body: - :type array_body: list[~vanilla.body.array.models.Product] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[Product]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace_async - async def get_array_null(self, **kwargs: Any) -> List[List[str]]: - """Get a null array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_null.metadata = {"url": "/array/array/null"} # type: ignore - - @distributed_trace_async - async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: - """Get an empty array []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore - - @distributed_trace_async - async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: - """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore - - @distributed_trace_async - async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: - """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore - - @distributed_trace_async - async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: - """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace_async - async def put_array_valid(self, array_body: List[List[str]], **kwargs: Any) -> None: - """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :param array_body: - :type array_body: list[list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[[str]]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace_async - async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries with value null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore - - @distributed_trace_async - async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore - - @distributed_trace_async - async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore - - @distributed_trace_async - async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore - - @distributed_trace_async - async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore - - @distributed_trace_async - async def put_dictionary_valid(self, array_body: List[Dict[str, str]], **kwargs: Any) -> None: - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :param array_body: - :type array_body: list[dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[{str}]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py deleted file mode 100644 index 0ea5ddb039e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py +++ /dev/null @@ -1,3265 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class ArrayOperations(object): - """ArrayOperations 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: ~vanilla.body.array.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get null array value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/array/null"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get invalid array [1, 2, 3. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/array/invalid"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get empty array value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace - def put_empty( - self, - array_body, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty []. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/array/empty"} # type: ignore - - @distributed_trace - def get_boolean_tfft( - self, **kwargs # type: Any - ): - # type: (...) -> List[bool] - """Get boolean array value [true, false, false, true]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace - def put_boolean_tfft( - self, - array_body, # type: List[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty [true, false, false, true]. - - :param array_body: - :type array_body: list[bool] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bool]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore - - @distributed_trace - def get_boolean_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[bool] - """Get boolean array value [true, null, false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore - - @distributed_trace - def get_boolean_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[bool] - """Get boolean array value [true, 'boolean', false]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bool, or the result of cls(response) - :rtype: list[bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bool]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore - - @distributed_trace - def get_integer_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace - def put_integer_valid( - self, - array_body, # type: List[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[int] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[int]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace - def get_int_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore - - @distributed_trace - def get_int_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of int, or the result of cls(response) - :rtype: list[int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[int]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore - - @distributed_trace - def get_long_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get integer array value [1, -1, 3, 300]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace - def put_long_valid( - self, - array_body, # type: List[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value empty [1, -1, 3, 300]. - - :param array_body: - :type array_body: list[long] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[long]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace - def get_long_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get long array value [1, null, 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore - - @distributed_trace - def get_long_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[int] - """Get long array value [1, 'integer', 0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of long, or the result of cls(response) - :rtype: list[long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[long]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore - - @distributed_trace - def get_float_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def put_float_valid( - self, - array_body, # type: List[float] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def get_float_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore - - @distributed_trace - def get_float_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore - - @distributed_trace - def get_double_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0, -0.01, 1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def put_double_valid( - self, - array_body, # type: List[float] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value [0, -0.01, 1.2e20]. - - :param array_body: - :type array_body: list[float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[float]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def get_double_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get float array value [0.0, null, -1.2e20]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore - - @distributed_trace - def get_double_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> List[float] - """Get boolean array value [1.0, 'number', 0.0]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of float, or the result of cls(response) - :rtype: list[float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[float]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore - - @distributed_trace - def get_string_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get string array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_string_valid( - self, - array_body, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_enum_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[Union[str, "_models.FooEnum"]] - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of FooEnum, or the result of cls(response) - :rtype: list[str or ~vanilla.body.array.models.FooEnum] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_enum_valid( - self, - array_body, # type: List[Union[str, "_models.FooEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~vanilla.body.array.models.FooEnum] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_string_enum_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[Union[str, "_models.Enum0"]] - """Get enum array value ['foo1', 'foo2', 'foo3']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Enum0, or the result of cls(response) - :rtype: list[str or ~vanilla.body.array.models.Enum0] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_string_enum_valid( - self, - array_body, # type: List[Union[str, "_models.Enum1"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['foo1', 'foo2', 'foo3']. - - :param array_body: - :type array_body: list[str or ~vanilla.body.array.models.Enum1] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_string_with_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get string array value ['foo', null, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore - - @distributed_trace - def get_string_with_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get string array value ['foo', 123, 'foo2']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore - - @distributed_trace - def get_uuid_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace - def put_uuid_valid( - self, - array_body, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', - 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. - - :param array_body: - :type array_body: list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_uuid_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore - - @distributed_trace - def get_uuid_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> List[str] - """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_uuid_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore - - @distributed_trace - def get_date_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.date] - """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace - def put_date_valid( - self, - array_body, # type: List[datetime.date] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. - - :param array_body: - :type array_body: list[~datetime.date] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[date]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore - - @distributed_trace - def get_date_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.date] - """Get date array value ['2012-01-01', null, '1776-07-04']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore - - @distributed_trace - def get_date_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.date] - """Get date array value ['2011-03-22', 'date']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of date, or the result of cls(response) - :rtype: list[~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[date]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore - - @distributed_trace - def get_date_time_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace - def put_date_time_valid( - self, - array_body, # type: List[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', - '1492-10-12T10:15:01-08:00']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[iso-8601]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore - - @distributed_trace - def get_date_time_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date array value ['2000-12-01t00:00:01z', null]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore - - @distributed_trace - def get_date_time_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date array value ['2000-12-01t00:00:01z', 'date-time']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[iso-8601]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore - - @distributed_trace - def get_date_time_rfc1123_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.datetime] - """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', - 'Wed, 12 Oct 1492 10:15:01 GMT']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of datetime, or the result of cls(response) - :rtype: list[~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[rfc-1123]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace - def put_date_time_rfc1123_valid( - self, - array_body, # type: List[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 - Oct 1492 10:15:01 GMT']. - - :param array_body: - :type array_body: list[~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[rfc-1123]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace - def get_duration_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[datetime.timedelta] - """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of timedelta, or the result of cls(response) - :rtype: list[~datetime.timedelta] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[duration]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace - def put_duration_valid( - self, - array_body, # type: List[datetime.timedelta] - **kwargs # type: Any - ): - # type: (...) -> None - """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. - - :param array_body: - :type array_body: list[~datetime.timedelta] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[duration]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore - - @distributed_trace - def get_byte_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[bytearray] - """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded - in base64. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace - def put_byte_valid( - self, - array_body, # type: List[bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each - elementencoded in base 64. - - :param array_body: - :type array_body: list[bytearray] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[bytearray]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore - - @distributed_trace - def get_byte_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[bytearray] - """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytearray, or the result of cls(response) - :rtype: list[bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[bytearray]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore - - @distributed_trace - def get_base64_url( - self, **kwargs # type: Any - ): - # type: (...) -> List[bytes] - """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with - the items base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of bytes, or the result of cls(response) - :rtype: list[bytes] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[base64]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore - - @distributed_trace - def get_complex_null( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore - - @distributed_trace - def get_complex_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get empty array of complex type []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore - - @distributed_trace - def get_complex_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore - - @distributed_trace - def get_complex_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, - 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore - - @distributed_trace - def get_complex_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Product"] - """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, - {'integer': 5, 'string': '6'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Product, or the result of cls(response) - :rtype: list[~vanilla.body.array.models.Product] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[Product]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace - def put_complex_valid( - self, - array_body, # type: List["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, - 'string': '4'}, {'integer': 5, 'string': '6'}]. - - :param array_body: - :type array_body: list[~vanilla.body.array.models.Product] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[Product]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore - - @distributed_trace - def get_array_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get a null array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_null.metadata = {"url": "/array/array/null"} # type: ignore - - @distributed_trace - def get_array_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an empty array []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore - - @distributed_trace - def get_array_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore - - @distributed_trace - def get_array_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore - - @distributed_trace - def get_array_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[List[str]] - """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of list of str, or the result of cls(response) - :rtype: list[list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[[str]]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace - def put_array_valid( - self, - array_body, # type: List[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. - - :param array_body: - :type array_body: list[list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[[str]]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore - - @distributed_trace - def get_dictionary_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries with value null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore - - @distributed_trace - def get_dictionary_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value []. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore - - @distributed_trace - def get_dictionary_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore - - @distributed_trace - def get_dictionary_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore - - @distributed_trace - def get_dictionary_valid( - self, **kwargs # type: Any - ): - # type: (...) -> List[Dict[str, str]] - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of dict mapping str to str, or the result of cls(response) - :rtype: list[dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[{str}]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore - - @distributed_trace - def put_dictionary_valid( - self, - array_body, # type: List[Dict[str, str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': - 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. - - :param array_body: - :type array_body: list[dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "[{str}]") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_auto_rest_bool_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_auto_rest_bool_test_service.py deleted file mode 100644 index 8a5e064e239..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_auto_rest_bool_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestBoolTestServiceConfiguration -from .operations import BoolOperations -from . import models - - -class AutoRestBoolTestService(object): - """Test Infrastructure for AutoRest. - - :ivar bool: BoolOperations operations - :vartype bool: bodyboolean.operations.BoolOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestBoolTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.bool = BoolOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestBoolTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_auto_rest_bool_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_auto_rest_bool_test_service.py deleted file mode 100644 index c7d1d32bd34..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_auto_rest_bool_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestBoolTestServiceConfiguration -from .operations import BoolOperations -from .. import models - - -class AutoRestBoolTestService(object): - """Test Infrastructure for AutoRest. - - :ivar bool: BoolOperations operations - :vartype bool: bodyboolean.aio.operations.BoolOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestBoolTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.bool = BoolOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestBoolTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py deleted file mode 100644 index aa8e7f8867f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py +++ /dev/null @@ -1,304 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class BoolOperations: - """BoolOperations 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: ~bodyboolean.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 get_true(self, **kwargs: Any) -> bool: - """Get true Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_true.metadata = {"url": "/bool/true"} # type: ignore - - @distributed_trace_async - async def put_true(self, **kwargs: Any) -> None: - """Set Boolean value true. - - :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/json") - bool_body = True - accept = "application/json" - - # Construct URL - url = self.put_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(bool_body, "bool") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_true.metadata = {"url": "/bool/true"} # type: ignore - - @distributed_trace_async - async def get_false(self, **kwargs: Any) -> bool: - """Get false Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_false.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_false.metadata = {"url": "/bool/false"} # type: ignore - - @distributed_trace_async - async def put_false(self, **kwargs: Any) -> None: - """Set Boolean value false. - - :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/json") - bool_body = False - accept = "application/json" - - # Construct URL - url = self.put_false.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(bool_body, "bool") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_false.metadata = {"url": "/bool/false"} # type: ignore - - @distributed_trace_async - async def get_null(self, **kwargs: Any) -> Optional[bool]: - """Get null Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool or None, or the result of cls(response) - :rtype: bool or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/bool/null"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> bool: - """Get invalid Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/bool/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py deleted file mode 100644 index e00f00da22e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py +++ /dev/null @@ -1,326 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class BoolOperations(object): - """BoolOperations 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: ~bodyboolean.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 get_true( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get true Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_true.metadata = {"url": "/bool/true"} # type: ignore - - @distributed_trace - def put_true( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Set Boolean value true. - - :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/json") - bool_body = True - accept = "application/json" - - # Construct URL - url = self.put_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(bool_body, "bool") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_true.metadata = {"url": "/bool/true"} # type: ignore - - @distributed_trace - def get_false( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get false Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_false.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_false.metadata = {"url": "/bool/false"} # type: ignore - - @distributed_trace - def put_false( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Set Boolean value false. - - :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/json") - bool_body = False - accept = "application/json" - - # Construct URL - url = self.put_false.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(bool_body, "bool") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_false.metadata = {"url": "/bool/false"} # type: ignore - - @distributed_trace - def get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[bool] - """Get null Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool or None, or the result of cls(response) - :rtype: bool or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/bool/null"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get invalid Boolean value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/bool/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/setup.py deleted file mode 100644 index 40f8c5587f1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestbooltestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestBoolTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestBoolTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/_auto_rest_swagger_bat_byte_service.py b/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/_auto_rest_swagger_bat_byte_service.py deleted file mode 100644 index caed822bb1b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/_auto_rest_swagger_bat_byte_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATByteServiceConfiguration -from .operations import ByteOperations -from . import models - - -class AutoRestSwaggerBATByteService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar byte: ByteOperations operations - :vartype byte: bodybyte.operations.ByteOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATByteServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.byte = ByteOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATByteService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_auto_rest_swagger_bat_byte_service.py b/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_auto_rest_swagger_bat_byte_service.py deleted file mode 100644 index df4798d14b9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_auto_rest_swagger_bat_byte_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATByteServiceConfiguration -from .operations import ByteOperations -from .. import models - - -class AutoRestSwaggerBATByteService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar byte: ByteOperations operations - :vartype byte: bodybyte.aio.operations.ByteOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATByteServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.byte = ByteOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATByteService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py deleted file mode 100644 index 9bb0c932e15..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py +++ /dev/null @@ -1,261 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ByteOperations: - """ByteOperations 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: ~bodybyte.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 get_null(self, **kwargs: Any) -> bytearray: - """Get null byte value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/byte/null"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> bytearray: - """Get empty byte value ''. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/byte/empty"} # type: ignore - - @distributed_trace_async - async def get_non_ascii(self, **kwargs: Any) -> bytearray: - """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace_async - async def put_non_ascii(self, byte_body: bytearray, **kwargs: Any) -> None: - """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - :type byte_body: bytearray - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(byte_body, "bytearray") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> bytearray: - """Get invalid byte value ':::SWAGGER::::'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py deleted file mode 100644 index 2dd144bebbd..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py +++ /dev/null @@ -1,282 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class ByteOperations(object): - """ByteOperations 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: ~bodybyte.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get null byte value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/byte/null"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get empty byte value ''. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/byte/empty"} # type: ignore - - @distributed_trace - def get_non_ascii( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace - def put_non_ascii( - self, - byte_body, # type: bytearray - **kwargs # type: Any - ): - # type: (...) -> None - """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - :type byte_body: bytearray - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(byte_body, "bytearray") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get invalid byte value ':::SWAGGER::::'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyByte/setup.py deleted file mode 100644 index 1483a1df65a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByte/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatbyteservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATByteService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATByteService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_class_name.py b/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_class_name.py deleted file mode 100644 index afc027f67c7..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_class_name.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ClassNameConfiguration -from .operations import ByteOperations -from . import models - - -class ClassName(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar byte: ByteOperations operations - :vartype byte: bodybytewithpackagename.operations.ByteOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = ClassNameConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.byte = ByteOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> ClassName - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_class_name.py b/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_class_name.py deleted file mode 100644 index 6c7b3e3d9a7..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_class_name.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import ClassNameConfiguration -from .operations import ByteOperations -from .. import models - - -class ClassName(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar byte: ByteOperations operations - :vartype byte: bodybytewithpackagename.aio.operations.ByteOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = ClassNameConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.byte = ByteOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "ClassName": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py deleted file mode 100644 index aafc42dcbcb..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py +++ /dev/null @@ -1,261 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ByteOperations: - """ByteOperations 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: ~bodybytewithpackagename.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 get_null(self, **kwargs: Any) -> bytearray: - """Get null byte value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/byte/null"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> bytearray: - """Get empty byte value ''. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/byte/empty"} # type: ignore - - @distributed_trace_async - async def get_non_ascii(self, **kwargs: Any) -> bytearray: - """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace_async - async def put_non_ascii(self, byte_body: bytearray, **kwargs: Any) -> None: - """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - :type byte_body: bytearray - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(byte_body, "bytearray") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> bytearray: - """Get invalid byte value ':::SWAGGER::::'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py deleted file mode 100644 index a2f657b2014..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py +++ /dev/null @@ -1,282 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class ByteOperations(object): - """ByteOperations 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: ~bodybytewithpackagename.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get null byte value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/byte/null"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get empty byte value ''. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/byte/empty"} # type: ignore - - @distributed_trace - def get_non_ascii( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace - def put_non_ascii( - self, - byte_body, # type: bytearray - **kwargs # type: Any - ): - # type: (...) -> None - """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - - :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). - :type byte_body: bytearray - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_non_ascii.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(byte_body, "bytearray") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get invalid byte value ':::SWAGGER::::'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/setup.py deleted file mode 100644 index 15d4043e676..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "package-name" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="package-name", - author_email="", - url="", - keywords=["Swagger", "ClassName"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_auto_rest_complex_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_auto_rest_complex_test_service.py deleted file mode 100644 index 4fc41bdcd90..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_auto_rest_complex_test_service.py +++ /dev/null @@ -1,112 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestComplexTestServiceConfiguration -from .operations import BasicOperations -from .operations import PrimitiveOperations -from .operations import ArrayOperations -from .operations import DictionaryOperations -from .operations import InheritanceOperations -from .operations import PolymorphismOperations -from .operations import PolymorphicrecursiveOperations -from .operations import ReadonlypropertyOperations -from .operations import FlattencomplexOperations -from . import models - - -class AutoRestComplexTestService(object): - """Test Infrastructure for AutoRest. - - :ivar basic: BasicOperations operations - :vartype basic: bodycomplex.operations.BasicOperations - :ivar primitive: PrimitiveOperations operations - :vartype primitive: bodycomplex.operations.PrimitiveOperations - :ivar array: ArrayOperations operations - :vartype array: bodycomplex.operations.ArrayOperations - :ivar dictionary: DictionaryOperations operations - :vartype dictionary: bodycomplex.operations.DictionaryOperations - :ivar inheritance: InheritanceOperations operations - :vartype inheritance: bodycomplex.operations.InheritanceOperations - :ivar polymorphism: PolymorphismOperations operations - :vartype polymorphism: bodycomplex.operations.PolymorphismOperations - :ivar polymorphicrecursive: PolymorphicrecursiveOperations operations - :vartype polymorphicrecursive: bodycomplex.operations.PolymorphicrecursiveOperations - :ivar readonlyproperty: ReadonlypropertyOperations operations - :vartype readonlyproperty: bodycomplex.operations.ReadonlypropertyOperations - :ivar flattencomplex: FlattencomplexOperations operations - :vartype flattencomplex: bodycomplex.operations.FlattencomplexOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestComplexTestServiceConfiguration(**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.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) - self.primitive = PrimitiveOperations(self._client, self._config, self._serialize, self._deserialize) - self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) - self.dictionary = DictionaryOperations(self._client, self._config, self._serialize, self._deserialize) - self.inheritance = InheritanceOperations(self._client, self._config, self._serialize, self._deserialize) - self.polymorphism = PolymorphismOperations(self._client, self._config, self._serialize, self._deserialize) - self.polymorphicrecursive = PolymorphicrecursiveOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.readonlyproperty = ReadonlypropertyOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.flattencomplex = FlattencomplexOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestComplexTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_auto_rest_complex_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_auto_rest_complex_test_service.py deleted file mode 100644 index 3fa8c53288f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_auto_rest_complex_test_service.py +++ /dev/null @@ -1,98 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestComplexTestServiceConfiguration -from .operations import BasicOperations -from .operations import PrimitiveOperations -from .operations import ArrayOperations -from .operations import DictionaryOperations -from .operations import InheritanceOperations -from .operations import PolymorphismOperations -from .operations import PolymorphicrecursiveOperations -from .operations import ReadonlypropertyOperations -from .operations import FlattencomplexOperations -from .. import models - - -class AutoRestComplexTestService(object): - """Test Infrastructure for AutoRest. - - :ivar basic: BasicOperations operations - :vartype basic: bodycomplex.aio.operations.BasicOperations - :ivar primitive: PrimitiveOperations operations - :vartype primitive: bodycomplex.aio.operations.PrimitiveOperations - :ivar array: ArrayOperations operations - :vartype array: bodycomplex.aio.operations.ArrayOperations - :ivar dictionary: DictionaryOperations operations - :vartype dictionary: bodycomplex.aio.operations.DictionaryOperations - :ivar inheritance: InheritanceOperations operations - :vartype inheritance: bodycomplex.aio.operations.InheritanceOperations - :ivar polymorphism: PolymorphismOperations operations - :vartype polymorphism: bodycomplex.aio.operations.PolymorphismOperations - :ivar polymorphicrecursive: PolymorphicrecursiveOperations operations - :vartype polymorphicrecursive: bodycomplex.aio.operations.PolymorphicrecursiveOperations - :ivar readonlyproperty: ReadonlypropertyOperations operations - :vartype readonlyproperty: bodycomplex.aio.operations.ReadonlypropertyOperations - :ivar flattencomplex: FlattencomplexOperations operations - :vartype flattencomplex: bodycomplex.aio.operations.FlattencomplexOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestComplexTestServiceConfiguration(**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.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) - self.primitive = PrimitiveOperations(self._client, self._config, self._serialize, self._deserialize) - self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) - self.dictionary = DictionaryOperations(self._client, self._config, self._serialize, self._deserialize) - self.inheritance = InheritanceOperations(self._client, self._config, self._serialize, self._deserialize) - self.polymorphism = PolymorphismOperations(self._client, self._config, self._serialize, self._deserialize) - self.polymorphicrecursive = PolymorphicrecursiveOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.readonlyproperty = ReadonlypropertyOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.flattencomplex = FlattencomplexOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestComplexTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py deleted file mode 100644 index 5fc383a12c5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py +++ /dev/null @@ -1,268 +0,0 @@ -# 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, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArrayOperations: - """ArrayOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.ArrayWrapper": - """Get complex types with array property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArrayWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ArrayWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ArrayWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/array/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, array: Optional[List[str]] = None, **kwargs: Any) -> None: - """Put complex types with array property. - - :param array: - :type array: list[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", {})) - - _complex_body = _models.ArrayWrapper(array=array) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ArrayWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/array/valid"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> "_models.ArrayWrapper": - """Get complex types with array property which is empty. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArrayWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ArrayWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ArrayWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/complex/array/empty"} # type: ignore - - @distributed_trace_async - async def put_empty(self, array: Optional[List[str]] = None, **kwargs: Any) -> None: - """Put complex types with array property which is empty. - - :param array: - :type array: list[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", {})) - - _complex_body = _models.ArrayWrapper(array=array) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ArrayWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/complex/array/empty"} # type: ignore - - @distributed_trace_async - async def get_not_provided(self, **kwargs: Any) -> "_models.ArrayWrapper": - """Get complex types with array property while server doesn't provide a response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArrayWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ArrayWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ArrayWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/complex/array/notprovided"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py deleted file mode 100644 index 61e623b1965..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py +++ /dev/null @@ -1,305 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class BasicOperations: - """BasicOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Basic": - """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, complex_body: "_models.Basic", **kwargs: Any) -> None: - """Please put {id: 2, name: 'abc', color: 'Magenta'}. - - :param complex_body: Please put {id: 2, name: 'abc', color: 'Magenta'}. - :type complex_body: ~bodycomplex.models.Basic - :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", {})) - api_version = "2016-02-29" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Basic") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> "_models.Basic": - """Get a basic complex type that is invalid for the local strong type. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/complex/basic/invalid"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> "_models.Basic": - """Get a basic complex type that is empty. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/complex/basic/empty"} # type: ignore - - @distributed_trace_async - async def get_null(self, **kwargs: Any) -> "_models.Basic": - """Get a basic complex type whose properties are null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/complex/basic/null"} # type: ignore - - @distributed_trace_async - async def get_not_provided(self, **kwargs: Any) -> "_models.Basic": - """Get a basic complex type while the server doesn't provide a response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/complex/basic/notprovided"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py deleted file mode 100644 index e66d91ac5ec..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py +++ /dev/null @@ -1,310 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DictionaryOperations: - """DictionaryOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.DictionaryWrapper": - """Get complex types with dictionary property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, default_program: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """Put complex types with dictionary property. - - :param default_program: Dictionary of :code:``. - :type default_program: dict[str, 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", {})) - - _complex_body = _models.DictionaryWrapper(default_program=default_program) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "DictionaryWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> "_models.DictionaryWrapper": - """Get complex types with dictionary property which is empty. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore - - @distributed_trace_async - async def put_empty(self, default_program: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """Put complex types with dictionary property which is empty. - - :param default_program: Dictionary of :code:``. - :type default_program: dict[str, 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", {})) - - _complex_body = _models.DictionaryWrapper(default_program=default_program) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "DictionaryWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore - - @distributed_trace_async - async def get_null(self, **kwargs: Any) -> "_models.DictionaryWrapper": - """Get complex types with dictionary property which is null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/complex/dictionary/typed/null"} # type: ignore - - @distributed_trace_async - async def get_not_provided(self, **kwargs: Any) -> "_models.DictionaryWrapper": - """Get complex types with dictionary property while server doesn't provide a response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/complex/dictionary/typed/notprovided"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py deleted file mode 100644 index 2df7cbfe830..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py +++ /dev/null @@ -1,89 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class FlattencomplexOperations: - """FlattencomplexOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.MyBaseType": - """get_valid. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyBaseType, or the result of cls(response) - :rtype: ~bodycomplex.models.MyBaseType - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyBaseType"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyBaseType", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/flatten/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py deleted file mode 100644 index a3d5ca67f92..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class InheritanceOperations: - """InheritanceOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Siamese": - """Get complex types that extend others. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Siamese, or the result of cls(response) - :rtype: ~bodycomplex.models.Siamese - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Siamese"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Siamese", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, complex_body: "_models.Siamese", **kwargs: Any) -> None: - """Put complex types that extend others. - - :param complex_body: Please put a siamese with id=2, name="Siameee", color=green, - breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and - the 2nd one named "Tomato" with id=-1 and food="french fries". - :type complex_body: ~bodycomplex.models.Siamese - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Siamese") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py deleted file mode 100644 index c13d5af5c26..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py +++ /dev/null @@ -1,187 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PolymorphicrecursiveOperations: - """PolymorphicrecursiveOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Fish": - """Get complex types that are polymorphic and have recursive references. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Fish, or the result of cls(response) - :rtype: ~bodycomplex.models.Fish - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Fish", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, complex_body: "_models.Fish", **kwargs: Any) -> None: - """Put complex types that are polymorphic and have recursive references. - - :param complex_body: Please put a salmon that looks like this: - { - "fishtype": "salmon", - "species": "king", - "length": 1, - "age": 1, - "location": "alaska", - "iswild": true, - "siblings": [ - { - "fishtype": "shark", - "species": "predator", - "length": 20, - "age": 6, - "siblings": [ - { - "fishtype": "salmon", - "species": "coho", - "length": 2, - "age": 2, - "location": "atlantic", - "iswild": true, - "siblings": [ - { - "fishtype": "shark", - "species": "predator", - "length": 20, - "age": 6 - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "length": 10, - "age": 105 - } - ] - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "length": 10, - "age": 105 - } - ] - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "length": 10, - "age": 105 - } - ] - }. - :type complex_body: ~bodycomplex.models.Fish - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Fish") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py deleted file mode 100644 index 9efac99ebe0..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py +++ /dev/null @@ -1,507 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PolymorphismOperations: - """PolymorphismOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Fish": - """Get complex types that are polymorphic. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Fish, or the result of cls(response) - :rtype: ~bodycomplex.models.Fish - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Fish", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, complex_body: "_models.Fish", **kwargs: Any) -> None: - """Put complex types that are polymorphic. - - :param complex_body: Please put a salmon that looks like this: - { - 'fishtype':'Salmon', - 'location':'alaska', - 'iswild':true, - 'species':'king', - 'length':1.0, - 'siblings':[ - { - 'fishtype':'Shark', - 'age':6, - 'birthday': '2012-01-05T01:00:00Z', - 'length':20.0, - 'species':'predator', - }, - { - 'fishtype':'Sawshark', - 'age':105, - 'birthday': '1900-01-05T01:00:00Z', - 'length':10.0, - 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), - 'species':'dangerous', - }, - { - 'fishtype': 'goblin', - 'age': 1, - 'birthday': '2015-08-08T00:00:00Z', - 'length': 30.0, - 'species': 'scary', - 'jawsize': 5 - } - ] - };. - :type complex_body: ~bodycomplex.models.Fish - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Fish") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore - - @distributed_trace_async - async def get_dot_syntax(self, **kwargs: Any) -> "_models.DotFish": - """Get complex types that are polymorphic, JSON key contains a dot. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DotFish, or the result of cls(response) - :rtype: ~bodycomplex.models.DotFish - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFish"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dot_syntax.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DotFish", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dot_syntax.metadata = {"url": "/complex/polymorphism/dotsyntax"} # type: ignore - - @distributed_trace_async - async def get_composed_with_discriminator(self, **kwargs: Any) -> "_models.DotFishMarket": - """Get complex object composing a polymorphic scalar property and array property with polymorphic - element type, with discriminator specified. Deserialization must NOT fail and use the - discriminator type specified on the wire. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DotFishMarket, or the result of cls(response) - :rtype: ~bodycomplex.models.DotFishMarket - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_composed_with_discriminator.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DotFishMarket", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_composed_with_discriminator.metadata = {"url": "/complex/polymorphism/composedWithDiscriminator"} # type: ignore - - @distributed_trace_async - async def get_composed_without_discriminator(self, **kwargs: Any) -> "_models.DotFishMarket": - """Get complex object composing a polymorphic scalar property and array property with polymorphic - element type, without discriminator specified on wire. Deserialization must NOT fail and use - the explicit type of the property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DotFishMarket, or the result of cls(response) - :rtype: ~bodycomplex.models.DotFishMarket - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_composed_without_discriminator.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DotFishMarket", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_composed_without_discriminator.metadata = {"url": "/complex/polymorphism/composedWithoutDiscriminator"} # type: ignore - - @distributed_trace_async - async def get_complicated(self, **kwargs: Any) -> "_models.Salmon": - """Get complex types that are polymorphic, but not at the root of the hierarchy; also have - additional properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Salmon, or the result of cls(response) - :rtype: ~bodycomplex.models.Salmon - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complicated.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Salmon", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore - - @distributed_trace_async - async def put_complicated(self, complex_body: "_models.Salmon", **kwargs: Any) -> None: - """Put complex types that are polymorphic, but not at the root of the hierarchy; also have - additional properties. - - :param complex_body: - :type complex_body: ~bodycomplex.models.Salmon - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complicated.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Salmon") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore - - @distributed_trace_async - async def put_missing_discriminator(self, complex_body: "_models.Salmon", **kwargs: Any) -> "_models.Salmon": - """Put complex types that are polymorphic, omitting the discriminator. - - :param complex_body: - :type complex_body: ~bodycomplex.models.Salmon - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Salmon, or the result of cls(response) - :rtype: ~bodycomplex.models.Salmon - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_missing_discriminator.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Salmon") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Salmon", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_missing_discriminator.metadata = {"url": "/complex/polymorphism/missingdiscriminator"} # type: ignore - - @distributed_trace_async - async def put_valid_missing_required(self, complex_body: "_models.Fish", **kwargs: Any) -> None: - """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the - request should not be allowed from the client. - - :param complex_body: Please attempt put a sawshark that looks like this, the client should not - allow this data to be sent: - { - "fishtype": "sawshark", - "species": "snaggle toothed", - "length": 18.5, - "age": 2, - "birthday": "2013-06-01T01:00:00Z", - "location": "alaska", - "picture": base64(FF FF FF FF FE), - "siblings": [ - { - "fishtype": "shark", - "species": "predator", - "birthday": "2012-01-05T01:00:00Z", - "length": 20, - "age": 6 - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "picture": base64(FF FF FF FF FE), - "length": 10, - "age": 105 - } - ] - }. - :type complex_body: ~bodycomplex.models.Fish - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid_missing_required.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Fish") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid_missing_required.metadata = {"url": "/complex/polymorphism/missingrequired/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py deleted file mode 100644 index 1c23c7d2488..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py +++ /dev/null @@ -1,1012 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrimitiveOperations: - """PrimitiveOperations 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: ~bodycomplex.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 get_int(self, **kwargs: Any) -> "_models.IntWrapper": - """Get complex types with integer properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.IntWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.IntWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("IntWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore - - @distributed_trace_async - async def put_int(self, complex_body: "_models.IntWrapper", **kwargs: Any) -> None: - """Put complex types with integer properties. - - :param complex_body: Please put -1 and 2. - :type complex_body: ~bodycomplex.models.IntWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_int.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "IntWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore - - @distributed_trace_async - async def get_long(self, **kwargs: Any) -> "_models.LongWrapper": - """Get complex types with long properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LongWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.LongWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.LongWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("LongWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long.metadata = {"url": "/complex/primitive/long"} # type: ignore - - @distributed_trace_async - async def put_long(self, complex_body: "_models.LongWrapper", **kwargs: Any) -> None: - """Put complex types with long properties. - - :param complex_body: Please put 1099511627775 and -999511627788. - :type complex_body: ~bodycomplex.models.LongWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "LongWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long.metadata = {"url": "/complex/primitive/long"} # type: ignore - - @distributed_trace_async - async def get_float(self, **kwargs: Any) -> "_models.FloatWrapper": - """Get complex types with float properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: FloatWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.FloatWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.FloatWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("FloatWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float.metadata = {"url": "/complex/primitive/float"} # type: ignore - - @distributed_trace_async - async def put_float(self, complex_body: "_models.FloatWrapper", **kwargs: Any) -> None: - """Put complex types with float properties. - - :param complex_body: Please put 1.05 and -0.003. - :type complex_body: ~bodycomplex.models.FloatWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "FloatWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float.metadata = {"url": "/complex/primitive/float"} # type: ignore - - @distributed_trace_async - async def get_double(self, **kwargs: Any) -> "_models.DoubleWrapper": - """Get complex types with double properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DoubleWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DoubleWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DoubleWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DoubleWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double.metadata = {"url": "/complex/primitive/double"} # type: ignore - - @distributed_trace_async - async def put_double(self, complex_body: "_models.DoubleWrapper", **kwargs: Any) -> None: - """Put complex types with double properties. - - :param complex_body: Please put 3e-100 and - -0.000000000000000000000000000000000000000000000000000000005. - :type complex_body: ~bodycomplex.models.DoubleWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "DoubleWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double.metadata = {"url": "/complex/primitive/double"} # type: ignore - - @distributed_trace_async - async def get_bool(self, **kwargs: Any) -> "_models.BooleanWrapper": - """Get complex types with bool properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BooleanWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.BooleanWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.BooleanWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("BooleanWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore - - @distributed_trace_async - async def put_bool(self, complex_body: "_models.BooleanWrapper", **kwargs: Any) -> None: - """Put complex types with bool properties. - - :param complex_body: Please put true and false. - :type complex_body: ~bodycomplex.models.BooleanWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "BooleanWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore - - @distributed_trace_async - async def get_string(self, **kwargs: Any) -> "_models.StringWrapper": - """Get complex types with string properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StringWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.StringWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StringWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("StringWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string.metadata = {"url": "/complex/primitive/string"} # type: ignore - - @distributed_trace_async - async def put_string(self, complex_body: "_models.StringWrapper", **kwargs: Any) -> None: - """Put complex types with string properties. - - :param complex_body: Please put 'goodrequest', '', and null. - :type complex_body: ~bodycomplex.models.StringWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "StringWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string.metadata = {"url": "/complex/primitive/string"} # type: ignore - - @distributed_trace_async - async def get_date(self, **kwargs: Any) -> "_models.DateWrapper": - """Get complex types with date properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DateWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DateWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DateWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DateWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date.metadata = {"url": "/complex/primitive/date"} # type: ignore - - @distributed_trace_async - async def put_date(self, complex_body: "_models.DateWrapper", **kwargs: Any) -> None: - """Put complex types with date properties. - - :param complex_body: Please put '0001-01-01' and '2016-02-29'. - :type complex_body: ~bodycomplex.models.DateWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "DateWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date.metadata = {"url": "/complex/primitive/date"} # type: ignore - - @distributed_trace_async - async def get_date_time(self, **kwargs: Any) -> "_models.DatetimeWrapper": - """Get complex types with datetime properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatetimeWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DatetimeWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DatetimeWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DatetimeWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore - - @distributed_trace_async - async def put_date_time(self, complex_body: "_models.DatetimeWrapper", **kwargs: Any) -> None: - """Put complex types with datetime properties. - - :param complex_body: Please put '0001-01-01T12:00:00-04:00' and '2015-05-18T11:38:00-08:00'. - :type complex_body: ~bodycomplex.models.DatetimeWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "DatetimeWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore - - @distributed_trace_async - async def get_date_time_rfc1123(self, **kwargs: Any) -> "_models.Datetimerfc1123Wrapper": - """Get complex types with datetimeRfc1123 properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datetimerfc1123Wrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.Datetimerfc1123Wrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Datetimerfc1123Wrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Datetimerfc1123Wrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore - - @distributed_trace_async - async def put_date_time_rfc1123(self, complex_body: "_models.Datetimerfc1123Wrapper", **kwargs: Any) -> None: - """Put complex types with datetimeRfc1123 properties. - - :param complex_body: Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May 2015 11:38:00 - GMT'. - :type complex_body: ~bodycomplex.models.Datetimerfc1123Wrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Datetimerfc1123Wrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore - - @distributed_trace_async - async def get_duration(self, **kwargs: Any) -> "_models.DurationWrapper": - """Get complex types with duration properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DurationWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DurationWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DurationWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DurationWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore - - @distributed_trace_async - async def put_duration(self, field: Optional[datetime.timedelta] = None, **kwargs: Any) -> None: - """Put complex types with duration properties. - - :param field: - :type field: ~datetime.timedelta - :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", {})) - - _complex_body = _models.DurationWrapper(field=field) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "DurationWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore - - @distributed_trace_async - async def get_byte(self, **kwargs: Any) -> "_models.ByteWrapper": - """Get complex types with byte properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ByteWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ByteWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ByteWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ByteWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore - - @distributed_trace_async - async def put_byte(self, field: Optional[bytearray] = None, **kwargs: Any) -> None: - """Put complex types with byte properties. - - :param field: - :type field: bytearray - :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", {})) - - _complex_body = _models.ByteWrapper(field=field) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ByteWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py deleted file mode 100644 index 2d8162686b5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ReadonlypropertyOperations: - """ReadonlypropertyOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.ReadonlyObj": - """Get complex types that have readonly properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReadonlyObj, or the result of cls(response) - :rtype: ~bodycomplex.models.ReadonlyObj - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ReadonlyObj"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ReadonlyObj", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore - - @distributed_trace_async - async def put_valid(self, size: Optional[int] = None, **kwargs: Any) -> None: - """Put complex types that have readonly properties. - - :param size: - :type size: int - :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", {})) - - _complex_body = _models.ReadonlyObj(size=size) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ReadonlyObj") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py deleted file mode 100644 index 425909f5bb2..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py +++ /dev/null @@ -1,291 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class ArrayOperations(object): - """ArrayOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ArrayWrapper" - """Get complex types with array property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArrayWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ArrayWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ArrayWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/array/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - array=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with array property. - - :param array: - :type array: list[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", {})) - - _complex_body = _models.ArrayWrapper(array=array) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ArrayWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/array/valid"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ArrayWrapper" - """Get complex types with array property which is empty. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArrayWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ArrayWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ArrayWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/complex/array/empty"} # type: ignore - - @distributed_trace - def put_empty( - self, - array=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with array property which is empty. - - :param array: - :type array: list[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", {})) - - _complex_body = _models.ArrayWrapper(array=array) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ArrayWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/complex/array/empty"} # type: ignore - - @distributed_trace - def get_not_provided( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ArrayWrapper" - """Get complex types with array property while server doesn't provide a response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArrayWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ArrayWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ArrayWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/complex/array/notprovided"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py deleted file mode 100644 index bac01500e21..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py +++ /dev/null @@ -1,329 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class BasicOperations(object): - """BasicOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Basic" - """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - complex_body, # type: "_models.Basic" - **kwargs # type: Any - ): - # type: (...) -> None - """Please put {id: 2, name: 'abc', color: 'Magenta'}. - - :param complex_body: Please put {id: 2, name: 'abc', color: 'Magenta'}. - :type complex_body: ~bodycomplex.models.Basic - :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", {})) - api_version = "2016-02-29" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["api-version"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Basic") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Basic" - """Get a basic complex type that is invalid for the local strong type. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/complex/basic/invalid"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Basic" - """Get a basic complex type that is empty. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/complex/basic/empty"} # type: ignore - - @distributed_trace - def get_null( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Basic" - """Get a basic complex type whose properties are null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/complex/basic/null"} # type: ignore - - @distributed_trace - def get_not_provided( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Basic" - """Get a basic complex type while the server doesn't provide a response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Basic, or the result of cls(response) - :rtype: ~bodycomplex.models.Basic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Basic", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/complex/basic/notprovided"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py deleted file mode 100644 index 713c85b1771..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py +++ /dev/null @@ -1,336 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class DictionaryOperations(object): - """DictionaryOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DictionaryWrapper" - """Get complex types with dictionary property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - default_program=None, # type: Optional[Dict[str, str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with dictionary property. - - :param default_program: Dictionary of :code:``. - :type default_program: dict[str, 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", {})) - - _complex_body = _models.DictionaryWrapper(default_program=default_program) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "DictionaryWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DictionaryWrapper" - """Get complex types with dictionary property which is empty. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore - - @distributed_trace - def put_empty( - self, - default_program=None, # type: Optional[Dict[str, str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with dictionary property which is empty. - - :param default_program: Dictionary of :code:``. - :type default_program: dict[str, 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", {})) - - _complex_body = _models.DictionaryWrapper(default_program=default_program) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "DictionaryWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore - - @distributed_trace - def get_null( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DictionaryWrapper" - """Get complex types with dictionary property which is null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/complex/dictionary/typed/null"} # type: ignore - - @distributed_trace - def get_not_provided( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DictionaryWrapper" - """Get complex types with dictionary property while server doesn't provide a response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DictionaryWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DictionaryWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DictionaryWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/complex/dictionary/typed/notprovided"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py deleted file mode 100644 index 7a6a78ffd3d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class FlattencomplexOperations(object): - """FlattencomplexOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyBaseType" - """get_valid. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyBaseType, or the result of cls(response) - :rtype: ~bodycomplex.models.MyBaseType - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyBaseType"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyBaseType", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/flatten/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py deleted file mode 100644 index 9963f575fc1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py +++ /dev/null @@ -1,149 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class InheritanceOperations(object): - """InheritanceOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Siamese" - """Get complex types that extend others. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Siamese, or the result of cls(response) - :rtype: ~bodycomplex.models.Siamese - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Siamese"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Siamese", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - complex_body, # type: "_models.Siamese" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types that extend others. - - :param complex_body: Please put a siamese with id=2, name="Siameee", color=green, - breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and - the 2nd one named "Tomato" with id=-1 and food="french fries". - :type complex_body: ~bodycomplex.models.Siamese - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Siamese") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py deleted file mode 100644 index ab49af239ab..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py +++ /dev/null @@ -1,199 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PolymorphicrecursiveOperations(object): - """PolymorphicrecursiveOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Fish" - """Get complex types that are polymorphic and have recursive references. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Fish, or the result of cls(response) - :rtype: ~bodycomplex.models.Fish - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Fish", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - complex_body, # type: "_models.Fish" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types that are polymorphic and have recursive references. - - :param complex_body: Please put a salmon that looks like this: - { - "fishtype": "salmon", - "species": "king", - "length": 1, - "age": 1, - "location": "alaska", - "iswild": true, - "siblings": [ - { - "fishtype": "shark", - "species": "predator", - "length": 20, - "age": 6, - "siblings": [ - { - "fishtype": "salmon", - "species": "coho", - "length": 2, - "age": 2, - "location": "atlantic", - "iswild": true, - "siblings": [ - { - "fishtype": "shark", - "species": "predator", - "length": 20, - "age": 6 - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "length": 10, - "age": 105 - } - ] - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "length": 10, - "age": 105 - } - ] - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "length": 10, - "age": 105 - } - ] - }. - :type complex_body: ~bodycomplex.models.Fish - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Fish") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py deleted file mode 100644 index 6f312b7d536..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py +++ /dev/null @@ -1,546 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PolymorphismOperations(object): - """PolymorphismOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Fish" - """Get complex types that are polymorphic. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Fish, or the result of cls(response) - :rtype: ~bodycomplex.models.Fish - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Fish", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - complex_body, # type: "_models.Fish" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types that are polymorphic. - - :param complex_body: Please put a salmon that looks like this: - { - 'fishtype':'Salmon', - 'location':'alaska', - 'iswild':true, - 'species':'king', - 'length':1.0, - 'siblings':[ - { - 'fishtype':'Shark', - 'age':6, - 'birthday': '2012-01-05T01:00:00Z', - 'length':20.0, - 'species':'predator', - }, - { - 'fishtype':'Sawshark', - 'age':105, - 'birthday': '1900-01-05T01:00:00Z', - 'length':10.0, - 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), - 'species':'dangerous', - }, - { - 'fishtype': 'goblin', - 'age': 1, - 'birthday': '2015-08-08T00:00:00Z', - 'length': 30.0, - 'species': 'scary', - 'jawsize': 5 - } - ] - };. - :type complex_body: ~bodycomplex.models.Fish - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Fish") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore - - @distributed_trace - def get_dot_syntax( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DotFish" - """Get complex types that are polymorphic, JSON key contains a dot. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DotFish, or the result of cls(response) - :rtype: ~bodycomplex.models.DotFish - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFish"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dot_syntax.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DotFish", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dot_syntax.metadata = {"url": "/complex/polymorphism/dotsyntax"} # type: ignore - - @distributed_trace - def get_composed_with_discriminator( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DotFishMarket" - """Get complex object composing a polymorphic scalar property and array property with polymorphic - element type, with discriminator specified. Deserialization must NOT fail and use the - discriminator type specified on the wire. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DotFishMarket, or the result of cls(response) - :rtype: ~bodycomplex.models.DotFishMarket - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_composed_with_discriminator.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DotFishMarket", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_composed_with_discriminator.metadata = {"url": "/complex/polymorphism/composedWithDiscriminator"} # type: ignore - - @distributed_trace - def get_composed_without_discriminator( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DotFishMarket" - """Get complex object composing a polymorphic scalar property and array property with polymorphic - element type, without discriminator specified on wire. Deserialization must NOT fail and use - the explicit type of the property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DotFishMarket, or the result of cls(response) - :rtype: ~bodycomplex.models.DotFishMarket - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_composed_without_discriminator.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DotFishMarket", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_composed_without_discriminator.metadata = {"url": "/complex/polymorphism/composedWithoutDiscriminator"} # type: ignore - - @distributed_trace - def get_complicated( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Salmon" - """Get complex types that are polymorphic, but not at the root of the hierarchy; also have - additional properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Salmon, or the result of cls(response) - :rtype: ~bodycomplex.models.Salmon - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complicated.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Salmon", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore - - @distributed_trace - def put_complicated( - self, - complex_body, # type: "_models.Salmon" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types that are polymorphic, but not at the root of the hierarchy; also have - additional properties. - - :param complex_body: - :type complex_body: ~bodycomplex.models.Salmon - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complicated.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Salmon") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore - - @distributed_trace - def put_missing_discriminator( - self, - complex_body, # type: "_models.Salmon" - **kwargs # type: Any - ): - # type: (...) -> "_models.Salmon" - """Put complex types that are polymorphic, omitting the discriminator. - - :param complex_body: - :type complex_body: ~bodycomplex.models.Salmon - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Salmon, or the result of cls(response) - :rtype: ~bodycomplex.models.Salmon - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_missing_discriminator.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Salmon") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Salmon", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_missing_discriminator.metadata = {"url": "/complex/polymorphism/missingdiscriminator"} # type: ignore - - @distributed_trace - def put_valid_missing_required( - self, - complex_body, # type: "_models.Fish" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the - request should not be allowed from the client. - - :param complex_body: Please attempt put a sawshark that looks like this, the client should not - allow this data to be sent: - { - "fishtype": "sawshark", - "species": "snaggle toothed", - "length": 18.5, - "age": 2, - "birthday": "2013-06-01T01:00:00Z", - "location": "alaska", - "picture": base64(FF FF FF FF FE), - "siblings": [ - { - "fishtype": "shark", - "species": "predator", - "birthday": "2012-01-05T01:00:00Z", - "length": 20, - "age": 6 - }, - { - "fishtype": "sawshark", - "species": "dangerous", - "picture": base64(FF FF FF FF FE), - "length": 10, - "age": 105 - } - ] - }. - :type complex_body: ~bodycomplex.models.Fish - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_valid_missing_required.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Fish") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid_missing_required.metadata = {"url": "/complex/polymorphism/missingrequired/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py deleted file mode 100644 index 2edc2a136c6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py +++ /dev/null @@ -1,1104 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PrimitiveOperations(object): - """PrimitiveOperations 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: ~bodycomplex.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 get_int( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.IntWrapper" - """Get complex types with integer properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.IntWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.IntWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("IntWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore - - @distributed_trace - def put_int( - self, - complex_body, # type: "_models.IntWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with integer properties. - - :param complex_body: Please put -1 and 2. - :type complex_body: ~bodycomplex.models.IntWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_int.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "IntWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore - - @distributed_trace - def get_long( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.LongWrapper" - """Get complex types with long properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LongWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.LongWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.LongWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("LongWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long.metadata = {"url": "/complex/primitive/long"} # type: ignore - - @distributed_trace - def put_long( - self, - complex_body, # type: "_models.LongWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with long properties. - - :param complex_body: Please put 1099511627775 and -999511627788. - :type complex_body: ~bodycomplex.models.LongWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "LongWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long.metadata = {"url": "/complex/primitive/long"} # type: ignore - - @distributed_trace - def get_float( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.FloatWrapper" - """Get complex types with float properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: FloatWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.FloatWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.FloatWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("FloatWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float.metadata = {"url": "/complex/primitive/float"} # type: ignore - - @distributed_trace - def put_float( - self, - complex_body, # type: "_models.FloatWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with float properties. - - :param complex_body: Please put 1.05 and -0.003. - :type complex_body: ~bodycomplex.models.FloatWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "FloatWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float.metadata = {"url": "/complex/primitive/float"} # type: ignore - - @distributed_trace - def get_double( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DoubleWrapper" - """Get complex types with double properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DoubleWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DoubleWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DoubleWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DoubleWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double.metadata = {"url": "/complex/primitive/double"} # type: ignore - - @distributed_trace - def put_double( - self, - complex_body, # type: "_models.DoubleWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with double properties. - - :param complex_body: Please put 3e-100 and - -0.000000000000000000000000000000000000000000000000000000005. - :type complex_body: ~bodycomplex.models.DoubleWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "DoubleWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double.metadata = {"url": "/complex/primitive/double"} # type: ignore - - @distributed_trace - def get_bool( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.BooleanWrapper" - """Get complex types with bool properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BooleanWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.BooleanWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.BooleanWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("BooleanWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore - - @distributed_trace - def put_bool( - self, - complex_body, # type: "_models.BooleanWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with bool properties. - - :param complex_body: Please put true and false. - :type complex_body: ~bodycomplex.models.BooleanWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "BooleanWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore - - @distributed_trace - def get_string( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.StringWrapper" - """Get complex types with string properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StringWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.StringWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StringWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("StringWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string.metadata = {"url": "/complex/primitive/string"} # type: ignore - - @distributed_trace - def put_string( - self, - complex_body, # type: "_models.StringWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with string properties. - - :param complex_body: Please put 'goodrequest', '', and null. - :type complex_body: ~bodycomplex.models.StringWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "StringWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string.metadata = {"url": "/complex/primitive/string"} # type: ignore - - @distributed_trace - def get_date( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DateWrapper" - """Get complex types with date properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DateWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DateWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DateWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DateWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date.metadata = {"url": "/complex/primitive/date"} # type: ignore - - @distributed_trace - def put_date( - self, - complex_body, # type: "_models.DateWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with date properties. - - :param complex_body: Please put '0001-01-01' and '2016-02-29'. - :type complex_body: ~bodycomplex.models.DateWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "DateWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date.metadata = {"url": "/complex/primitive/date"} # type: ignore - - @distributed_trace - def get_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DatetimeWrapper" - """Get complex types with datetime properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatetimeWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DatetimeWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DatetimeWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DatetimeWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore - - @distributed_trace - def put_date_time( - self, - complex_body, # type: "_models.DatetimeWrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with datetime properties. - - :param complex_body: Please put '0001-01-01T12:00:00-04:00' and '2015-05-18T11:38:00-08:00'. - :type complex_body: ~bodycomplex.models.DatetimeWrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "DatetimeWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore - - @distributed_trace - def get_date_time_rfc1123( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Datetimerfc1123Wrapper" - """Get complex types with datetimeRfc1123 properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datetimerfc1123Wrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.Datetimerfc1123Wrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Datetimerfc1123Wrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Datetimerfc1123Wrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore - - @distributed_trace - def put_date_time_rfc1123( - self, - complex_body, # type: "_models.Datetimerfc1123Wrapper" - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with datetimeRfc1123 properties. - - :param complex_body: Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May 2015 11:38:00 - GMT'. - :type complex_body: ~bodycomplex.models.Datetimerfc1123Wrapper - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(complex_body, "Datetimerfc1123Wrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore - - @distributed_trace - def get_duration( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.DurationWrapper" - """Get complex types with duration properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DurationWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.DurationWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.DurationWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("DurationWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore - - @distributed_trace - def put_duration( - self, - field=None, # type: Optional[datetime.timedelta] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with duration properties. - - :param field: - :type field: ~datetime.timedelta - :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", {})) - - _complex_body = _models.DurationWrapper(field=field) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "DurationWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore - - @distributed_trace - def get_byte( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ByteWrapper" - """Get complex types with byte properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ByteWrapper, or the result of cls(response) - :rtype: ~bodycomplex.models.ByteWrapper - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ByteWrapper"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ByteWrapper", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore - - @distributed_trace - def put_byte( - self, - field=None, # type: Optional[bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types with byte properties. - - :param field: - :type field: bytearray - :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", {})) - - _complex_body = _models.ByteWrapper(field=field) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ByteWrapper") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py deleted file mode 100644 index 38ef8ad16bf..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py +++ /dev/null @@ -1,149 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class ReadonlypropertyOperations(object): - """ReadonlypropertyOperations 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: ~bodycomplex.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 get_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ReadonlyObj" - """Get complex types that have readonly properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReadonlyObj, or the result of cls(response) - :rtype: ~bodycomplex.models.ReadonlyObj - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ReadonlyObj"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ReadonlyObj", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore - - @distributed_trace - def put_valid( - self, - size=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Put complex types that have readonly properties. - - :param size: - :type size: int - :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", {})) - - _complex_body = _models.ReadonlyObj(size=size) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_complex_body, "ReadonlyObj") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/setup.py deleted file mode 100644 index 2e84a81824b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestcomplextestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestComplexTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestComplexTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_auto_rest_date_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_auto_rest_date_test_service.py deleted file mode 100644 index b549b76ec95..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_auto_rest_date_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestDateTestServiceConfiguration -from .operations import DateOperations -from . import models - - -class AutoRestDateTestService(object): - """Test Infrastructure for AutoRest. - - :ivar date: DateOperations operations - :vartype date: bodydate.operations.DateOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDateTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.date = DateOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestDateTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/_auto_rest_date_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/_auto_rest_date_test_service.py deleted file mode 100644 index 9b98f41a119..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/_auto_rest_date_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestDateTestServiceConfiguration -from .operations import DateOperations -from .. import models - - -class AutoRestDateTestService(object): - """Test Infrastructure for AutoRest. - - :ivar date: DateOperations operations - :vartype date: bodydate.aio.operations.DateOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDateTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.date = DateOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestDateTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py deleted file mode 100644 index c5f42f857d4..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py +++ /dev/null @@ -1,391 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DateOperations: - """DateOperations 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: ~bodydate.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 get_null(self, **kwargs: Any) -> Optional[datetime.date]: - """Get null date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date or None, or the result of cls(response) - :rtype: ~datetime.date or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/date/null"} # type: ignore - - @distributed_trace_async - async def get_invalid_date(self, **kwargs: Any) -> datetime.date: - """Get invalid date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_date.metadata = {"url": "/date/invaliddate"} # type: ignore - - @distributed_trace_async - async def get_overflow_date(self, **kwargs: Any) -> datetime.date: - """Get overflow date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow_date.metadata = {"url": "/date/overflowdate"} # type: ignore - - @distributed_trace_async - async def get_underflow_date(self, **kwargs: Any) -> datetime.date: - """Get underflow date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow_date.metadata = {"url": "/date/underflowdate"} # type: ignore - - @distributed_trace_async - async def put_max_date(self, date_body: datetime.date, **kwargs: Any) -> None: - """Put max date value 9999-12-31. - - :param date_body: date body. - :type date_body: ~datetime.date - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_max_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(date_body, "date") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_max_date.metadata = {"url": "/date/max"} # type: ignore - - @distributed_trace_async - async def get_max_date(self, **kwargs: Any) -> datetime.date: - """Get max date value 9999-12-31. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_max_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_max_date.metadata = {"url": "/date/max"} # type: ignore - - @distributed_trace_async - async def put_min_date(self, date_body: datetime.date, **kwargs: Any) -> None: - """Put min date value 0000-01-01. - - :param date_body: date body. - :type date_body: ~datetime.date - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_min_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(date_body, "date") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_min_date.metadata = {"url": "/date/min"} # type: ignore - - @distributed_trace_async - async def get_min_date(self, **kwargs: Any) -> datetime.date: - """Get min date value 0000-01-01. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_min_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_min_date.metadata = {"url": "/date/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py deleted file mode 100644 index a4ff0151065..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py +++ /dev/null @@ -1,423 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class DateOperations(object): - """DateOperations 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: ~bodydate.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[datetime.date] - """Get null date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date or None, or the result of cls(response) - :rtype: ~datetime.date or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/date/null"} # type: ignore - - @distributed_trace - def get_invalid_date( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.date - """Get invalid date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_date.metadata = {"url": "/date/invaliddate"} # type: ignore - - @distributed_trace - def get_overflow_date( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.date - """Get overflow date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow_date.metadata = {"url": "/date/overflowdate"} # type: ignore - - @distributed_trace - def get_underflow_date( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.date - """Get underflow date value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow_date.metadata = {"url": "/date/underflowdate"} # type: ignore - - @distributed_trace - def put_max_date( - self, - date_body, # type: datetime.date - **kwargs # type: Any - ): - # type: (...) -> None - """Put max date value 9999-12-31. - - :param date_body: date body. - :type date_body: ~datetime.date - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_max_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(date_body, "date") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_max_date.metadata = {"url": "/date/max"} # type: ignore - - @distributed_trace - def get_max_date( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.date - """Get max date value 9999-12-31. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_max_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_max_date.metadata = {"url": "/date/max"} # type: ignore - - @distributed_trace - def put_min_date( - self, - date_body, # type: datetime.date - **kwargs # type: Any - ): - # type: (...) -> None - """Put min date value 0000-01-01. - - :param date_body: date body. - :type date_body: ~datetime.date - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_min_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(date_body, "date") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_min_date.metadata = {"url": "/date/min"} # type: ignore - - @distributed_trace - def get_min_date( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.date - """Get min date value 0000-01-01. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_min_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("date", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_min_date.metadata = {"url": "/date/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/setup.py deleted file mode 100644 index 003f05ad212..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestdatetestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestDateTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestDateTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_auto_rest_date_time_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_auto_rest_date_time_test_service.py deleted file mode 100644 index 2ca59d14292..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_auto_rest_date_time_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestDateTimeTestServiceConfiguration -from .operations import DatetimeOperations -from . import models - - -class AutoRestDateTimeTestService(object): - """Test Infrastructure for AutoRest. - - :ivar datetime: DatetimeOperations operations - :vartype datetime: bodydatetime.operations.DatetimeOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDateTimeTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.datetime = DatetimeOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestDateTimeTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_auto_rest_date_time_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_auto_rest_date_time_test_service.py deleted file mode 100644 index 49526c96237..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_auto_rest_date_time_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestDateTimeTestServiceConfiguration -from .operations import DatetimeOperations -from .. import models - - -class AutoRestDateTimeTestService(object): - """Test Infrastructure for AutoRest. - - :ivar datetime: DatetimeOperations operations - :vartype datetime: bodydatetime.aio.operations.DatetimeOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDateTimeTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.datetime = DatetimeOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestDateTimeTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py deleted file mode 100644 index 4c869e1754c..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py +++ /dev/null @@ -1,1000 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DatetimeOperations: - """DatetimeOperations 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: ~bodydatetime.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 get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: - """Get null datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime or None, or the result of cls(response) - :rtype: ~datetime.datetime or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/datetime/null"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> datetime.datetime: - """Get invalid datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/datetime/invalid"} # type: ignore - - @distributed_trace_async - async def get_overflow(self, **kwargs: Any) -> datetime.datetime: - """Get overflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow.metadata = {"url": "/datetime/overflow"} # type: ignore - - @distributed_trace_async - async def get_underflow(self, **kwargs: Any) -> datetime.datetime: - """Get underflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow.metadata = {"url": "/datetime/underflow"} # type: ignore - - @distributed_trace_async - async def put_utc_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put max datetime value 9999-12-31T23:59:59.999Z. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_max_date_time.metadata = {"url": "/datetime/max/utc"} # type: ignore - - @distributed_trace_async - async def put_utc_max_date_time7_digits(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put max datetime value 9999-12-31T23:59:59.9999999Z. - - This is against the recommendation that asks for 3 digits, but allow to test what happens in - that scenario. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_max_date_time7_digits.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms"} # type: ignore - - @distributed_trace_async - async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value 9999-12-31t23:59:59.999z. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_lowercase_max_date_time.metadata = {"url": "/datetime/max/utc/lowercase"} # type: ignore - - @distributed_trace_async - async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value 9999-12-31T23:59:59.999Z. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_uppercase_max_date_time.metadata = {"url": "/datetime/max/utc/uppercase"} # type: ignore - - @distributed_trace_async - async def get_utc_uppercase_max_date_time7_digits(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value 9999-12-31T23:59:59.9999999Z. - - This is against the recommendation that asks for 3 digits, but allow to test what happens in - that scenario. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_uppercase_max_date_time7_digits.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_uppercase_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms/uppercase"} # type: ignore - - @distributed_trace_async - async def put_local_positive_offset_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_positive_offset_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_positive_offset_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset"} # type: ignore - - @distributed_trace_async - async def get_local_positive_offset_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_positive_offset_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_positive_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/lowercase"} # type: ignore - - @distributed_trace_async - async def get_local_positive_offset_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_positive_offset_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_positive_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/uppercase"} # type: ignore - - @distributed_trace_async - async def put_local_negative_offset_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_negative_offset_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_negative_offset_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset"} # type: ignore - - @distributed_trace_async - async def get_local_negative_offset_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_negative_offset_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_negative_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/uppercase"} # type: ignore - - @distributed_trace_async - async def get_local_negative_offset_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_negative_offset_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_negative_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/lowercase"} # type: ignore - - @distributed_trace_async - async def put_utc_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put min datetime value 0001-01-01T00:00:00Z. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore - - @distributed_trace_async - async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get min datetime value 0001-01-01T00:00:00Z. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore - - @distributed_trace_async - async def put_local_positive_offset_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put min datetime value 0001-01-01T00:00:00+14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_positive_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore - - @distributed_trace_async - async def get_local_positive_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get min datetime value 0001-01-01T00:00:00+14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_positive_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore - - @distributed_trace_async - async def put_local_negative_offset_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put min datetime value 0001-01-01T00:00:00-14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_negative_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore - - @distributed_trace_async - async def get_local_negative_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get min datetime value 0001-01-01T00:00:00-14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_negative_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore - - @distributed_trace_async - async def get_local_no_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get min datetime value 0001-01-01T00:00:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_no_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_no_offset_min_date_time.metadata = {"url": "/datetime/min/localnooffset"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py deleted file mode 100644 index ef028131712..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py +++ /dev/null @@ -1,1084 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class DatetimeOperations(object): - """DatetimeOperations 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: ~bodydatetime.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[datetime.datetime] - """Get null datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime or None, or the result of cls(response) - :rtype: ~datetime.datetime or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/datetime/null"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get invalid datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/datetime/invalid"} # type: ignore - - @distributed_trace - def get_overflow( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get overflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow.metadata = {"url": "/datetime/overflow"} # type: ignore - - @distributed_trace - def get_underflow( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get underflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow.metadata = {"url": "/datetime/underflow"} # type: ignore - - @distributed_trace - def put_utc_max_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put max datetime value 9999-12-31T23:59:59.999Z. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_max_date_time.metadata = {"url": "/datetime/max/utc"} # type: ignore - - @distributed_trace - def put_utc_max_date_time7_digits( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put max datetime value 9999-12-31T23:59:59.9999999Z. - - This is against the recommendation that asks for 3 digits, but allow to test what happens in - that scenario. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_max_date_time7_digits.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms"} # type: ignore - - @distributed_trace - def get_utc_lowercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value 9999-12-31t23:59:59.999z. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_lowercase_max_date_time.metadata = {"url": "/datetime/max/utc/lowercase"} # type: ignore - - @distributed_trace - def get_utc_uppercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value 9999-12-31T23:59:59.999Z. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_uppercase_max_date_time.metadata = {"url": "/datetime/max/utc/uppercase"} # type: ignore - - @distributed_trace - def get_utc_uppercase_max_date_time7_digits( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value 9999-12-31T23:59:59.9999999Z. - - This is against the recommendation that asks for 3 digits, but allow to test what happens in - that scenario. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_uppercase_max_date_time7_digits.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_uppercase_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms/uppercase"} # type: ignore - - @distributed_trace - def put_local_positive_offset_max_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_positive_offset_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_positive_offset_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset"} # type: ignore - - @distributed_trace - def get_local_positive_offset_lowercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_positive_offset_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_positive_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/lowercase"} # type: ignore - - @distributed_trace - def get_local_positive_offset_uppercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_positive_offset_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_positive_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/uppercase"} # type: ignore - - @distributed_trace - def put_local_negative_offset_max_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_negative_offset_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_negative_offset_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset"} # type: ignore - - @distributed_trace - def get_local_negative_offset_uppercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_negative_offset_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_negative_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/uppercase"} # type: ignore - - @distributed_trace - def get_local_negative_offset_lowercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_negative_offset_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_negative_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/lowercase"} # type: ignore - - @distributed_trace - def put_utc_min_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put min datetime value 0001-01-01T00:00:00Z. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore - - @distributed_trace - def get_utc_min_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get min datetime value 0001-01-01T00:00:00Z. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore - - @distributed_trace - def put_local_positive_offset_min_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put min datetime value 0001-01-01T00:00:00+14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_positive_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore - - @distributed_trace - def get_local_positive_offset_min_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get min datetime value 0001-01-01T00:00:00+14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_positive_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore - - @distributed_trace - def put_local_negative_offset_min_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put min datetime value 0001-01-01T00:00:00-14:00. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_local_negative_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "iso-8601") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore - - @distributed_trace - def get_local_negative_offset_min_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get min datetime value 0001-01-01T00:00:00-14:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_negative_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore - - @distributed_trace - def get_local_no_offset_min_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get min datetime value 0001-01-01T00:00:00. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_no_offset_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("iso-8601", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_local_no_offset_min_date_time.metadata = {"url": "/datetime/min/localnooffset"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/setup.py deleted file mode 100644 index 9741e241020..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestdatetimetestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestDateTimeTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestDateTimeTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_auto_rest_rfc1123_date_time_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_auto_rest_rfc1123_date_time_test_service.py deleted file mode 100644 index 58618e66623..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_auto_rest_rfc1123_date_time_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestRFC1123DateTimeTestServiceConfiguration -from .operations import Datetimerfc1123Operations -from . import models - - -class AutoRestRFC1123DateTimeTestService(object): - """Test Infrastructure for AutoRest. - - :ivar datetimerfc1123: Datetimerfc1123Operations operations - :vartype datetimerfc1123: bodydatetimerfc1123.operations.Datetimerfc1123Operations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestRFC1123DateTimeTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.datetimerfc1123 = Datetimerfc1123Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestRFC1123DateTimeTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_auto_rest_rfc1123_date_time_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_auto_rest_rfc1123_date_time_test_service.py deleted file mode 100644 index b7659e51e7b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_auto_rest_rfc1123_date_time_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestRFC1123DateTimeTestServiceConfiguration -from .operations import Datetimerfc1123Operations -from .. import models - - -class AutoRestRFC1123DateTimeTestService(object): - """Test Infrastructure for AutoRest. - - :ivar datetimerfc1123: Datetimerfc1123Operations operations - :vartype datetimerfc1123: bodydatetimerfc1123.aio.operations.Datetimerfc1123Operations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestRFC1123DateTimeTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.datetimerfc1123 = Datetimerfc1123Operations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestRFC1123DateTimeTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py deleted file mode 100644 index be025ade51e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py +++ /dev/null @@ -1,433 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Datetimerfc1123Operations: - """Datetimerfc1123Operations 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: ~bodydatetimerfc1123.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 get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: - """Get null datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime or None, or the result of cls(response) - :rtype: ~datetime.datetime or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/datetimerfc1123/null"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> datetime.datetime: - """Get invalid datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/datetimerfc1123/invalid"} # type: ignore - - @distributed_trace_async - async def get_overflow(self, **kwargs: Any) -> datetime.datetime: - """Get overflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow.metadata = {"url": "/datetimerfc1123/overflow"} # type: ignore - - @distributed_trace_async - async def get_underflow(self, **kwargs: Any) -> datetime.datetime: - """Get underflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow.metadata = {"url": "/datetimerfc1123/underflow"} # type: ignore - - @distributed_trace_async - async def put_utc_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "rfc-1123") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_max_date_time.metadata = {"url": "/datetimerfc1123/max"} # type: ignore - - @distributed_trace_async - async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_lowercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/lowercase"} # type: ignore - - @distributed_trace_async - async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_uppercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/uppercase"} # type: ignore - - @distributed_trace_async - async def put_utc_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: - """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "rfc-1123") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore - - @distributed_trace_async - async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: - """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py deleted file mode 100644 index 4f48a144e3a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py +++ /dev/null @@ -1,468 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class Datetimerfc1123Operations(object): - """Datetimerfc1123Operations 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: ~bodydatetimerfc1123.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[datetime.datetime] - """Get null datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime or None, or the result of cls(response) - :rtype: ~datetime.datetime or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/datetimerfc1123/null"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get invalid datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/datetimerfc1123/invalid"} # type: ignore - - @distributed_trace - def get_overflow( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get overflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow.metadata = {"url": "/datetimerfc1123/overflow"} # type: ignore - - @distributed_trace - def get_underflow( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get underflow datetime value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow.metadata = {"url": "/datetimerfc1123/underflow"} # type: ignore - - @distributed_trace - def put_utc_max_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "rfc-1123") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_max_date_time.metadata = {"url": "/datetimerfc1123/max"} # type: ignore - - @distributed_trace - def get_utc_lowercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_lowercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_lowercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/lowercase"} # type: ignore - - @distributed_trace - def get_utc_uppercase_max_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_uppercase_max_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_uppercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/uppercase"} # type: ignore - - @distributed_trace - def put_utc_min_date_time( - self, - datetime_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. - - :param datetime_body: datetime body. - :type datetime_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(datetime_body, "rfc-1123") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore - - @distributed_trace - def get_utc_min_date_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_utc_min_date_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("rfc-1123", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py deleted file mode 100644 index 44b85bb140b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestrfc1123datetimetestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestRFC1123DateTimeTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestRFC1123DateTimeTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_auto_rest_swagger_ba_tdictionary_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_auto_rest_swagger_ba_tdictionary_service.py deleted file mode 100644 index 58bf108a76a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_auto_rest_swagger_ba_tdictionary_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATDictionaryServiceConfiguration -from .operations import DictionaryOperations -from . import models - - -class AutoRestSwaggerBATDictionaryService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar dictionary: DictionaryOperations operations - :vartype dictionary: bodydictionary.operations.DictionaryOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATDictionaryServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.dictionary = DictionaryOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATDictionaryService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_auto_rest_swagger_ba_tdictionary_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_auto_rest_swagger_ba_tdictionary_service.py deleted file mode 100644 index f5638bef233..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_auto_rest_swagger_ba_tdictionary_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATDictionaryServiceConfiguration -from .operations import DictionaryOperations -from .. import models - - -class AutoRestSwaggerBATDictionaryService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar dictionary: DictionaryOperations operations - :vartype dictionary: bodydictionary.aio.operations.DictionaryOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATDictionaryServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.dictionary = DictionaryOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATDictionaryService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py deleted file mode 100644 index b1c292772bd..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py +++ /dev/null @@ -1,2844 +0,0 @@ -# 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 datetime -from typing import Any, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DictionaryOperations: - """DictionaryOperations 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: ~bodydictionary.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 get_null(self, **kwargs: Any) -> Dict[str, int]: - """Get null dictionary value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/dictionary/null"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> Dict[str, int]: - """Get empty dictionary value {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/dictionary/empty"} # type: ignore - - @distributed_trace_async - async def put_empty(self, array_body: Dict[str, str], **kwargs: Any) -> None: - """Set dictionary value empty {}. - - :param array_body: - :type array_body: dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{str}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/dictionary/empty"} # type: ignore - - @distributed_trace_async - async def get_null_value(self, **kwargs: Any) -> Dict[str, str]: - """Get Dictionary with null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_value.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_value.metadata = {"url": "/dictionary/nullvalue"} # type: ignore - - @distributed_trace_async - async def get_null_key(self, **kwargs: Any) -> Dict[str, str]: - """Get Dictionary with null key. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_key.metadata = {"url": "/dictionary/nullkey"} # type: ignore - - @distributed_trace_async - async def get_empty_string_key(self, **kwargs: Any) -> Dict[str, str]: - """Get Dictionary with key as empty string. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty_string_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_string_key.metadata = {"url": "/dictionary/keyemptystring"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> Dict[str, str]: - """Get invalid Dictionary value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/dictionary/invalid"} # type: ignore - - @distributed_trace_async - async def get_boolean_tfft(self, **kwargs: Any) -> Dict[str, bool]: - """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bool, or the result of cls(response) - :rtype: dict[str, bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bool}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore - - @distributed_trace_async - async def put_boolean_tfft(self, array_body: Dict[str, bool], **kwargs: Any) -> None: - """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. - - :param array_body: - :type array_body: dict[str, bool] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{bool}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore - - @distributed_trace_async - async def get_boolean_invalid_null(self, **kwargs: Any) -> Dict[str, bool]: - """Get boolean dictionary value {"0": true, "1": null, "2": false }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bool, or the result of cls(response) - :rtype: dict[str, bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bool}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_null.metadata = {"url": "/dictionary/prim/boolean/true.null.false"} # type: ignore - - @distributed_trace_async - async def get_boolean_invalid_string(self, **kwargs: Any) -> Dict[str, bool]: - """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bool, or the result of cls(response) - :rtype: dict[str, bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bool}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_string.metadata = {"url": "/dictionary/prim/boolean/true.boolean.false"} # type: ignore - - @distributed_trace_async - async def get_integer_valid(self, **kwargs: Any) -> Dict[str, int]: - """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def put_integer_valid(self, array_body: Dict[str, int], **kwargs: Any) -> None: - """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. - - :param array_body: - :type array_body: dict[str, int] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{int}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def get_int_invalid_null(self, **kwargs: Any) -> Dict[str, int]: - """Get integer dictionary value {"0": 1, "1": null, "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_null.metadata = {"url": "/dictionary/prim/integer/1.null.zero"} # type: ignore - - @distributed_trace_async - async def get_int_invalid_string(self, **kwargs: Any) -> Dict[str, int]: - """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_string.metadata = {"url": "/dictionary/prim/integer/1.integer.0"} # type: ignore - - @distributed_trace_async - async def get_long_valid(self, **kwargs: Any) -> Dict[str, int]: - """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to long, or the result of cls(response) - :rtype: dict[str, long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{long}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def put_long_valid(self, array_body: Dict[str, int], **kwargs: Any) -> None: - """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. - - :param array_body: - :type array_body: dict[str, long] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{long}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace_async - async def get_long_invalid_null(self, **kwargs: Any) -> Dict[str, int]: - """Get long dictionary value {"0": 1, "1": null, "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to long, or the result of cls(response) - :rtype: dict[str, long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{long}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_null.metadata = {"url": "/dictionary/prim/long/1.null.zero"} # type: ignore - - @distributed_trace_async - async def get_long_invalid_string(self, **kwargs: Any) -> Dict[str, int]: - """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to long, or the result of cls(response) - :rtype: dict[str, long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{long}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_string.metadata = {"url": "/dictionary/prim/long/1.integer.0"} # type: ignore - - @distributed_trace_async - async def get_float_valid(self, **kwargs: Any) -> Dict[str, float]: - """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def put_float_valid(self, array_body: Dict[str, float], **kwargs: Any) -> None: - """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :param array_body: - :type array_body: dict[str, float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{float}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_float_invalid_null(self, **kwargs: Any) -> Dict[str, float]: - """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_null.metadata = {"url": "/dictionary/prim/float/0.0-null-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_float_invalid_string(self, **kwargs: Any) -> Dict[str, float]: - """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_string.metadata = {"url": "/dictionary/prim/float/1.number.0"} # type: ignore - - @distributed_trace_async - async def get_double_valid(self, **kwargs: Any) -> Dict[str, float]: - """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def put_double_valid(self, array_body: Dict[str, float], **kwargs: Any) -> None: - """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :param array_body: - :type array_body: dict[str, float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{float}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_double_invalid_null(self, **kwargs: Any) -> Dict[str, float]: - """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_null.metadata = {"url": "/dictionary/prim/double/0.0-null-1.2e20"} # type: ignore - - @distributed_trace_async - async def get_double_invalid_string(self, **kwargs: Any) -> Dict[str, float]: - """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_string.metadata = {"url": "/dictionary/prim/double/1.number.0"} # type: ignore - - @distributed_trace_async - async def get_string_valid(self, **kwargs: Any) -> Dict[str, str]: - """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def put_string_valid(self, array_body: Dict[str, str], **kwargs: Any) -> None: - """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. - - :param array_body: - :type array_body: dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{str}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace_async - async def get_string_with_null(self, **kwargs: Any) -> Dict[str, str]: - """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_null.metadata = {"url": "/dictionary/prim/string/foo.null.foo2"} # type: ignore - - @distributed_trace_async - async def get_string_with_invalid(self, **kwargs: Any) -> Dict[str, str]: - """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_invalid.metadata = {"url": "/dictionary/prim/string/foo.123.foo2"} # type: ignore - - @distributed_trace_async - async def get_date_valid(self, **kwargs: Any) -> Dict[str, datetime.date]: - """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to date, or the result of cls(response) - :rtype: dict[str, ~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{date}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore - - @distributed_trace_async - async def put_date_valid(self, array_body: Dict[str, datetime.date], **kwargs: Any) -> None: - """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. - - :param array_body: - :type array_body: dict[str, ~datetime.date] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{date}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore - - @distributed_trace_async - async def get_date_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.date]: - """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to date, or the result of cls(response) - :rtype: dict[str, ~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{date}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_null.metadata = {"url": "/dictionary/prim/date/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_date_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.date]: - """Get date dictionary value {"0": "2011-03-22", "1": "date"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to date, or the result of cls(response) - :rtype: dict[str, ~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{date}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_chars.metadata = {"url": "/dictionary/prim/date/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_time_valid(self, **kwargs: Any) -> Dict[str, datetime.datetime]: - """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", - "2": "1492-10-12T10:15:01-08:00"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{iso-8601}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore - - @distributed_trace_async - async def put_date_time_valid(self, array_body: Dict[str, datetime.datetime], **kwargs: Any) -> None: - """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": - "1492-10-12T10:15:01-08:00"}. - - :param array_body: - :type array_body: dict[str, ~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{iso-8601}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore - - @distributed_trace_async - async def get_date_time_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.datetime]: - """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{iso-8601}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_null.metadata = {"url": "/dictionary/prim/date-time/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_date_time_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.datetime]: - """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{iso-8601}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_chars.metadata = {"url": "/dictionary/prim/date-time/invalidchars"} # type: ignore - - @distributed_trace_async - async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> Dict[str, datetime.datetime]: - """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan - 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{rfc-1123}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace_async - async def put_date_time_rfc1123_valid(self, array_body: Dict[str, datetime.datetime], **kwargs: Any) -> None: - """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 - 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. - - :param array_body: - :type array_body: dict[str, ~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{rfc-1123}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace_async - async def get_duration_valid(self, **kwargs: Any) -> Dict[str, datetime.timedelta]: - """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to timedelta, or the result of cls(response) - :rtype: dict[str, ~datetime.timedelta] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{duration}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore - - @distributed_trace_async - async def put_duration_valid(self, array_body: Dict[str, datetime.timedelta], **kwargs: Any) -> None: - """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. - - :param array_body: - :type array_body: dict[str, ~datetime.timedelta] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{duration}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore - - @distributed_trace_async - async def get_byte_valid(self, **kwargs: Any) -> Dict[str, bytearray]: - """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} - with each item encoded in base64. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bytearray, or the result of cls(response) - :rtype: dict[str, bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bytearray}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore - - @distributed_trace_async - async def put_byte_valid(self, array_body: Dict[str, bytearray], **kwargs: Any) -> None: - """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} - with each elementencoded in base 64. - - :param array_body: - :type array_body: dict[str, bytearray] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{bytearray}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore - - @distributed_trace_async - async def get_byte_invalid_null(self, **kwargs: Any) -> Dict[str, bytearray]: - """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 - encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bytearray, or the result of cls(response) - :rtype: dict[str, bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bytearray}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_invalid_null.metadata = {"url": "/dictionary/prim/byte/invalidnull"} # type: ignore - - @distributed_trace_async - async def get_base64_url(self, **kwargs: Any) -> Dict[str, bytes]: - """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test - string", "2": "Lorem ipsum"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bytes, or the result of cls(response) - :rtype: dict[str, bytes] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{base64}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url.metadata = {"url": "/dictionary/prim/base64url/valid"} # type: ignore - - @distributed_trace_async - async def get_complex_null(self, **kwargs: Any) -> Optional[Dict[str, "_models.Widget"]]: - """Get dictionary of complex type null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget or None, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, "_models.Widget"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_null.metadata = {"url": "/dictionary/complex/null"} # type: ignore - - @distributed_trace_async - async def get_complex_empty(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: - """Get empty dictionary of complex type {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_empty.metadata = {"url": "/dictionary/complex/empty"} # type: ignore - - @distributed_trace_async - async def get_complex_item_null(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: - """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, - "2": {"integer": 5, "string": "6"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_null.metadata = {"url": "/dictionary/complex/itemnull"} # type: ignore - - @distributed_trace_async - async def get_complex_item_empty(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: - """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, - "2": {"integer": 5, "string": "6"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_empty.metadata = {"url": "/dictionary/complex/itemempty"} # type: ignore - - @distributed_trace_async - async def get_complex_valid(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: - """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, - "string": "4"}, "2": {"integer": 5, "string": "6"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore - - @distributed_trace_async - async def put_complex_valid(self, array_body: Dict[str, "_models.Widget"], **kwargs: Any) -> None: - """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": - {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. - - :param array_body: - :type array_body: dict[str, ~bodydictionary.models.Widget] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{Widget}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore - - @distributed_trace_async - async def get_array_null(self, **kwargs: Any) -> Optional[Dict[str, List[str]]]: - """Get a null array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str or None, or the result of cls(response) - :rtype: dict[str, list[str]] or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, List[str]]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_null.metadata = {"url": "/dictionary/array/null"} # type: ignore - - @distributed_trace_async - async def get_array_empty(self, **kwargs: Any) -> Dict[str, List[str]]: - """Get an empty dictionary {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_empty.metadata = {"url": "/dictionary/array/empty"} # type: ignore - - @distributed_trace_async - async def get_array_item_null(self, **kwargs: Any) -> Dict[str, List[str]]: - """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_null.metadata = {"url": "/dictionary/array/itemnull"} # type: ignore - - @distributed_trace_async - async def get_array_item_empty(self, **kwargs: Any) -> Dict[str, List[str]]: - """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_empty.metadata = {"url": "/dictionary/array/itemempty"} # type: ignore - - @distributed_trace_async - async def get_array_valid(self, **kwargs: Any) -> Dict[str, List[str]]: - """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", - "9"]}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore - - @distributed_trace_async - async def put_array_valid(self, array_body: Dict[str, List[str]], **kwargs: Any) -> None: - """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", - "9"]}. - - :param array_body: - :type array_body: dict[str, list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{[str]}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore - - @distributed_trace_async - async def get_dictionary_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: - """Get an dictionaries of dictionaries with value null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_null.metadata = {"url": "/dictionary/dictionary/null"} # type: ignore - - @distributed_trace_async - async def get_dictionary_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: - """Get an dictionaries of dictionaries of type with value {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_empty.metadata = {"url": "/dictionary/dictionary/empty"} # type: ignore - - @distributed_trace_async - async def get_dictionary_item_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_null.metadata = {"url": "/dictionary/dictionary/itemnull"} # type: ignore - - @distributed_trace_async - async def get_dictionary_item_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_empty.metadata = {"url": "/dictionary/dictionary/itemempty"} # type: ignore - - @distributed_trace_async - async def get_dictionary_valid(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": - "eight", "9": "nine"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore - - @distributed_trace_async - async def put_dictionary_valid(self, array_body: Dict[str, Dict[str, str]], **kwargs: Any) -> None: - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": - "eight", "9": "nine"}}. - - :param array_body: - :type array_body: dict[str, dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{{str}}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py deleted file mode 100644 index 26aad828895..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py +++ /dev/null @@ -1,3073 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class DictionaryOperations(object): - """DictionaryOperations 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: ~bodydictionary.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get null dictionary value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/dictionary/null"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get empty dictionary value {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/dictionary/empty"} # type: ignore - - @distributed_trace - def put_empty( - self, - array_body, # type: Dict[str, str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value empty {}. - - :param array_body: - :type array_body: dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{str}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/dictionary/empty"} # type: ignore - - @distributed_trace - def get_null_value( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get Dictionary with null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_value.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_value.metadata = {"url": "/dictionary/nullvalue"} # type: ignore - - @distributed_trace - def get_null_key( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get Dictionary with null key. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_key.metadata = {"url": "/dictionary/nullkey"} # type: ignore - - @distributed_trace - def get_empty_string_key( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get Dictionary with key as empty string. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty_string_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_string_key.metadata = {"url": "/dictionary/keyemptystring"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get invalid Dictionary value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/dictionary/invalid"} # type: ignore - - @distributed_trace - def get_boolean_tfft( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, bool] - """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bool, or the result of cls(response) - :rtype: dict[str, bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bool}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore - - @distributed_trace - def put_boolean_tfft( - self, - array_body, # type: Dict[str, bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. - - :param array_body: - :type array_body: dict[str, bool] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_boolean_tfft.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{bool}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore - - @distributed_trace - def get_boolean_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, bool] - """Get boolean dictionary value {"0": true, "1": null, "2": false }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bool, or the result of cls(response) - :rtype: dict[str, bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bool}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_null.metadata = {"url": "/dictionary/prim/boolean/true.null.false"} # type: ignore - - @distributed_trace - def get_boolean_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, bool] - """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bool, or the result of cls(response) - :rtype: dict[str, bool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bool}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_boolean_invalid_string.metadata = {"url": "/dictionary/prim/boolean/true.boolean.false"} # type: ignore - - @distributed_trace - def get_integer_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace - def put_integer_valid( - self, - array_body, # type: Dict[str, int] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. - - :param array_body: - :type array_body: dict[str, int] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_integer_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{int}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore - - @distributed_trace - def get_int_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get integer dictionary value {"0": 1, "1": null, "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_null.metadata = {"url": "/dictionary/prim/integer/1.null.zero"} # type: ignore - - @distributed_trace - def get_int_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_int_invalid_string.metadata = {"url": "/dictionary/prim/integer/1.integer.0"} # type: ignore - - @distributed_trace - def get_long_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to long, or the result of cls(response) - :rtype: dict[str, long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{long}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace - def put_long_valid( - self, - array_body, # type: Dict[str, int] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. - - :param array_body: - :type array_body: dict[str, long] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_long_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{long}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore - - @distributed_trace - def get_long_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get long dictionary value {"0": 1, "1": null, "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to long, or the result of cls(response) - :rtype: dict[str, long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{long}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_null.metadata = {"url": "/dictionary/prim/long/1.null.zero"} # type: ignore - - @distributed_trace - def get_long_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to long, or the result of cls(response) - :rtype: dict[str, long] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{long}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_long_invalid_string.metadata = {"url": "/dictionary/prim/long/1.integer.0"} # type: ignore - - @distributed_trace - def get_float_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, float] - """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def put_float_valid( - self, - array_body, # type: Dict[str, float] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :param array_body: - :type array_body: dict[str, float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_float_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{float}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def get_float_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, float] - """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_null.metadata = {"url": "/dictionary/prim/float/0.0-null-1.2e20"} # type: ignore - - @distributed_trace - def get_float_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, float] - """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_float_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_float_invalid_string.metadata = {"url": "/dictionary/prim/float/1.number.0"} # type: ignore - - @distributed_trace - def get_double_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, float] - """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def put_double_valid( - self, - array_body, # type: Dict[str, float] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. - - :param array_body: - :type array_body: dict[str, float] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_double_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{float}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore - - @distributed_trace - def get_double_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, float] - """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_null.metadata = {"url": "/dictionary/prim/double/0.0-null-1.2e20"} # type: ignore - - @distributed_trace - def get_double_invalid_string( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, float] - """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to float, or the result of cls(response) - :rtype: dict[str, float] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_double_invalid_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{float}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_double_invalid_string.metadata = {"url": "/dictionary/prim/double/1.number.0"} # type: ignore - - @distributed_trace - def get_string_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def put_string_valid( - self, - array_body, # type: Dict[str, str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. - - :param array_body: - :type array_body: dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_string_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{str}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore - - @distributed_trace - def get_string_with_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_null.metadata = {"url": "/dictionary/prim/string/foo.null.foo2"} # type: ignore - - @distributed_trace - def get_string_with_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] - """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) - :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_string_with_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{str}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_string_with_invalid.metadata = {"url": "/dictionary/prim/string/foo.123.foo2"} # type: ignore - - @distributed_trace - def get_date_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.date] - """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to date, or the result of cls(response) - :rtype: dict[str, ~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{date}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore - - @distributed_trace - def put_date_valid( - self, - array_body, # type: Dict[str, datetime.date] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. - - :param array_body: - :type array_body: dict[str, ~datetime.date] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{date}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore - - @distributed_trace - def get_date_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.date] - """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to date, or the result of cls(response) - :rtype: dict[str, ~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{date}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_null.metadata = {"url": "/dictionary/prim/date/invalidnull"} # type: ignore - - @distributed_trace - def get_date_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.date] - """Get date dictionary value {"0": "2011-03-22", "1": "date"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to date, or the result of cls(response) - :rtype: dict[str, ~datetime.date] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{date}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_invalid_chars.metadata = {"url": "/dictionary/prim/date/invalidchars"} # type: ignore - - @distributed_trace - def get_date_time_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.datetime] - """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", - "2": "1492-10-12T10:15:01-08:00"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{iso-8601}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore - - @distributed_trace - def put_date_time_valid( - self, - array_body, # type: Dict[str, datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": - "1492-10-12T10:15:01-08:00"}. - - :param array_body: - :type array_body: dict[str, ~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{iso-8601}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore - - @distributed_trace - def get_date_time_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.datetime] - """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{iso-8601}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_null.metadata = {"url": "/dictionary/prim/date-time/invalidnull"} # type: ignore - - @distributed_trace - def get_date_time_invalid_chars( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.datetime] - """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_invalid_chars.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{iso-8601}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_invalid_chars.metadata = {"url": "/dictionary/prim/date-time/invalidchars"} # type: ignore - - @distributed_trace - def get_date_time_rfc1123_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.datetime] - """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan - 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to datetime, or the result of cls(response) - :rtype: dict[str, ~datetime.datetime] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{rfc-1123}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace - def put_date_time_rfc1123_valid( - self, - array_body, # type: Dict[str, datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 - 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. - - :param array_body: - :type array_body: dict[str, ~datetime.datetime] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_date_time_rfc1123_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{rfc-1123}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore - - @distributed_trace - def get_duration_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, datetime.timedelta] - """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to timedelta, or the result of cls(response) - :rtype: dict[str, ~datetime.timedelta] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{duration}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore - - @distributed_trace - def put_duration_valid( - self, - array_body, # type: Dict[str, datetime.timedelta] - **kwargs # type: Any - ): - # type: (...) -> None - """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. - - :param array_body: - :type array_body: dict[str, ~datetime.timedelta] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_duration_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{duration}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore - - @distributed_trace - def get_byte_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, bytearray] - """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} - with each item encoded in base64. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bytearray, or the result of cls(response) - :rtype: dict[str, bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bytearray}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore - - @distributed_trace - def put_byte_valid( - self, - array_body, # type: Dict[str, bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} - with each elementencoded in base 64. - - :param array_body: - :type array_body: dict[str, bytearray] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_byte_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{bytearray}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore - - @distributed_trace - def get_byte_invalid_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, bytearray] - """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 - encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bytearray, or the result of cls(response) - :rtype: dict[str, bytearray] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_byte_invalid_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{bytearray}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_byte_invalid_null.metadata = {"url": "/dictionary/prim/byte/invalidnull"} # type: ignore - - @distributed_trace - def get_base64_url( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, bytes] - """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test - string", "2": "Lorem ipsum"}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to bytes, or the result of cls(response) - :rtype: dict[str, bytes] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{base64}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url.metadata = {"url": "/dictionary/prim/base64url/valid"} # type: ignore - - @distributed_trace - def get_complex_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[Dict[str, "_models.Widget"]] - """Get dictionary of complex type null value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget or None, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, "_models.Widget"]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_null.metadata = {"url": "/dictionary/complex/null"} # type: ignore - - @distributed_trace - def get_complex_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, "_models.Widget"] - """Get empty dictionary of complex type {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_empty.metadata = {"url": "/dictionary/complex/empty"} # type: ignore - - @distributed_trace - def get_complex_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, "_models.Widget"] - """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, - "2": {"integer": 5, "string": "6"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_null.metadata = {"url": "/dictionary/complex/itemnull"} # type: ignore - - @distributed_trace - def get_complex_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, "_models.Widget"] - """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, - "2": {"integer": 5, "string": "6"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_item_empty.metadata = {"url": "/dictionary/complex/itemempty"} # type: ignore - - @distributed_trace - def get_complex_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, "_models.Widget"] - """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, - "string": "4"}, "2": {"integer": 5, "string": "6"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to Widget, or the result of cls(response) - :rtype: dict[str, ~bodydictionary.models.Widget] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{Widget}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore - - @distributed_trace - def put_complex_valid( - self, - array_body, # type: Dict[str, "_models.Widget"] - **kwargs # type: Any - ): - # type: (...) -> None - """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": - {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. - - :param array_body: - :type array_body: dict[str, ~bodydictionary.models.Widget] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_complex_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{Widget}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore - - @distributed_trace - def get_array_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[Dict[str, List[str]]] - """Get a null array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str or None, or the result of cls(response) - :rtype: dict[str, list[str]] or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, List[str]]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_null.metadata = {"url": "/dictionary/array/null"} # type: ignore - - @distributed_trace - def get_array_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, List[str]] - """Get an empty dictionary {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_empty.metadata = {"url": "/dictionary/array/empty"} # type: ignore - - @distributed_trace - def get_array_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, List[str]] - """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_null.metadata = {"url": "/dictionary/array/itemnull"} # type: ignore - - @distributed_trace - def get_array_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, List[str]] - """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_item_empty.metadata = {"url": "/dictionary/array/itemempty"} # type: ignore - - @distributed_trace - def get_array_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, List[str]] - """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", - "9"]}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to list of str, or the result of cls(response) - :rtype: dict[str, list[str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{[str]}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore - - @distributed_trace - def put_array_valid( - self, - array_body, # type: Dict[str, List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", - "9"]}. - - :param array_body: - :type array_body: dict[str, list[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/json") - accept = "application/json" - - # Construct URL - url = self.put_array_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{[str]}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore - - @distributed_trace - def get_dictionary_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, Dict[str, str]] - """Get an dictionaries of dictionaries with value null. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_null.metadata = {"url": "/dictionary/dictionary/null"} # type: ignore - - @distributed_trace - def get_dictionary_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, Dict[str, str]] - """Get an dictionaries of dictionaries of type with value {}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_empty.metadata = {"url": "/dictionary/dictionary/empty"} # type: ignore - - @distributed_trace - def get_dictionary_item_null( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, Dict[str, str]] - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_null.metadata = {"url": "/dictionary/dictionary/itemnull"} # type: ignore - - @distributed_trace - def get_dictionary_item_empty( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, Dict[str, str]] - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_item_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_item_empty.metadata = {"url": "/dictionary/dictionary/itemempty"} # type: ignore - - @distributed_trace - def get_dictionary_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, Dict[str, str]] - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": - "eight", "9": "nine"}}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to dict mapping str to str, or the result of cls(response) - :rtype: dict[str, dict[str, str]] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{{str}}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore - - @distributed_trace - def put_dictionary_valid( - self, - array_body, # type: Dict[str, Dict[str, str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": - "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": - "eight", "9": "nine"}}. - - :param array_body: - :type array_body: dict[str, dict[str, 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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{{str}}") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/setup.py deleted file mode 100644 index 6d63a9d1a14..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatdictionaryservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATDictionaryService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATDictionaryService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_auto_rest_duration_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_auto_rest_duration_test_service.py deleted file mode 100644 index 644e71de070..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/_auto_rest_duration_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestDurationTestServiceConfiguration -from .operations import DurationOperations -from . import models - - -class AutoRestDurationTestService(object): - """Test Infrastructure for AutoRest. - - :ivar duration: DurationOperations operations - :vartype duration: bodyduration.operations.DurationOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDurationTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.duration = DurationOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestDurationTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py deleted file mode 100644 index 1f956fba577..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestDurationTestServiceConfiguration -from .operations import DurationOperations -from .. import models - - -class AutoRestDurationTestService(object): - """Test Infrastructure for AutoRest. - - :ivar duration: DurationOperations operations - :vartype duration: bodyduration.aio.operations.DurationOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestDurationTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.duration = DurationOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestDurationTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py deleted file mode 100644 index cf8abe6538b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py +++ /dev/null @@ -1,220 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DurationOperations: - """DurationOperations 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: ~bodyduration.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 get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: - """Get null duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta or None, or the result of cls(response) - :rtype: ~datetime.timedelta or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/duration/null"} # type: ignore - - @distributed_trace_async - async def put_positive_duration(self, duration_body: datetime.timedelta, **kwargs: Any) -> None: - """Put a positive duration value. - - :param duration_body: duration body. - :type duration_body: ~datetime.timedelta - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(duration_body, "duration") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace_async - async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: - """Get a positive duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: - """Get an invalid duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py deleted file mode 100644 index 72de7e128df..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py +++ /dev/null @@ -1,238 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class DurationOperations(object): - """DurationOperations 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: ~bodyduration.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[datetime.timedelta] - """Get null duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta or None, or the result of cls(response) - :rtype: ~datetime.timedelta or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/duration/null"} # type: ignore - - @distributed_trace - def put_positive_duration( - self, - duration_body, # type: datetime.timedelta - **kwargs # type: Any - ): - # type: (...) -> None - """Put a positive duration value. - - :param duration_body: duration body. - :type duration_body: ~datetime.timedelta - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(duration_body, "duration") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace - def get_positive_duration( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.timedelta - """Get a positive duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_positive_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.timedelta - """Get an invalid duration value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("duration", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/setup.py deleted file mode 100644 index 47f4913beda..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestdurationtestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestDurationTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestDurationTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_auto_rest_swagger_bat_file_service.py b/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_auto_rest_swagger_bat_file_service.py deleted file mode 100644 index 8bd2f45f034..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_auto_rest_swagger_bat_file_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATFileServiceConfiguration -from .operations import FilesOperations -from . import models - - -class AutoRestSwaggerBATFileService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar files: FilesOperations operations - :vartype files: bodyfile.operations.FilesOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATFileServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.files = FilesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATFileService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_auto_rest_swagger_bat_file_service.py b/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_auto_rest_swagger_bat_file_service.py deleted file mode 100644 index 2b10d9d7220..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_auto_rest_swagger_bat_file_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATFileServiceConfiguration -from .operations import FilesOperations -from .. import models - - -class AutoRestSwaggerBATFileService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar files: FilesOperations operations - :vartype files: bodyfile.aio.operations.FilesOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATFileServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.files = FilesOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATFileService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py deleted file mode 100644 index 5c2df733b3f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py +++ /dev/null @@ -1,174 +0,0 @@ -# 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, Callable, Dict, Generic, IO, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class FilesOperations: - """FilesOperations 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: ~bodyfile.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 get_file(self, **kwargs: Any) -> IO: - """Get file. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "image/png, application/json" - - # Construct URL - url = self.get_file.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_file.metadata = {"url": "/files/stream/nonempty"} # type: ignore - - @distributed_trace_async - async def get_file_large(self, **kwargs: Any) -> IO: - """Get a large file. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "image/png, application/json" - - # Construct URL - url = self.get_file_large.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_file_large.metadata = {"url": "/files/stream/verylarge"} # type: ignore - - @distributed_trace_async - async def get_empty_file(self, **kwargs: Any) -> IO: - """Get empty file. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "image/png, application/json" - - # Construct URL - url = self.get_empty_file.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_file.metadata = {"url": "/files/stream/empty"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py deleted file mode 100644 index 96a905b7ed0..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py +++ /dev/null @@ -1,187 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class FilesOperations(object): - """FilesOperations 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: ~bodyfile.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 get_file( - self, **kwargs # type: Any - ): - # type: (...) -> IO - """Get file. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "image/png, application/json" - - # Construct URL - url = self.get_file.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_file.metadata = {"url": "/files/stream/nonempty"} # type: ignore - - @distributed_trace - def get_file_large( - self, **kwargs # type: Any - ): - # type: (...) -> IO - """Get a large file. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "image/png, application/json" - - # Construct URL - url = self.get_file_large.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_file_large.metadata = {"url": "/files/stream/verylarge"} # type: ignore - - @distributed_trace - def get_empty_file( - self, **kwargs # type: Any - ): - # type: (...) -> IO - """Get empty file. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "image/png, application/json" - - # Construct URL - url = self.get_empty_file.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_file.metadata = {"url": "/files/stream/empty"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyFile/setup.py deleted file mode 100644 index 356cfee04da..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFile/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatfileservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATFileService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATFileService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_auto_rest_swagger_bat_form_data_service.py b/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_auto_rest_swagger_bat_form_data_service.py deleted file mode 100644 index 22306e3ffd9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_auto_rest_swagger_bat_form_data_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATFormDataServiceConfiguration -from .operations import FormdataOperations -from . import models - - -class AutoRestSwaggerBATFormDataService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar formdata: FormdataOperations operations - :vartype formdata: bodyformdata.operations.FormdataOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATFormDataServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.formdata = FormdataOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATFormDataService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_auto_rest_swagger_bat_form_data_service.py b/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_auto_rest_swagger_bat_form_data_service.py deleted file mode 100644 index 331ae2a81b3..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_auto_rest_swagger_bat_form_data_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATFormDataServiceConfiguration -from .operations import FormdataOperations -from .. import models - - -class AutoRestSwaggerBATFormDataService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar formdata: FormdataOperations operations - :vartype formdata: bodyformdata.aio.operations.FormdataOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATFormDataServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.formdata = FormdataOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATFormDataService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py deleted file mode 100644 index 68b8fe4b229..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py +++ /dev/null @@ -1,199 +0,0 @@ -# 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, Callable, Dict, Generic, IO, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class FormdataOperations: - """FormdataOperations 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: ~bodyformdata.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 upload_file(self, file_content: IO, file_name: str, **kwargs: Any) -> IO: - """Upload file. - - :param file_content: File to upload. - :type file_content: IO - :param file_name: File name to upload. Name has to be spelled exactly as written here. - :type file_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "multipart/form-data") - accept = "application/octet-stream, application/json" - - # Construct URL - url = self.upload_file.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - # Construct form data - _form_content = { - "fileContent": file_content, - "fileName": file_name, - } - request = self._client.post(url, query_parameters, header_parameters, form_content=_form_content) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - upload_file.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore - - @distributed_trace_async - async def upload_file_via_body(self, file_content: IO, **kwargs: Any) -> IO: - """Upload file. - - :param file_content: File to upload. - :type file_content: IO - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/octet-stream") - accept = "application/octet-stream, application/json" - - # Construct URL - url = self.upload_file_via_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = file_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - upload_file_via_body.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore - - @distributed_trace_async - async def upload_files(self, file_content: List[IO], **kwargs: Any) -> IO: - """Upload multiple files. - - :param file_content: Files to upload. - :type file_content: list[IO] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "multipart/form-data") - accept = "application/octet-stream, application/json" - - # Construct URL - url = self.upload_files.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - # Construct form data - _form_content = { - "fileContent": file_content, - } - request = self._client.post(url, query_parameters, header_parameters, form_content=_form_content) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - upload_files.metadata = {"url": "/formdata/stream/uploadfiles"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py deleted file mode 100644 index dcd37f74668..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py +++ /dev/null @@ -1,219 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class FormdataOperations(object): - """FormdataOperations 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: ~bodyformdata.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 upload_file( - self, - file_content, # type: IO - file_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> IO - """Upload file. - - :param file_content: File to upload. - :type file_content: IO - :param file_name: File name to upload. Name has to be spelled exactly as written here. - :type file_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "multipart/form-data") - accept = "application/octet-stream, application/json" - - # Construct URL - url = self.upload_file.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - # Construct form data - _form_content = { - "fileContent": file_content, - "fileName": file_name, - } - request = self._client.post(url, query_parameters, header_parameters, form_content=_form_content) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - upload_file.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore - - @distributed_trace - def upload_file_via_body( - self, - file_content, # type: IO - **kwargs # type: Any - ): - # type: (...) -> IO - """Upload file. - - :param file_content: File to upload. - :type file_content: IO - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/octet-stream") - accept = "application/octet-stream, application/json" - - # Construct URL - url = self.upload_file_via_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = file_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - upload_file_via_body.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore - - @distributed_trace - def upload_files( - self, - file_content, # type: List[IO] - **kwargs # type: Any - ): - # type: (...) -> IO - """Upload multiple files. - - :param file_content: Files to upload. - :type file_content: list[IO] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[IO] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "multipart/form-data") - accept = "application/octet-stream, application/json" - - # Construct URL - url = self.upload_files.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - # Construct form data - _form_content = { - "fileContent": file_content, - } - request = self._client.post(url, query_parameters, header_parameters, form_content=_form_content) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = response.stream_download(self._client._pipeline) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - upload_files.metadata = {"url": "/formdata/stream/uploadfiles"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyFormData/setup.py deleted file mode 100644 index 28c0309c5e6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyFormData/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatformdataservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATFormDataService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATFormDataService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_auto_rest_integer_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_auto_rest_integer_test_service.py deleted file mode 100644 index 0a9ec6fb8c5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_auto_rest_integer_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestIntegerTestServiceConfiguration -from .operations import IntOperations -from . import models - - -class AutoRestIntegerTestService(object): - """Test Infrastructure for AutoRest. - - :ivar int: IntOperations operations - :vartype int: bodyinteger.operations.IntOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestIntegerTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.int = IntOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestIntegerTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_auto_rest_integer_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_auto_rest_integer_test_service.py deleted file mode 100644 index ec6dde5c774..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_auto_rest_integer_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestIntegerTestServiceConfiguration -from .operations import IntOperations -from .. import models - - -class AutoRestIntegerTestService(object): - """Test Infrastructure for AutoRest. - - :ivar int: IntOperations operations - :vartype int: bodyinteger.aio.operations.IntOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestIntegerTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.int = IntOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestIntegerTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py deleted file mode 100644 index 73bbd0ef6dd..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py +++ /dev/null @@ -1,652 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IntOperations: - """IntOperations 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: ~bodyinteger.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 get_null(self, **kwargs: Any) -> Optional[int]: - """Get null Int value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int or None, or the result of cls(response) - :rtype: int or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/int/null"} # type: ignore - - @distributed_trace_async - async def get_invalid(self, **kwargs: Any) -> int: - """Get invalid Int value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/int/invalid"} # type: ignore - - @distributed_trace_async - async def get_overflow_int32(self, **kwargs: Any) -> int: - """Get overflow Int32 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow_int32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow_int32.metadata = {"url": "/int/overflowint32"} # type: ignore - - @distributed_trace_async - async def get_underflow_int32(self, **kwargs: Any) -> int: - """Get underflow Int32 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow_int32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow_int32.metadata = {"url": "/int/underflowint32"} # type: ignore - - @distributed_trace_async - async def get_overflow_int64(self, **kwargs: Any) -> int: - """Get overflow Int64 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: long, or the result of cls(response) - :rtype: long - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow_int64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("long", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow_int64.metadata = {"url": "/int/overflowint64"} # type: ignore - - @distributed_trace_async - async def get_underflow_int64(self, **kwargs: Any) -> int: - """Get underflow Int64 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: long, or the result of cls(response) - :rtype: long - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow_int64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("long", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow_int64.metadata = {"url": "/int/underflowint64"} # type: ignore - - @distributed_trace_async - async def put_max32(self, int_body: int, **kwargs: Any) -> None: - """Put max int32 value. - - :param int_body: int body. - :type int_body: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_max32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "int") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_max32.metadata = {"url": "/int/max/32"} # type: ignore - - @distributed_trace_async - async def put_max64(self, int_body: int, **kwargs: Any) -> None: - """Put max int64 value. - - :param int_body: int body. - :type int_body: long - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_max64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "long") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_max64.metadata = {"url": "/int/max/64"} # type: ignore - - @distributed_trace_async - async def put_min32(self, int_body: int, **kwargs: Any) -> None: - """Put min int32 value. - - :param int_body: int body. - :type int_body: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_min32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "int") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_min32.metadata = {"url": "/int/min/32"} # type: ignore - - @distributed_trace_async - async def put_min64(self, int_body: int, **kwargs: Any) -> None: - """Put min int64 value. - - :param int_body: int body. - :type int_body: long - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_min64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "long") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_min64.metadata = {"url": "/int/min/64"} # type: ignore - - @distributed_trace_async - async def get_unix_time(self, **kwargs: Any) -> datetime.datetime: - """Get datetime encoded as Unix time value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_unix_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("unix-time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_unix_time.metadata = {"url": "/int/unixtime"} # type: ignore - - @distributed_trace_async - async def put_unix_time_date(self, int_body: datetime.datetime, **kwargs: Any) -> None: - """Put datetime encoded as Unix time. - - :param int_body: int body. - :type int_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_unix_time_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "unix-time") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_unix_time_date.metadata = {"url": "/int/unixtime"} # type: ignore - - @distributed_trace_async - async def get_invalid_unix_time(self, **kwargs: Any) -> datetime.datetime: - """Get invalid Unix time value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_unix_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("unix-time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_unix_time.metadata = {"url": "/int/invalidunixtime"} # type: ignore - - @distributed_trace_async - async def get_null_unix_time(self, **kwargs: Any) -> Optional[datetime.datetime]: - """Get null Unix time value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime or None, or the result of cls(response) - :rtype: ~datetime.datetime or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_unix_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("unix-time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_unix_time.metadata = {"url": "/int/nullunixtime"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py deleted file mode 100644 index d5903221f6d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py +++ /dev/null @@ -1,708 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class IntOperations(object): - """IntOperations 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: ~bodyinteger.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[int] - """Get null Int value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int or None, or the result of cls(response) - :rtype: int or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/int/null"} # type: ignore - - @distributed_trace - def get_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> int - """Get invalid Int value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid.metadata = {"url": "/int/invalid"} # type: ignore - - @distributed_trace - def get_overflow_int32( - self, **kwargs # type: Any - ): - # type: (...) -> int - """Get overflow Int32 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow_int32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow_int32.metadata = {"url": "/int/overflowint32"} # type: ignore - - @distributed_trace - def get_underflow_int32( - self, **kwargs # type: Any - ): - # type: (...) -> int - """Get underflow Int32 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow_int32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow_int32.metadata = {"url": "/int/underflowint32"} # type: ignore - - @distributed_trace - def get_overflow_int64( - self, **kwargs # type: Any - ): - # type: (...) -> int - """Get overflow Int64 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: long, or the result of cls(response) - :rtype: long - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_overflow_int64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("long", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_overflow_int64.metadata = {"url": "/int/overflowint64"} # type: ignore - - @distributed_trace - def get_underflow_int64( - self, **kwargs # type: Any - ): - # type: (...) -> int - """Get underflow Int64 value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: long, or the result of cls(response) - :rtype: long - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[int] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_underflow_int64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("long", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_underflow_int64.metadata = {"url": "/int/underflowint64"} # type: ignore - - @distributed_trace - def put_max32( - self, - int_body, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Put max int32 value. - - :param int_body: int body. - :type int_body: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_max32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "int") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_max32.metadata = {"url": "/int/max/32"} # type: ignore - - @distributed_trace - def put_max64( - self, - int_body, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Put max int64 value. - - :param int_body: int body. - :type int_body: long - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_max64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "long") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_max64.metadata = {"url": "/int/max/64"} # type: ignore - - @distributed_trace - def put_min32( - self, - int_body, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Put min int32 value. - - :param int_body: int body. - :type int_body: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_min32.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "int") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_min32.metadata = {"url": "/int/min/32"} # type: ignore - - @distributed_trace - def put_min64( - self, - int_body, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Put min int64 value. - - :param int_body: int body. - :type int_body: long - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_min64.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "long") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_min64.metadata = {"url": "/int/min/64"} # type: ignore - - @distributed_trace - def get_unix_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get datetime encoded as Unix time value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_unix_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("unix-time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_unix_time.metadata = {"url": "/int/unixtime"} # type: ignore - - @distributed_trace - def put_unix_time_date( - self, - int_body, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Put datetime encoded as Unix time. - - :param int_body: int body. - :type int_body: ~datetime.datetime - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_unix_time_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(int_body, "unix-time") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_unix_time_date.metadata = {"url": "/int/unixtime"} # type: ignore - - @distributed_trace - def get_invalid_unix_time( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.datetime - """Get invalid Unix time value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_unix_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("unix-time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_unix_time.metadata = {"url": "/int/invalidunixtime"} # type: ignore - - @distributed_trace - def get_null_unix_time( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[datetime.datetime] - """Get null Unix time value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime or None, or the result of cls(response) - :rtype: ~datetime.datetime or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_unix_time.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("unix-time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_unix_time.metadata = {"url": "/int/nullunixtime"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/setup.py deleted file mode 100644 index 3e59a6b4673..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestintegertestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestIntegerTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestIntegerTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_auto_rest_number_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_auto_rest_number_test_service.py deleted file mode 100644 index 81229864507..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_auto_rest_number_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestNumberTestServiceConfiguration -from .operations import NumberOperations -from . import models - - -class AutoRestNumberTestService(object): - """Test Infrastructure for AutoRest. - - :ivar number: NumberOperations operations - :vartype number: bodynumber.operations.NumberOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestNumberTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.number = NumberOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestNumberTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_auto_rest_number_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_auto_rest_number_test_service.py deleted file mode 100644 index 3b3523decf8..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_auto_rest_number_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestNumberTestServiceConfiguration -from .operations import NumberOperations -from .. import models - - -class AutoRestNumberTestService(object): - """Test Infrastructure for AutoRest. - - :ivar number: NumberOperations operations - :vartype number: bodynumber.aio.operations.NumberOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestNumberTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.number = NumberOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestNumberTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py deleted file mode 100644 index 61f62a0515d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py +++ /dev/null @@ -1,1082 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class NumberOperations: - """NumberOperations 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: ~bodynumber.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 get_null(self, **kwargs: Any) -> Optional[float]: - """Get null Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float or None, or the result of cls(response) - :rtype: float or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/number/null"} # type: ignore - - @distributed_trace_async - async def get_invalid_float(self, **kwargs: Any) -> float: - """Get invalid float Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_float.metadata = {"url": "/number/invalidfloat"} # type: ignore - - @distributed_trace_async - async def get_invalid_double(self, **kwargs: Any) -> float: - """Get invalid double Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_double.metadata = {"url": "/number/invaliddouble"} # type: ignore - - @distributed_trace_async - async def get_invalid_decimal(self, **kwargs: Any) -> float: - """Get invalid decimal Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_decimal.metadata = {"url": "/number/invaliddecimal"} # type: ignore - - @distributed_trace_async - async def put_big_float(self, number_body: float, **kwargs: Any) -> None: - """Put big float value 3.402823e+20. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_big_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore - - @distributed_trace_async - async def get_big_float(self, **kwargs: Any) -> float: - """Get big float value 3.402823e+20. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore - - @distributed_trace_async - async def put_big_double(self, number_body: float, **kwargs: Any) -> None: - """Put big double value 2.5976931e+101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_big_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore - - @distributed_trace_async - async def get_big_double(self, **kwargs: Any) -> float: - """Get big double value 2.5976931e+101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore - - @distributed_trace_async - async def put_big_double_positive_decimal(self, **kwargs: Any) -> None: - """Put big double value 99999999.99. - - :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/json") - number_body = 99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_double_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore - - @distributed_trace_async - async def get_big_double_positive_decimal(self, **kwargs: Any) -> float: - """Get big double value 99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_double_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore - - @distributed_trace_async - async def put_big_double_negative_decimal(self, **kwargs: Any) -> None: - """Put big double value -99999999.99. - - :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/json") - number_body = -99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_double_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore - - @distributed_trace_async - async def get_big_double_negative_decimal(self, **kwargs: Any) -> float: - """Get big double value -99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_double_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore - - @distributed_trace_async - async def put_big_decimal(self, number_body: float, **kwargs: Any) -> None: - """Put big decimal value 2.5976931e+101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_big_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore - - @distributed_trace_async - async def get_big_decimal(self, **kwargs: Any) -> float: - """Get big decimal value 2.5976931e+101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore - - @distributed_trace_async - async def put_big_decimal_positive_decimal(self, **kwargs: Any) -> None: - """Put big decimal value 99999999.99. - - :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/json") - number_body = 99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_decimal_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore - - @distributed_trace_async - async def get_big_decimal_positive_decimal(self, **kwargs: Any) -> float: - """Get big decimal value 99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_decimal_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore - - @distributed_trace_async - async def put_big_decimal_negative_decimal(self, **kwargs: Any) -> None: - """Put big decimal value -99999999.99. - - :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/json") - number_body = -99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_decimal_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore - - @distributed_trace_async - async def get_big_decimal_negative_decimal(self, **kwargs: Any) -> float: - """Get big decimal value -99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_decimal_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore - - @distributed_trace_async - async def put_small_float(self, number_body: float, **kwargs: Any) -> None: - """Put small float value 3.402823e-20. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_small_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore - - @distributed_trace_async - async def get_small_float(self, **kwargs: Any) -> float: - """Get big double value 3.402823e-20. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_small_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore - - @distributed_trace_async - async def put_small_double(self, number_body: float, **kwargs: Any) -> None: - """Put small double value 2.5976931e-101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_small_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore - - @distributed_trace_async - async def get_small_double(self, **kwargs: Any) -> float: - """Get big double value 2.5976931e-101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_small_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore - - @distributed_trace_async - async def put_small_decimal(self, number_body: float, **kwargs: Any) -> None: - """Put small decimal value 2.5976931e-101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_small_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore - - @distributed_trace_async - async def get_small_decimal(self, **kwargs: Any) -> float: - """Get small decimal value 2.5976931e-101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_small_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py deleted file mode 100644 index a22b08de2c5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py +++ /dev/null @@ -1,1170 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class NumberOperations(object): - """NumberOperations 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: ~bodynumber.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[float] - """Get null Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float or None, or the result of cls(response) - :rtype: float or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[float]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/number/null"} # type: ignore - - @distributed_trace - def get_invalid_float( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get invalid float Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_float.metadata = {"url": "/number/invalidfloat"} # type: ignore - - @distributed_trace - def get_invalid_double( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get invalid double Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_double.metadata = {"url": "/number/invaliddouble"} # type: ignore - - @distributed_trace - def get_invalid_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get invalid decimal Number value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_invalid_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_invalid_decimal.metadata = {"url": "/number/invaliddecimal"} # type: ignore - - @distributed_trace - def put_big_float( - self, - number_body, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Put big float value 3.402823e+20. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_big_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore - - @distributed_trace - def get_big_float( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big float value 3.402823e+20. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore - - @distributed_trace - def put_big_double( - self, - number_body, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Put big double value 2.5976931e+101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_big_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore - - @distributed_trace - def get_big_double( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big double value 2.5976931e+101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore - - @distributed_trace - def put_big_double_positive_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Put big double value 99999999.99. - - :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/json") - number_body = 99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_double_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore - - @distributed_trace - def get_big_double_positive_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big double value 99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_double_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore - - @distributed_trace - def put_big_double_negative_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Put big double value -99999999.99. - - :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/json") - number_body = -99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_double_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore - - @distributed_trace - def get_big_double_negative_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big double value -99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_double_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore - - @distributed_trace - def put_big_decimal( - self, - number_body, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Put big decimal value 2.5976931e+101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_big_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore - - @distributed_trace - def get_big_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big decimal value 2.5976931e+101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore - - @distributed_trace - def put_big_decimal_positive_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Put big decimal value 99999999.99. - - :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/json") - number_body = 99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_decimal_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore - - @distributed_trace - def get_big_decimal_positive_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big decimal value 99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_decimal_positive_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore - - @distributed_trace - def put_big_decimal_negative_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Put big decimal value -99999999.99. - - :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/json") - number_body = -99999999.99 - accept = "application/json" - - # Construct URL - url = self.put_big_decimal_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore - - @distributed_trace - def get_big_decimal_negative_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big decimal value -99999999.99. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_big_decimal_negative_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore - - @distributed_trace - def put_small_float( - self, - number_body, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Put small float value 3.402823e-20. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_small_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore - - @distributed_trace - def get_small_float( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big double value 3.402823e-20. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_small_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore - - @distributed_trace - def put_small_double( - self, - number_body, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Put small double value 2.5976931e-101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_small_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore - - @distributed_trace - def get_small_double( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get big double value 2.5976931e-101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_small_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore - - @distributed_trace - def put_small_decimal( - self, - number_body, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Put small decimal value 2.5976931e-101. - - :param number_body: number body. - :type number_body: float - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_small_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(number_body, "float") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore - - @distributed_trace - def get_small_decimal( - self, **kwargs # type: Any - ): - # type: (...) -> float - """Get small decimal value 2.5976931e-101. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[float] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_small_decimal.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/setup.py deleted file mode 100644 index 3c25c7dec0b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestnumbertestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestNumberTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestNumberTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_auto_rest_swagger_bat_service.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_auto_rest_swagger_bat_service.py deleted file mode 100644 index 9b03846a630..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_auto_rest_swagger_bat_service.py +++ /dev/null @@ -1,81 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATServiceConfiguration -from .operations import StringOperations -from .operations import EnumOperations -from . import models - - -class AutoRestSwaggerBATService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar string: StringOperations operations - :vartype string: bodystring.operations.StringOperations - :ivar enum: EnumOperations operations - :vartype enum: bodystring.operations.EnumOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.string = StringOperations(self._client, self._config, self._serialize, self._deserialize) - self.enum = EnumOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/_auto_rest_swagger_bat_service.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/_auto_rest_swagger_bat_service.py deleted file mode 100644 index 5660b0d1929..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/_auto_rest_swagger_bat_service.py +++ /dev/null @@ -1,67 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATServiceConfiguration -from .operations import StringOperations -from .operations import EnumOperations -from .. import models - - -class AutoRestSwaggerBATService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar string: StringOperations operations - :vartype string: bodystring.aio.operations.StringOperations - :ivar enum: EnumOperations operations - :vartype enum: bodystring.aio.operations.EnumOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.string = StringOperations(self._client, self._config, self._serialize, self._deserialize) - self.enum = EnumOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py deleted file mode 100644 index e8089c9c970..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py +++ /dev/null @@ -1,311 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class EnumOperations: - """EnumOperations 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: ~bodystring.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 get_not_expandable(self, **kwargs: Any) -> Union[str, "_models.Colors"]: - """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Colors, or the result of cls(response) - :rtype: str or ~bodystring.models.Colors - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_expandable.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore - - @distributed_trace_async - async def put_not_expandable(self, string_body: Union[str, "_models.Colors"], **kwargs: Any) -> None: - """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :param string_body: string body. - :type string_body: str or ~bodystring.models.Colors - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_not_expandable.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore - - @distributed_trace_async - async def get_referenced(self, **kwargs: Any) -> Union[str, "_models.Colors"]: - """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Colors, or the result of cls(response) - :rtype: str or ~bodystring.models.Colors - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_referenced.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore - - @distributed_trace_async - async def put_referenced(self, enum_string_body: Union[str, "_models.Colors"], **kwargs: Any) -> None: - """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :param enum_string_body: enum string body. - :type enum_string_body: str or ~bodystring.models.Colors - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_referenced.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enum_string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore - - @distributed_trace_async - async def get_referenced_constant(self, **kwargs: Any) -> "_models.RefColorConstant": - """Get value 'green-color' from the constant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RefColorConstant, or the result of cls(response) - :rtype: ~bodystring.models.RefColorConstant - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.RefColorConstant"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_referenced_constant.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("RefColorConstant", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore - - @distributed_trace_async - async def put_referenced_constant(self, field1: Optional[str] = None, **kwargs: Any) -> None: - """Sends value 'green-color' from a constant. - - :param field1: Sample string. - :type field1: 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", {})) - - _enum_string_body = _models.RefColorConstant(field1=field1) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_referenced_constant.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_enum_string_body, "RefColorConstant") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py deleted file mode 100644 index 20c23059fcc..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py +++ /dev/null @@ -1,613 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class StringOperations: - """StringOperations 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: ~bodystring.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 get_null(self, **kwargs: Any) -> Optional[str]: - """Get null string value value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str or None, or the result of cls(response) - :rtype: str or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/string/null"} # type: ignore - - @distributed_trace_async - async def put_null(self, string_body: Optional[str] = None, **kwargs: Any) -> None: - """Set string value null. - - :param string_body: string body. - :type string_body: 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/json") - accept = "application/json" - - # Construct URL - url = self.put_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if string_body is not None: - body_content = self._serialize.body(string_body, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_null.metadata = {"url": "/string/null"} # type: ignore - - @distributed_trace_async - async def get_empty(self, **kwargs: Any) -> str: - """Get empty string value value ''. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/string/empty"} # type: ignore - - @distributed_trace_async - async def put_empty(self, **kwargs: Any) -> None: - """Set string value empty ''. - - :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/json") - string_body = "" - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/string/empty"} # type: ignore - - @distributed_trace_async - async def get_mbcs(self, **kwargs: Any) -> str: - """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_mbcs.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore - - @distributed_trace_async - async def put_mbcs(self, **kwargs: Any) -> None: - """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. - - :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/json") - string_body = "啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€" - accept = "application/json" - - # Construct URL - url = self.put_mbcs.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore - - @distributed_trace_async - async def get_whitespace(self, **kwargs: Any) -> str: - """Get string value with leading and trailing whitespace - ':code:``:code:``:code:``Now is the time for all good men to come to the aid - of their country:code:``:code:``:code:``'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_whitespace.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore - - @distributed_trace_async - async def put_whitespace(self, **kwargs: Any) -> None: - """Set String value with leading and trailing whitespace - ':code:``:code:``:code:``Now is the time for all good men to come to the aid - of their country:code:``:code:``:code:``'. - - :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/json") - string_body = " Now is the time for all good men to come to the aid of their country " - accept = "application/json" - - # Construct URL - url = self.put_whitespace.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore - - @distributed_trace_async - async def get_not_provided(self, **kwargs: Any) -> str: - """Get String value when no string value is sent in response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/string/notProvided"} # type: ignore - - @distributed_trace_async - async def get_base64_encoded(self, **kwargs: Any) -> bytearray: - """Get value that is base64 encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_encoded.metadata = {"url": "/string/base64Encoding"} # type: ignore - - @distributed_trace_async - async def get_base64_url_encoded(self, **kwargs: Any) -> bytes: - """Get value that is base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytes, or the result of cls(response) - :rtype: bytes - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytes] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("base64", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore - - @distributed_trace_async - async def put_base64_url_encoded(self, string_body: bytes, **kwargs: Any) -> None: - """Put value that is base64url encoded. - - :param string_body: string body. - :type string_body: bytes - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_base64_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "base64") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore - - @distributed_trace_async - async def get_null_base64_url_encoded(self, **kwargs: Any) -> Optional[bytes]: - """Get null value that is expected to be base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytes or None, or the result of cls(response) - :rtype: bytes or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_base64_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("base64", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_base64_url_encoded.metadata = {"url": "/string/nullBase64UrlEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py deleted file mode 100644 index 68c9e50626d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py +++ /dev/null @@ -1,339 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class EnumOperations(object): - """EnumOperations 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: ~bodystring.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 get_not_expandable( - self, **kwargs # type: Any - ): - # type: (...) -> Union[str, "_models.Colors"] - """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Colors, or the result of cls(response) - :rtype: str or ~bodystring.models.Colors - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_expandable.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore - - @distributed_trace - def put_not_expandable( - self, - string_body, # type: Union[str, "_models.Colors"] - **kwargs # type: Any - ): - # type: (...) -> None - """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :param string_body: string body. - :type string_body: str or ~bodystring.models.Colors - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_not_expandable.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore - - @distributed_trace - def get_referenced( - self, **kwargs # type: Any - ): - # type: (...) -> Union[str, "_models.Colors"] - """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Colors, or the result of cls(response) - :rtype: str or ~bodystring.models.Colors - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_referenced.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore - - @distributed_trace - def put_referenced( - self, - enum_string_body, # type: Union[str, "_models.Colors"] - **kwargs # type: Any - ): - # type: (...) -> None - """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. - - :param enum_string_body: enum string body. - :type enum_string_body: str or ~bodystring.models.Colors - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_referenced.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enum_string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore - - @distributed_trace - def get_referenced_constant( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.RefColorConstant" - """Get value 'green-color' from the constant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RefColorConstant, or the result of cls(response) - :rtype: ~bodystring.models.RefColorConstant - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.RefColorConstant"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_referenced_constant.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("RefColorConstant", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore - - @distributed_trace - def put_referenced_constant( - self, - field1=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Sends value 'green-color' from a constant. - - :param field1: Sample string. - :type field1: 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", {})) - - _enum_string_body = _models.RefColorConstant(field1=field1) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_referenced_constant.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_enum_string_body, "RefColorConstant") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py deleted file mode 100644 index d8d3517d831..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py +++ /dev/null @@ -1,660 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class StringOperations(object): - """StringOperations 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: ~bodystring.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 get_null( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[str] - """Get null string value value. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str or None, or the result of cls(response) - :rtype: str or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null.metadata = {"url": "/string/null"} # type: ignore - - @distributed_trace - def put_null( - self, - string_body=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Set string value null. - - :param string_body: string body. - :type string_body: 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/json") - accept = "application/json" - - # Construct URL - url = self.put_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if string_body is not None: - body_content = self._serialize.body(string_body, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_null.metadata = {"url": "/string/null"} # type: ignore - - @distributed_trace - def get_empty( - self, **kwargs # type: Any - ): - # type: (...) -> str - """Get empty string value value ''. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty.metadata = {"url": "/string/empty"} # type: ignore - - @distributed_trace - def put_empty( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Set string value empty ''. - - :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/json") - string_body = "" - accept = "application/json" - - # Construct URL - url = self.put_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty.metadata = {"url": "/string/empty"} # type: ignore - - @distributed_trace - def get_mbcs( - self, **kwargs # type: Any - ): - # type: (...) -> str - """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_mbcs.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore - - @distributed_trace - def put_mbcs( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. - - :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/json") - string_body = "啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€" - accept = "application/json" - - # Construct URL - url = self.put_mbcs.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore - - @distributed_trace - def get_whitespace( - self, **kwargs # type: Any - ): - # type: (...) -> str - """Get string value with leading and trailing whitespace - ':code:``:code:``:code:``Now is the time for all good men to come to the aid - of their country:code:``:code:``:code:``'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_whitespace.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore - - @distributed_trace - def put_whitespace( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Set String value with leading and trailing whitespace - ':code:``:code:``:code:``Now is the time for all good men to come to the aid - of their country:code:``:code:``:code:``'. - - :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/json") - string_body = " Now is the time for all good men to come to the aid of their country " - accept = "application/json" - - # Construct URL - url = self.put_whitespace.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "str") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore - - @distributed_trace - def get_not_provided( - self, **kwargs # type: Any - ): - # type: (...) -> str - """Get String value when no string value is sent in response payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_not_provided.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_not_provided.metadata = {"url": "/string/notProvided"} # type: ignore - - @distributed_trace - def get_base64_encoded( - self, **kwargs # type: Any - ): - # type: (...) -> bytearray - """Get value that is base64 encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytearray, or the result of cls(response) - :rtype: bytearray - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytearray] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bytearray", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_encoded.metadata = {"url": "/string/base64Encoding"} # type: ignore - - @distributed_trace - def get_base64_url_encoded( - self, **kwargs # type: Any - ): - # type: (...) -> bytes - """Get value that is base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytes, or the result of cls(response) - :rtype: bytes - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bytes] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_base64_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("base64", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore - - @distributed_trace - def put_base64_url_encoded( - self, - string_body, # type: bytes - **kwargs # type: Any - ): - # type: (...) -> None - """Put value that is base64url encoded. - - :param string_body: string body. - :type string_body: bytes - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_base64_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(string_body, "base64") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore - - @distributed_trace - def get_null_base64_url_encoded( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[bytes] - """Get null value that is expected to be base64url encoded. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytes or None, or the result of cls(response) - :rtype: bytes or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[bytes]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_null_base64_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("base64", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_null_base64_url_encoded.metadata = {"url": "/string/nullBase64UrlEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyString/setup.py deleted file mode 100644 index 6f65e52812e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_auto_rest_time_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_auto_rest_time_test_service.py deleted file mode 100644 index 19ba02d6960..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_auto_rest_time_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestTimeTestServiceConfiguration -from .operations import TimeOperations -from . import models - - -class AutoRestTimeTestService(object): - """Test Infrastructure for AutoRest. - - :ivar time: TimeOperations operations - :vartype time: bodytime.operations.TimeOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestTimeTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.time = TimeOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestTimeTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/_auto_rest_time_test_service.py b/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/_auto_rest_time_test_service.py deleted file mode 100644 index 9bac277c6df..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/_auto_rest_time_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestTimeTestServiceConfiguration -from .operations import TimeOperations -from .. import models - - -class AutoRestTimeTestService(object): - """Test Infrastructure for AutoRest. - - :ivar time: TimeOperations operations - :vartype time: bodytime.aio.operations.TimeOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestTimeTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.time = TimeOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestTimeTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py deleted file mode 100644 index 21061c0fd6b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py +++ /dev/null @@ -1,140 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TimeOperations: - """TimeOperations 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: ~bodytime.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 get(self, **kwargs: Any) -> datetime.time: - """Get time value "11:34:56". - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: time, or the result of cls(response) - :rtype: ~datetime.time - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.time] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/time/get"} # type: ignore - - @distributed_trace_async - async def put(self, time_body: datetime.time, **kwargs: Any) -> str: - """Put time value "08:07:56". - - :param time_body: Put time value "08:07:56" in parameter to pass testserver. - :type time_body: ~datetime.time - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(time_body, "time") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/time/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py deleted file mode 100644 index bd31089e76e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class TimeOperations(object): - """TimeOperations 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: ~bodytime.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 get( - self, **kwargs # type: Any - ): - # type: (...) -> datetime.time - """Get time value "11:34:56". - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: time, or the result of cls(response) - :rtype: ~datetime.time - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[datetime.time] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("time", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/time/get"} # type: ignore - - @distributed_trace - def put( - self, - time_body, # type: datetime.time - **kwargs # type: Any - ): - # type: (...) -> str - """Put time value "08:07:56". - - :param time_body: Put time value "08:07:56" in parameter to pass testserver. - :type time_body: ~datetime.time - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(time_body, "time") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/time/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/setup.py b/test/vanilla/Expected/AcceptanceTests/BodyTime/setup.py deleted file mode 100644 index 3be6a0a2392..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/BodyTime/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autoresttimetestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestTimeTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestTimeTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/_auto_rest_swagger_constant_service.py b/test/vanilla/Expected/AcceptanceTests/Constants/constants/_auto_rest_swagger_constant_service.py deleted file mode 100644 index 21870b4cd99..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Constants/constants/_auto_rest_swagger_constant_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerConstantServiceConfiguration -from .operations import ContantsOperations -from . import models - - -class AutoRestSwaggerConstantService(object): - """Test Infrastructure for AutoRest Swagger Constant. - - :ivar contants: ContantsOperations operations - :vartype contants: constants.operations.ContantsOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerConstantServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.contants = ContantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerConstantService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/_auto_rest_swagger_constant_service.py b/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/_auto_rest_swagger_constant_service.py deleted file mode 100644 index 235923dc5fe..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/_auto_rest_swagger_constant_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerConstantServiceConfiguration -from .operations import ContantsOperations -from .. import models - - -class AutoRestSwaggerConstantService(object): - """Test Infrastructure for AutoRest Swagger Constant. - - :ivar contants: ContantsOperations operations - :vartype contants: constants.aio.operations.ContantsOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerConstantServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.contants = ContantsOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerConstantService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py b/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py deleted file mode 100644 index 3968107b44f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py +++ /dev/null @@ -1,734 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ContantsOperations: - """ContantsOperations 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: ~constants.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 put_no_model_as_string_no_required_two_value_no_default( - self, - input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, - **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_no_required_two_value_default( - self, - input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", - **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_no_required_one_value_no_default( - self, input: Optional[str] = "value1", **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: 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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_no_required_one_value_default( - self, input: Optional[str] = "value1", **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: 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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_required_two_value_no_default( - self, input: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_required_two_value_default( - self, input: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_required_one_value_no_default(self, **kwargs: Any) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :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", {})) - input = "value1" - - # Construct URL - url = self.put_no_model_as_string_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_no_model_as_string_required_one_value_default(self, **kwargs: Any) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :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", {})) - input = "value1" - - # Construct URL - url = self.put_no_model_as_string_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_no_required_two_value_no_default( - self, - input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, - **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_no_required_two_value_default( - self, - input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", - **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_no_required_one_value_no_default( - self, - input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] = None, - **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_no_required_one_value_default( - self, - input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] = "value1", - **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_required_two_value_no_default( - self, input: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_required_two_value_default( - self, input: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_two_value_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_required_one_value_no_default( - self, input: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"], **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredOneValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace_async - async def put_model_as_string_required_one_value_default( - self, input: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] = "value1", **kwargs: Any - ) -> None: - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredOneValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_one_value_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueDefault"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py b/test/vanilla/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py deleted file mode 100644 index 3e48bd58e4a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py +++ /dev/null @@ -1,774 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class ContantsOperations(object): - """ContantsOperations 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: ~constants.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 put_no_model_as_string_no_required_two_value_no_default( - self, - input=None, # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_no_required_two_value_default( - self, - input="value1", # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_no_required_one_value_no_default( - self, - input="value1", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: 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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_no_required_one_value_default( - self, - input="value1", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: 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", {})) - - # Construct URL - url = self.put_no_model_as_string_no_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_required_two_value_no_default( - self, - input, # type: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_required_two_value_default( - self, - input="value1", # type: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_no_model_as_string_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_required_one_value_no_default( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :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", {})) - input = "value1" - - # Construct URL - url = self.put_no_model_as_string_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace - def put_no_model_as_string_required_one_value_default( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :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", {})) - input = "value1" - - # Construct URL - url = self.put_no_model_as_string_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_no_model_as_string_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_no_required_two_value_no_default( - self, - input=None, # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_no_required_two_value_default( - self, - input="value1", # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_no_required_one_value_no_default( - self, - input=None, # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_no_required_one_value_default( - self, - input="value1", # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_no_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if input is not None: - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_required_two_value_no_default( - self, - input, # type: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_two_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueNoDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_required_two_value_default( - self, - input="value1", # type: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredTwoValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_two_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_two_value_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_required_one_value_no_default( - self, - input, # type: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredOneValueNoDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_one_value_no_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueNoDefault"} # type: ignore - - @distributed_trace - def put_model_as_string_required_one_value_default( - self, - input="value1", # type: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts constants to the testserver. - - Puts constants to the testserver. - - :param input: - :type input: str or ~constants.models.ModelAsStringRequiredOneValueDefaultOpEnum - :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", {})) - - # Construct URL - url = self.put_model_as_string_required_one_value_default.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["input"] = self._serialize.query("input", input, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_model_as_string_required_one_value_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueDefault"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/setup.py b/test/vanilla/Expected/AcceptanceTests/Constants/setup.py deleted file mode 100644 index dedd16b32ff..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Constants/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerconstantservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerConstantService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerConstantService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger Constant. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py deleted file mode 100644 index 8a3070ec02e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py +++ /dev/null @@ -1,79 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestParameterizedHostTestClientConfiguration -from .operations import PathsOperations -from . import models - - -class AutoRestParameterizedHostTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: custombaseurl.operations.PathsOperations - :param host: A string value that is used as a global part of the parameterized host. - :type host: str - """ - - def __init__( - self, - host="host", # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = "http://{accountName}{host}" - self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestParameterizedHostTestClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py deleted file mode 100644 index b0badaad24f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py +++ /dev/null @@ -1,65 +0,0 @@ -# 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 import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestParameterizedHostTestClientConfiguration -from .operations import PathsOperations -from .. import models - - -class AutoRestParameterizedHostTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: custombaseurl.aio.operations.PathsOperations - :param host: A string value that is used as a global part of the parameterized host. - :type host: str - """ - - def __init__(self, host: str = "host", **kwargs: Any) -> None: - base_url = "http://{accountName}{host}" - self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestParameterizedHostTestClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py deleted file mode 100644 index 8d9a7bf9f65..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py +++ /dev/null @@ -1,93 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PathsOperations: - """PathsOperations 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: ~custombaseurl.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 get_empty(self, account_name: str, **kwargs: Any) -> None: - """Get a 200 to test a valid base uri. - - :param account_name: Account Name. - :type account_name: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py deleted file mode 100644 index 227cbbdefcc..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py +++ /dev/null @@ -1,102 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PathsOperations(object): - """PathsOperations 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: ~custombaseurl.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 get_empty( - self, - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a 200 to test a valid base uri. - - :param account_name: Account Name. - :type account_name: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - path_format_arguments = { - "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), - "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/setup.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/setup.py deleted file mode 100644 index b41dddbf059..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestparameterizedhosttestclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestParameterizedHostTestClient", - author_email="", - url="", - keywords=["Swagger", "AutoRestParameterizedHostTestClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_auto_rest_parameterized_custom_host_test_client.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_auto_rest_parameterized_custom_host_test_client.py deleted file mode 100644 index 23707487597..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_auto_rest_parameterized_custom_host_test_client.py +++ /dev/null @@ -1,86 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestParameterizedCustomHostTestClientConfiguration -from .operations import PathsOperations -from . import models - - -class AutoRestParameterizedCustomHostTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: custombaseurlmoreoptions.operations.PathsOperations - :param subscription_id: The subscription id with value 'test12'. - :type subscription_id: str - :param dns_suffix: A string value that is used as a global part of the parameterized host. Default value 'host'. - :type dns_suffix: str - """ - - def __init__( - self, - subscription_id, # type: str - dns_suffix="host", # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = "{vault}{secret}{dnsSuffix}" - self._config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, **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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "dnsSuffix": self._serialize.url( - "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True - ), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestParameterizedCustomHostTestClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_auto_rest_parameterized_custom_host_test_client.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_auto_rest_parameterized_custom_host_test_client.py deleted file mode 100644 index 01d17063fe1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_auto_rest_parameterized_custom_host_test_client.py +++ /dev/null @@ -1,71 +0,0 @@ -# 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 import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestParameterizedCustomHostTestClientConfiguration -from .operations import PathsOperations -from .. import models - - -class AutoRestParameterizedCustomHostTestClient(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: custombaseurlmoreoptions.aio.operations.PathsOperations - :param subscription_id: The subscription id with value 'test12'. - :type subscription_id: str - :param dns_suffix: A string value that is used as a global part of the parameterized host. Default value 'host'. - :type dns_suffix: str - """ - - def __init__(self, subscription_id: str, dns_suffix: str = "host", **kwargs: Any) -> None: - base_url = "{vault}{secret}{dnsSuffix}" - self._config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, **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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "dnsSuffix": self._serialize.url( - "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True - ), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestParameterizedCustomHostTestClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py deleted file mode 100644 index e0323b5afe4..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py +++ /dev/null @@ -1,108 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PathsOperations: - """PathsOperations 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: ~custombaseurlmoreoptions.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 get_empty( - self, vault: str, secret: str, key_name: str, key_version: Optional[str] = "v1", **kwargs: Any - ) -> None: - """Get a 200 to test a valid base uri. - - :param vault: The vault name, e.g. https://myvault. - :type vault: str - :param secret: Secret value. - :type secret: str - :param key_name: The key name with value 'key1'. - :type key_name: str - :param key_version: The key version. Default value 'v1'. - :type key_version: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - path_format_arguments = { - "vault": self._serialize.url("vault", vault, "str", skip_quote=True), - "secret": self._serialize.url("secret", secret, "str", skip_quote=True), - "dnsSuffix": self._serialize.url( - "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True - ), - "keyName": self._serialize.url("key_name", key_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if key_version is not None: - query_parameters["keyVersion"] = self._serialize.query("key_version", key_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_empty.metadata = {"url": "/customuri/{subscriptionId}/{keyName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py deleted file mode 100644 index 38133641e09..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py +++ /dev/null @@ -1,118 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PathsOperations(object): - """PathsOperations 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: ~custombaseurlmoreoptions.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 get_empty( - self, - vault, # type: str - secret, # type: str - key_name, # type: str - key_version="v1", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Get a 200 to test a valid base uri. - - :param vault: The vault name, e.g. https://myvault. - :type vault: str - :param secret: Secret value. - :type secret: str - :param key_name: The key name with value 'key1'. - :type key_name: str - :param key_version: The key version. Default value 'v1'. - :type key_version: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty.metadata["url"] # type: ignore - path_format_arguments = { - "vault": self._serialize.url("vault", vault, "str", skip_quote=True), - "secret": self._serialize.url("secret", secret, "str", skip_quote=True), - "dnsSuffix": self._serialize.url( - "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True - ), - "keyName": self._serialize.url("key_name", key_name, "str"), - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if key_version is not None: - query_parameters["keyVersion"] = self._serialize.query("key_version", key_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_empty.metadata = {"url": "/customuri/{subscriptionId}/{keyName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py b/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py deleted file mode 100644 index d743f6dfe21..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestparameterizedcustomhosttestclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestParameterizedCustomHostTestClient", - author_email="", - url="", - keywords=["Swagger", "AutoRestParameterizedCustomHostTestClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_pet_store_inc.py b/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_pet_store_inc.py deleted file mode 100644 index e190d7e08d7..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_pet_store_inc.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PetStoreIncConfiguration -from .operations import PetOperations -from . import models - - -class PetStoreInc(object): - """PetStore. - - :ivar pet: PetOperations operations - :vartype pet: extensibleenumsswagger.operations.PetOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = PetStoreIncConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.pet = PetOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> PetStoreInc - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_pet_store_inc.py b/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_pet_store_inc.py deleted file mode 100644 index 5542f99ffa5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_pet_store_inc.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import PetStoreIncConfiguration -from .operations import PetOperations -from .. import models - - -class PetStoreInc(object): - """PetStore. - - :ivar pet: PetOperations operations - :vartype pet: extensibleenumsswagger.aio.operations.PetOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = PetStoreIncConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.pet = PetOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "PetStoreInc": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py b/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py deleted file mode 100644 index 0101b92c0f5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py +++ /dev/null @@ -1,146 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PetOperations: - """PetOperations 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: ~extensibleenumsswagger.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 get_by_pet_id(self, pet_id: str, **kwargs: Any) -> "_models.Pet": - """get pet by id. - - :param pet_id: Pet id. - :type pet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~extensibleenumsswagger.models.Pet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_by_pet_id.metadata["url"] # type: ignore - path_format_arguments = { - "petId": self._serialize.url("pet_id", pet_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_pet_id.metadata = {"url": "/extensibleenums/pet/{petId}"} # type: ignore - - @distributed_trace_async - async def add_pet(self, pet_param: Optional["_models.Pet"] = None, **kwargs: Any) -> "_models.Pet": - """add pet. - - :param pet_param: pet param. - :type pet_param: ~extensibleenumsswagger.models.Pet - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~extensibleenumsswagger.models.Pet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add_pet.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if pet_param is not None: - body_content = self._serialize.body(pet_param, "Pet") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - add_pet.metadata = {"url": "/extensibleenums/pet/addPet"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py b/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py deleted file mode 100644 index 1f7529ca80f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PetOperations(object): - """PetOperations 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: ~extensibleenumsswagger.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 get_by_pet_id( - self, - pet_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Pet" - """get pet by id. - - :param pet_id: Pet id. - :type pet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~extensibleenumsswagger.models.Pet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_by_pet_id.metadata["url"] # type: ignore - path_format_arguments = { - "petId": self._serialize.url("pet_id", pet_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_pet_id.metadata = {"url": "/extensibleenums/pet/{petId}"} # type: ignore - - @distributed_trace - def add_pet( - self, - pet_param=None, # type: Optional["_models.Pet"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Pet" - """add pet. - - :param pet_param: pet param. - :type pet_param: ~extensibleenumsswagger.models.Pet - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~extensibleenumsswagger.models.Pet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add_pet.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if pet_param is not None: - body_content = self._serialize.body(pet_param, "Pet") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - add_pet.metadata = {"url": "/extensibleenums/pet/addPet"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/setup.py b/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/setup.py deleted file mode 100644 index f51e9d461f4..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "petstoreinc" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="PetStoreInc", - author_email="", - url="", - keywords=["Swagger", "PetStoreInc"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - PetStore. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/_auto_rest_swagger_bat_header_service.py b/test/vanilla/Expected/AcceptanceTests/Header/header/_auto_rest_swagger_bat_header_service.py deleted file mode 100644 index 044c5671d79..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Header/header/_auto_rest_swagger_bat_header_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATHeaderServiceConfiguration -from .operations import HeaderOperations -from . import models - - -class AutoRestSwaggerBATHeaderService(object): - """Test Infrastructure for AutoRest. - - :ivar header: HeaderOperations operations - :vartype header: header.operations.HeaderOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATHeaderServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.header = HeaderOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATHeaderService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/_auto_rest_swagger_bat_header_service.py b/test/vanilla/Expected/AcceptanceTests/Header/header/aio/_auto_rest_swagger_bat_header_service.py deleted file mode 100644 index 8e36c441d70..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/_auto_rest_swagger_bat_header_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATHeaderServiceConfiguration -from .operations import HeaderOperations -from .. import models - - -class AutoRestSwaggerBATHeaderService(object): - """Test Infrastructure for AutoRest. - - :ivar header: HeaderOperations operations - :vartype header: header.aio.operations.HeaderOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATHeaderServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.header = HeaderOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATHeaderService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py b/test/vanilla/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py deleted file mode 100644 index 2a7fc4058e9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py +++ /dev/null @@ -1,1333 +0,0 @@ -# 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 datetime -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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HeaderOperations: - """HeaderOperations 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: ~header.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 param_existing_key(self, user_agent_parameter: str, **kwargs: Any) -> None: - """Send a post request with header value "User-Agent": "overwrite". - - :param user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". - :type user_agent_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_existing_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["User-Agent"] = self._serialize.header("user_agent_parameter", user_agent_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_existing_key.metadata = {"url": "/header/param/existingkey"} # type: ignore - - @distributed_trace_async - async def response_existing_key(self, **kwargs: Any) -> None: - """Get a response with header value "User-Agent": "overwrite". - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.response_existing_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["User-Agent"] = self._deserialize("str", response.headers.get("User-Agent")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_existing_key.metadata = {"url": "/header/response/existingkey"} # type: ignore - - @distributed_trace_async - async def param_protected_key(self, content_type: str, **kwargs: Any) -> None: - """Send a post request with header value "Content-Type": "text/html". - - :param content_type: Send a post request with header value "Content-Type": "text/html". - :type content_type: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_protected_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_protected_key.metadata = {"url": "/header/param/protectedkey"} # type: ignore - - @distributed_trace_async - async def response_protected_key(self, **kwargs: Any) -> None: - """Get a response with header value "Content-Type": "text/html". - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.response_protected_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_protected_key.metadata = {"url": "/header/response/protectedkey"} # type: ignore - - @distributed_trace_async - async def param_integer(self, scenario: str, value: int, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": - "negative", "value": -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 1 or -2. - :type value: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_integer.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_integer.metadata = {"url": "/header/param/prim/integer"} # type: ignore - - @distributed_trace_async - async def response_integer(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header value "value": 1 or -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_integer.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("int", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_integer.metadata = {"url": "/header/response/prim/integer"} # type: ignore - - @distributed_trace_async - async def param_long(self, scenario: str, value: int, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": - "negative", "value": -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 105 or -2. - :type value: long - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "long") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_long.metadata = {"url": "/header/param/prim/long"} # type: ignore - - @distributed_trace_async - async def response_long(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header value "value": 105 or -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("long", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_long.metadata = {"url": "/header/response/prim/long"} # type: ignore - - @distributed_trace_async - async def param_float(self, scenario: str, value: float, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": - "negative", "value": -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 0.07 or -3.0. - :type value: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "float") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_float.metadata = {"url": "/header/param/prim/float"} # type: ignore - - @distributed_trace_async - async def response_float(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header value "value": 0.07 or -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("float", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_float.metadata = {"url": "/header/response/prim/float"} # type: ignore - - @distributed_trace_async - async def param_double(self, scenario: str, value: float, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": - "negative", "value": -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 7e120 or -3.0. - :type value: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "float") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_double.metadata = {"url": "/header/param/prim/double"} # type: ignore - - @distributed_trace_async - async def response_double(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header value "value": 7e120 or -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("float", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_double.metadata = {"url": "/header/response/prim/double"} # type: ignore - - @distributed_trace_async - async def param_bool(self, scenario: str, value: bool, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "true", "value": true or "scenario": - "false", "value": false. - - :param scenario: Send a post request with header values "scenario": "true" or "false". - :type scenario: str - :param value: Send a post request with header values true or false. - :type value: bool - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "bool") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_bool.metadata = {"url": "/header/param/prim/bool"} # type: ignore - - @distributed_trace_async - async def response_bool(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header value "value": true or false. - - :param scenario: Send a post request with header values "scenario": "true" or "false". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("bool", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_bool.metadata = {"url": "/header/response/prim/bool"} # type: ignore - - @distributed_trace_async - async def param_string(self, scenario: str, value: Optional[str] = None, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps - over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: str - :param value: Send a post request with header values "The quick brown fox jumps over the lazy - dog" or null or "". - :type value: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - if value is not None: - header_parameters["value"] = self._serialize.header("value", value, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_string.metadata = {"url": "/header/param/prim/string"} # type: ignore - - @distributed_trace_async - async def response_string(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("str", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_string.metadata = {"url": "/header/response/prim/string"} # type: ignore - - @distributed_trace_async - async def param_date(self, scenario: str, value: datetime.date, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or - "scenario": "min", "value": "0001-01-01". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: str - :param value: Send a post request with header values "2010-01-01" or "0001-01-01". - :type value: ~datetime.date - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "date") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_date.metadata = {"url": "/header/param/prim/date"} # type: ignore - - @distributed_trace_async - async def response_date(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "2010-01-01" or "0001-01-01". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("date", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_date.metadata = {"url": "/header/response/prim/date"} # type: ignore - - @distributed_trace_async - async def param_datetime(self, scenario: str, value: datetime.datetime, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or - "scenario": "min", "value": "0001-01-01T00:00:00Z". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: str - :param value: Send a post request with header values "2010-01-01T12:34:56Z" or - "0001-01-01T00:00:00Z". - :type value: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_datetime.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "iso-8601") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_datetime.metadata = {"url": "/header/param/prim/datetime"} # type: ignore - - @distributed_trace_async - async def response_datetime(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_datetime.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("iso-8601", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_datetime.metadata = {"url": "/header/response/prim/datetime"} # type: ignore - - @distributed_trace_async - async def param_datetime_rfc1123( - self, scenario: str, value: Optional[datetime.datetime] = None, **kwargs: Any - ) -> None: - """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 - GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: str - :param value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, - 01 Jan 0001 00:00:00 GMT". - :type value: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_datetime_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - if value is not None: - header_parameters["value"] = self._serialize.header("value", value, "rfc-1123") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_datetime_rfc1123.metadata = {"url": "/header/param/prim/datetimerfc1123"} # type: ignore - - @distributed_trace_async - async def response_datetime_rfc1123(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 - GMT". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_datetime_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("rfc-1123", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_datetime_rfc1123.metadata = {"url": "/header/response/prim/datetimerfc1123"} # type: ignore - - @distributed_trace_async - async def param_duration(self, scenario: str, value: datetime.timedelta, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: str - :param value: Send a post request with header values "P123DT22H14M12.011S". - :type value: ~datetime.timedelta - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "duration") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_duration.metadata = {"url": "/header/param/prim/duration"} # type: ignore - - @distributed_trace_async - async def response_duration(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "P123DT22H14M12.011S". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("duration", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_duration.metadata = {"url": "/header/response/prim/duration"} # type: ignore - - @distributed_trace_async - async def param_byte(self, scenario: str, value: bytearray, **kwargs: Any) -> None: - """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: str - :param value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". - :type value: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "bytearray") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_byte.metadata = {"url": "/header/param/prim/byte"} # type: ignore - - @distributed_trace_async - async def response_byte(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("bytearray", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_byte.metadata = {"url": "/header/response/prim/byte"} # type: ignore - - @distributed_trace_async - async def param_enum( - self, scenario: str, value: Optional[Union[str, "_models.GreyscaleColors"]] = None, **kwargs: Any - ) -> None: - """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": - "null", "value": null. - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: str - :param value: Send a post request with header values 'GREY'. - :type value: str or ~header.models.GreyscaleColors - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_enum.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - if value is not None: - header_parameters["value"] = self._serialize.header("value", value, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_enum.metadata = {"url": "/header/param/prim/enum"} # type: ignore - - @distributed_trace_async - async def response_enum(self, scenario: str, **kwargs: Any) -> None: - """Get a response with header values "GREY" or null. - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_enum.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("str", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_enum.metadata = {"url": "/header/response/prim/enum"} # type: ignore - - @distributed_trace_async - async def custom_request_id(self, **kwargs: Any) -> None: - """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the - request. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.custom_request_id.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - custom_request_id.metadata = {"url": "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/operations/_header_operations.py b/test/vanilla/Expected/AcceptanceTests/Header/header/operations/_header_operations.py deleted file mode 100644 index 0620ce54f23..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Header/header/operations/_header_operations.py +++ /dev/null @@ -1,1484 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class HeaderOperations(object): - """HeaderOperations 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: ~header.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 param_existing_key( - self, - user_agent_parameter, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header value "User-Agent": "overwrite". - - :param user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". - :type user_agent_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_existing_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["User-Agent"] = self._serialize.header("user_agent_parameter", user_agent_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_existing_key.metadata = {"url": "/header/param/existingkey"} # type: ignore - - @distributed_trace - def response_existing_key( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "User-Agent": "overwrite". - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.response_existing_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["User-Agent"] = self._deserialize("str", response.headers.get("User-Agent")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_existing_key.metadata = {"url": "/header/response/existingkey"} # type: ignore - - @distributed_trace - def param_protected_key( - self, - content_type, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header value "Content-Type": "text/html". - - :param content_type: Send a post request with header value "Content-Type": "text/html". - :type content_type: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_protected_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_protected_key.metadata = {"url": "/header/param/protectedkey"} # type: ignore - - @distributed_trace - def response_protected_key( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "Content-Type": "text/html". - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.response_protected_key.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_protected_key.metadata = {"url": "/header/response/protectedkey"} # type: ignore - - @distributed_trace - def param_integer( - self, - scenario, # type: str - value, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": - "negative", "value": -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 1 or -2. - :type value: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_integer.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_integer.metadata = {"url": "/header/param/prim/integer"} # type: ignore - - @distributed_trace - def response_integer( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "value": 1 or -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_integer.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("int", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_integer.metadata = {"url": "/header/response/prim/integer"} # type: ignore - - @distributed_trace - def param_long( - self, - scenario, # type: str - value, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": - "negative", "value": -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 105 or -2. - :type value: long - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "long") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_long.metadata = {"url": "/header/param/prim/long"} # type: ignore - - @distributed_trace - def response_long( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "value": 105 or -2. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_long.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("long", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_long.metadata = {"url": "/header/response/prim/long"} # type: ignore - - @distributed_trace - def param_float( - self, - scenario, # type: str - value, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": - "negative", "value": -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 0.07 or -3.0. - :type value: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "float") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_float.metadata = {"url": "/header/param/prim/float"} # type: ignore - - @distributed_trace - def response_float( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "value": 0.07 or -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_float.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("float", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_float.metadata = {"url": "/header/response/prim/float"} # type: ignore - - @distributed_trace - def param_double( - self, - scenario, # type: str - value, # type: float - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": - "negative", "value": -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: str - :param value: Send a post request with header values 7e120 or -3.0. - :type value: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "float") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_double.metadata = {"url": "/header/param/prim/double"} # type: ignore - - @distributed_trace - def response_double( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "value": 7e120 or -3.0. - - :param scenario: Send a post request with header values "scenario": "positive" or "negative". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_double.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("float", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_double.metadata = {"url": "/header/response/prim/double"} # type: ignore - - @distributed_trace - def param_bool( - self, - scenario, # type: str - value, # type: bool - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "true", "value": true or "scenario": - "false", "value": false. - - :param scenario: Send a post request with header values "scenario": "true" or "false". - :type scenario: str - :param value: Send a post request with header values true or false. - :type value: bool - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "bool") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_bool.metadata = {"url": "/header/param/prim/bool"} # type: ignore - - @distributed_trace - def response_bool( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header value "value": true or false. - - :param scenario: Send a post request with header values "scenario": "true" or "false". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_bool.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("bool", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_bool.metadata = {"url": "/header/response/prim/bool"} # type: ignore - - @distributed_trace - def param_string( - self, - scenario, # type: str - value=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps - over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: str - :param value: Send a post request with header values "The quick brown fox jumps over the lazy - dog" or null or "". - :type value: 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", {})) - accept = "application/json" - - # Construct URL - url = self.param_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - if value is not None: - header_parameters["value"] = self._serialize.header("value", value, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_string.metadata = {"url": "/header/param/prim/string"} # type: ignore - - @distributed_trace - def response_string( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_string.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("str", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_string.metadata = {"url": "/header/response/prim/string"} # type: ignore - - @distributed_trace - def param_date( - self, - scenario, # type: str - value, # type: datetime.date - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or - "scenario": "min", "value": "0001-01-01". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: str - :param value: Send a post request with header values "2010-01-01" or "0001-01-01". - :type value: ~datetime.date - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "date") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_date.metadata = {"url": "/header/param/prim/date"} # type: ignore - - @distributed_trace - def response_date( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "2010-01-01" or "0001-01-01". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_date.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("date", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_date.metadata = {"url": "/header/response/prim/date"} # type: ignore - - @distributed_trace - def param_datetime( - self, - scenario, # type: str - value, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or - "scenario": "min", "value": "0001-01-01T00:00:00Z". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: str - :param value: Send a post request with header values "2010-01-01T12:34:56Z" or - "0001-01-01T00:00:00Z". - :type value: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_datetime.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "iso-8601") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_datetime.metadata = {"url": "/header/param/prim/datetime"} # type: ignore - - @distributed_trace - def response_datetime( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_datetime.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("iso-8601", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_datetime.metadata = {"url": "/header/response/prim/datetime"} # type: ignore - - @distributed_trace - def param_datetime_rfc1123( - self, - scenario, # type: str - value=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 - GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: str - :param value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, - 01 Jan 0001 00:00:00 GMT". - :type value: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_datetime_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - if value is not None: - header_parameters["value"] = self._serialize.header("value", value, "rfc-1123") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_datetime_rfc1123.metadata = {"url": "/header/param/prim/datetimerfc1123"} # type: ignore - - @distributed_trace - def response_datetime_rfc1123( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 - GMT". - - :param scenario: Send a post request with header values "scenario": "valid" or "min". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_datetime_rfc1123.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("rfc-1123", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_datetime_rfc1123.metadata = {"url": "/header/response/prim/datetimerfc1123"} # type: ignore - - @distributed_trace - def param_duration( - self, - scenario, # type: str - value, # type: datetime.timedelta - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: str - :param value: Send a post request with header values "P123DT22H14M12.011S". - :type value: ~datetime.timedelta - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "duration") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_duration.metadata = {"url": "/header/param/prim/duration"} # type: ignore - - @distributed_trace - def response_duration( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "P123DT22H14M12.011S". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_duration.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("duration", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_duration.metadata = {"url": "/header/response/prim/duration"} # type: ignore - - @distributed_trace - def param_byte( - self, - scenario, # type: str - value, # type: bytearray - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: str - :param value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". - :type value: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["value"] = self._serialize.header("value", value, "bytearray") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_byte.metadata = {"url": "/header/param/prim/byte"} # type: ignore - - @distributed_trace - def response_byte( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". - - :param scenario: Send a post request with header values "scenario": "valid". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("bytearray", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_byte.metadata = {"url": "/header/response/prim/byte"} # type: ignore - - @distributed_trace - def param_enum( - self, - scenario, # type: str - value=None, # type: Optional[Union[str, "_models.GreyscaleColors"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": - "null", "value": null. - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: str - :param value: Send a post request with header values 'GREY'. - :type value: str or ~header.models.GreyscaleColors - :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", {})) - accept = "application/json" - - # Construct URL - url = self.param_enum.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - if value is not None: - header_parameters["value"] = self._serialize.header("value", value, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - param_enum.metadata = {"url": "/header/param/prim/enum"} # type: ignore - - @distributed_trace - def response_enum( - self, - scenario, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get a response with header values "GREY" or null. - - :param scenario: Send a post request with header values "scenario": "valid" or "null" or - "empty". - :type scenario: 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", {})) - accept = "application/json" - - # Construct URL - url = self.response_enum.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["scenario"] = self._serialize.header("scenario", scenario, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["value"] = self._deserialize("str", response.headers.get("value")) - - if cls: - return cls(pipeline_response, None, response_headers) - - response_enum.metadata = {"url": "/header/response/prim/enum"} # type: ignore - - @distributed_trace - def custom_request_id( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the - request. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.custom_request_id.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - custom_request_id.metadata = {"url": "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Header/setup.py b/test/vanilla/Expected/AcceptanceTests/Header/setup.py deleted file mode 100644 index c0eebcb1e12..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Header/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatheaderservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATHeaderService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATHeaderService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py deleted file mode 100644 index 9256b4828c6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py +++ /dev/null @@ -1,107 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestHttpInfrastructureTestServiceConfiguration -from .operations import HttpFailureOperations -from .operations import HttpSuccessOperations -from .operations import HttpRedirectsOperations -from .operations import HttpClientFailureOperations -from .operations import HttpServerFailureOperations -from .operations import HttpRetryOperations -from .operations import MultipleResponsesOperations -from . import models - - -class AutoRestHttpInfrastructureTestService(object): - """Test Infrastructure for AutoRest. - - :ivar http_failure: HttpFailureOperations operations - :vartype http_failure: httpinfrastructure.operations.HttpFailureOperations - :ivar http_success: HttpSuccessOperations operations - :vartype http_success: httpinfrastructure.operations.HttpSuccessOperations - :ivar http_redirects: HttpRedirectsOperations operations - :vartype http_redirects: httpinfrastructure.operations.HttpRedirectsOperations - :ivar http_client_failure: HttpClientFailureOperations operations - :vartype http_client_failure: httpinfrastructure.operations.HttpClientFailureOperations - :ivar http_server_failure: HttpServerFailureOperations operations - :vartype http_server_failure: httpinfrastructure.operations.HttpServerFailureOperations - :ivar http_retry: HttpRetryOperations operations - :vartype http_retry: httpinfrastructure.operations.HttpRetryOperations - :ivar multiple_responses: MultipleResponsesOperations operations - :vartype multiple_responses: httpinfrastructure.operations.MultipleResponsesOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHttpInfrastructureTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.http_failure = HttpFailureOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_redirects = HttpRedirectsOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_client_failure = HttpClientFailureOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.http_server_failure = HttpServerFailureOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.http_retry = HttpRetryOperations(self._client, self._config, self._serialize, self._deserialize) - self.multiple_responses = MultipleResponsesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestHttpInfrastructureTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py deleted file mode 100644 index 71d066b390d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py +++ /dev/null @@ -1,93 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestHttpInfrastructureTestServiceConfiguration -from .operations import HttpFailureOperations -from .operations import HttpSuccessOperations -from .operations import HttpRedirectsOperations -from .operations import HttpClientFailureOperations -from .operations import HttpServerFailureOperations -from .operations import HttpRetryOperations -from .operations import MultipleResponsesOperations -from .. import models - - -class AutoRestHttpInfrastructureTestService(object): - """Test Infrastructure for AutoRest. - - :ivar http_failure: HttpFailureOperations operations - :vartype http_failure: httpinfrastructure.aio.operations.HttpFailureOperations - :ivar http_success: HttpSuccessOperations operations - :vartype http_success: httpinfrastructure.aio.operations.HttpSuccessOperations - :ivar http_redirects: HttpRedirectsOperations operations - :vartype http_redirects: httpinfrastructure.aio.operations.HttpRedirectsOperations - :ivar http_client_failure: HttpClientFailureOperations operations - :vartype http_client_failure: httpinfrastructure.aio.operations.HttpClientFailureOperations - :ivar http_server_failure: HttpServerFailureOperations operations - :vartype http_server_failure: httpinfrastructure.aio.operations.HttpServerFailureOperations - :ivar http_retry: HttpRetryOperations operations - :vartype http_retry: httpinfrastructure.aio.operations.HttpRetryOperations - :ivar multiple_responses: MultipleResponsesOperations operations - :vartype multiple_responses: httpinfrastructure.aio.operations.MultipleResponsesOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestHttpInfrastructureTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.http_failure = HttpFailureOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_redirects = HttpRedirectsOperations(self._client, self._config, self._serialize, self._deserialize) - self.http_client_failure = HttpClientFailureOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.http_server_failure = HttpServerFailureOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.http_retry = HttpRetryOperations(self._client, self._config, self._serialize, self._deserialize) - self.multiple_responses = MultipleResponsesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestHttpInfrastructureTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py deleted file mode 100644 index cecc929dc60..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py +++ /dev/null @@ -1,1166 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpClientFailureOperations: - """HttpClientFailureOperations 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: ~httpinfrastructure.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 head400(self, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def get400(self, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def options400(self, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - options400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def put400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def patch400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def post400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def delete400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace_async - async def head401(self, **kwargs: Any) -> None: - """Return 401 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head401.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head401.metadata = {"url": "/http/failure/client/401"} # type: ignore - - @distributed_trace_async - async def get402(self, **kwargs: Any) -> None: - """Return 402 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get402.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get402.metadata = {"url": "/http/failure/client/402"} # type: ignore - - @distributed_trace_async - async def options403(self, **kwargs: Any) -> None: - """Return 403 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options403.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - options403.metadata = {"url": "/http/failure/client/403"} # type: ignore - - @distributed_trace_async - async def get403(self, **kwargs: Any) -> None: - """Return 403 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get403.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get403.metadata = {"url": "/http/failure/client/403"} # type: ignore - - @distributed_trace_async - async def put404(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 404 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put404.metadata = {"url": "/http/failure/client/404"} # type: ignore - - @distributed_trace_async - async def patch405(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 405 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch405.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch405.metadata = {"url": "/http/failure/client/405"} # type: ignore - - @distributed_trace_async - async def post406(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 406 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post406.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post406.metadata = {"url": "/http/failure/client/406"} # type: ignore - - @distributed_trace_async - async def delete407(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 407 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete407.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete407.metadata = {"url": "/http/failure/client/407"} # type: ignore - - @distributed_trace_async - async def put409(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 409 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put409.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put409.metadata = {"url": "/http/failure/client/409"} # type: ignore - - @distributed_trace_async - async def head410(self, **kwargs: Any) -> None: - """Return 410 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head410.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head410.metadata = {"url": "/http/failure/client/410"} # type: ignore - - @distributed_trace_async - async def get411(self, **kwargs: Any) -> None: - """Return 411 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get411.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get411.metadata = {"url": "/http/failure/client/411"} # type: ignore - - @distributed_trace_async - async def options412(self, **kwargs: Any) -> None: - """Return 412 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options412.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - options412.metadata = {"url": "/http/failure/client/412"} # type: ignore - - @distributed_trace_async - async def get412(self, **kwargs: Any) -> None: - """Return 412 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get412.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get412.metadata = {"url": "/http/failure/client/412"} # type: ignore - - @distributed_trace_async - async def put413(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 413 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put413.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put413.metadata = {"url": "/http/failure/client/413"} # type: ignore - - @distributed_trace_async - async def patch414(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 414 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch414.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch414.metadata = {"url": "/http/failure/client/414"} # type: ignore - - @distributed_trace_async - async def post415(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 415 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post415.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post415.metadata = {"url": "/http/failure/client/415"} # type: ignore - - @distributed_trace_async - async def get416(self, **kwargs: Any) -> None: - """Return 416 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get416.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get416.metadata = {"url": "/http/failure/client/416"} # type: ignore - - @distributed_trace_async - async def delete417(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 417 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete417.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete417.metadata = {"url": "/http/failure/client/417"} # type: ignore - - @distributed_trace_async - async def head429(self, **kwargs: Any) -> None: - """Return 429 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head429.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head429.metadata = {"url": "/http/failure/client/429"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py deleted file mode 100644 index a805e69080b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py +++ /dev/null @@ -1,172 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpFailureOperations: - """HttpFailureOperations 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: ~httpinfrastructure.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 get_empty_error(self, **kwargs: Any) -> bool: - """Get empty error form server. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty_error.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_error.metadata = {"url": "/http/failure/emptybody/error"} # type: ignore - - @distributed_trace_async - async def get_no_model_error(self, **kwargs: Any) -> bool: - """Get empty error form server. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_no_model_error.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_no_model_error.metadata = {"url": "/http/failure/nomodel/error"} # type: ignore - - @distributed_trace_async - async def get_no_model_empty(self, **kwargs: Any) -> bool: - """Get empty response from server. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_no_model_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_no_model_empty.metadata = {"url": "/http/failure/nomodel/empty"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py deleted file mode 100644 index 72af6d62924..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py +++ /dev/null @@ -1,795 +0,0 @@ -# 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, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpRedirectsOperations: - """HttpRedirectsOperations 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: ~httpinfrastructure.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 head300(self, **kwargs: Any) -> None: - """Return 300 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head300.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 300]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 300: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head300.metadata = {"url": "/http/redirect/300"} # type: ignore - - @distributed_trace_async - async def get300(self, **kwargs: Any) -> Optional[List[str]]: - """Return 300 status code and redirect to /http/success/200. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get300.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 300]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - deserialized = None - if response.status_code == 300: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - get300.metadata = {"url": "/http/redirect/300"} # type: ignore - - @distributed_trace_async - async def head301(self, **kwargs: Any) -> None: - """Return 301 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head301.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 301]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 301: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head301.metadata = {"url": "/http/redirect/301"} # type: ignore - - @distributed_trace_async - async def get301(self, **kwargs: Any) -> None: - """Return 301 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get301.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 301]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 301: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get301.metadata = {"url": "/http/redirect/301"} # type: ignore - - @distributed_trace_async - async def put301(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Put true Boolean value in request returns 301. This request should not be automatically - redirected, but should return the received 301 to the caller for evaluation. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put301.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [301]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - put301.metadata = {"url": "/http/redirect/301"} # type: ignore - - @distributed_trace_async - async def head302(self, **kwargs: Any) -> None: - """Return 302 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head302.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 302]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 302: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head302.metadata = {"url": "/http/redirect/302"} # type: ignore - - @distributed_trace_async - async def get302(self, **kwargs: Any) -> None: - """Return 302 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get302.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 302]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 302: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get302.metadata = {"url": "/http/redirect/302"} # type: ignore - - @distributed_trace_async - async def patch302(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Patch true Boolean value in request returns 302. This request should not be automatically - redirected, but should return the received 302 to the caller for evaluation. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch302.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [302]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - patch302.metadata = {"url": "/http/redirect/302"} # type: ignore - - @distributed_trace_async - async def post303(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Post true Boolean value in request returns 303. This request should be automatically - redirected usign a get, ultimately returning a 200 status code. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post303.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 303]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 303: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - post303.metadata = {"url": "/http/redirect/303"} # type: ignore - - @distributed_trace_async - async def head307(self, **kwargs: Any) -> None: - """Redirect with 307, resulting in a 200 success. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace_async - async def get307(self, **kwargs: Any) -> None: - """Redirect get with 307, resulting in a 200 success. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace_async - async def options307(self, **kwargs: Any) -> None: - """options redirected with 307, resulting in a 200 after redirect. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - options307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace_async - async def put307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Put redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - put307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace_async - async def patch307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Patch redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - patch307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace_async - async def post307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Post redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - post307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace_async - async def delete307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Delete redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - delete307.metadata = {"url": "/http/redirect/307"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py deleted file mode 100644 index 4f5c082f2a1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py +++ /dev/null @@ -1,454 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpRetryOperations: - """HttpRetryOperations 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: ~httpinfrastructure.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 head408(self, **kwargs: Any) -> None: - """Return 408 status code, then 200 after retry. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head408.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head408.metadata = {"url": "/http/retry/408"} # type: ignore - - @distributed_trace_async - async def put500(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 500 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put500.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put500.metadata = {"url": "/http/retry/500"} # type: ignore - - @distributed_trace_async - async def patch500(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 500 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch500.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch500.metadata = {"url": "/http/retry/500"} # type: ignore - - @distributed_trace_async - async def get502(self, **kwargs: Any) -> None: - """Return 502 status code, then 200 after retry. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get502.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get502.metadata = {"url": "/http/retry/502"} # type: ignore - - @distributed_trace_async - async def options502(self, **kwargs: Any) -> bool: - """Return 502 status code, then 200 after retry. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.options502.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - options502.metadata = {"url": "/http/retry/502"} # type: ignore - - @distributed_trace_async - async def post503(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 503 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post503.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post503.metadata = {"url": "/http/retry/503"} # type: ignore - - @distributed_trace_async - async def delete503(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 503 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete503.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete503.metadata = {"url": "/http/retry/503"} # type: ignore - - @distributed_trace_async - async def put504(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 504 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put504.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put504.metadata = {"url": "/http/retry/504"} # type: ignore - - @distributed_trace_async - async def patch504(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 504 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch504.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch504.metadata = {"url": "/http/retry/504"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py deleted file mode 100644 index 35c2d973794..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py +++ /dev/null @@ -1,220 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpServerFailureOperations: - """HttpServerFailureOperations 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: ~httpinfrastructure.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 head501(self, **kwargs: Any) -> None: - """Return 501 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head501.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head501.metadata = {"url": "/http/failure/server/501"} # type: ignore - - @distributed_trace_async - async def get501(self, **kwargs: Any) -> None: - """Return 501 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get501.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get501.metadata = {"url": "/http/failure/server/501"} # type: ignore - - @distributed_trace_async - async def post505(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 505 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post505.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post505.metadata = {"url": "/http/failure/server/505"} # type: ignore - - @distributed_trace_async - async def delete505(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Return 505 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete505.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete505.metadata = {"url": "/http/failure/server/505"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py deleted file mode 100644 index 2dfedb61fb9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py +++ /dev/null @@ -1,918 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HttpSuccessOperations: - """HttpSuccessOperations 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: ~httpinfrastructure.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 head200(self, **kwargs: Any) -> None: - """Return 200 status code if successful. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def get200(self, **kwargs: Any) -> bool: - """Get 200 success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def options200(self, **kwargs: Any) -> bool: - """Options 200 success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.options200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - options200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def put200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Put boolean value true returning 200 success. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def patch200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Patch true Boolean value in request returning 200. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def post200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Post bollean value true in request that returns a 200. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def delete200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Delete simple boolean value true returns 200. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace_async - async def put201(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Put true Boolean value in request returns 201. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put201.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put201.metadata = {"url": "/http/success/201"} # type: ignore - - @distributed_trace_async - async def post201(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Post true Boolean value in request returns 201 (Created). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post201.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post201.metadata = {"url": "/http/success/201"} # type: ignore - - @distributed_trace_async - async def put202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Put true Boolean value in request returns 202 (Accepted). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace_async - async def patch202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Patch true Boolean value in request returns 202. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace_async - async def post202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Post true Boolean value in request returns 202 (Accepted). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace_async - async def delete202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Delete true Boolean value in request returns 202 (accepted). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace_async - async def head204(self, **kwargs: Any) -> None: - """Return 204 status code if successful. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def put204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Put true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def patch204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Patch true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def post204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Post true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def delete204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: - """Delete true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace_async - async def head404(self, **kwargs: Any) -> None: - """Return 404 status code. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py deleted file mode 100644 index 58ddb5d28a3..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py +++ /dev/null @@ -1,1456 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MultipleResponsesOperations: - """MultipleResponsesOperations 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: ~httpinfrastructure.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 get200_model204_no_model_default_error200_valid(self, **kwargs: Any) -> Optional["_models.MyException"]: - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/200/valid"} # type: ignore - - @distributed_trace_async - async def get200_model204_no_model_default_error204_valid(self, **kwargs: Any) -> Optional["_models.MyException"]: - """Send a 204 response with no payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error204_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error204_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/204/none"} # type: ignore - - @distributed_trace_async - async def get200_model204_no_model_default_error201_invalid(self, **kwargs: Any) -> Optional["_models.MyException"]: - """Send a 201 response with valid payload: {'statusCode': '201'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error201_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error201_invalid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/201/valid"} # type: ignore - - @distributed_trace_async - async def get200_model204_no_model_default_error202_none(self, **kwargs: Any) -> Optional["_models.MyException"]: - """Send a 202 response with no payload:. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error202_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error202_none.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/202/none"} # type: ignore - - @distributed_trace_async - async def get200_model204_no_model_default_error400_valid(self, **kwargs: Any) -> Optional["_models.MyException"]: - """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/400/valid"} # type: ignore - - @distributed_trace_async - async def get200_model201_model_default_error200_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.B"]: - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or B, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model201_model_default_error200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("B", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model201_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/200/valid"} # type: ignore - - @distributed_trace_async - async def get200_model201_model_default_error201_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.B"]: - """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or B, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model201_model_default_error201_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("B", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model201_model_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/201/valid"} # type: ignore - - @distributed_trace_async - async def get200_model201_model_default_error400_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.B"]: - """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or B, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model201_model_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("B", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model201_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/400/valid"} # type: ignore - - @distributed_trace_async - async def get200_model_a201_model_c404_model_d_default_error200_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.C", "_models.D"]: - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid"} # type: ignore - - @distributed_trace_async - async def get200_model_a201_model_c404_model_d_default_error201_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.C", "_models.D"]: - """Send a 200 response with valid payload: {'httpCode': '201'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error201_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid"} # type: ignore - - @distributed_trace_async - async def get200_model_a201_model_c404_model_d_default_error404_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.C", "_models.D"]: - """Send a 200 response with valid payload: {'httpStatusCode': '404'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error404_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error404_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid"} # type: ignore - - @distributed_trace_async - async def get200_model_a201_model_c404_model_d_default_error400_valid( - self, **kwargs: Any - ) -> Union["_models.MyException", "_models.C", "_models.D"]: - """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_error202_none(self, **kwargs: Any) -> None: - """Send a 202 response with no payload. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get202_none204_none_default_error202_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_error202_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/202/none"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_error204_none(self, **kwargs: Any) -> None: - """Send a 204 response with no payload. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get202_none204_none_default_error204_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_error204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/204/none"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_error400_valid(self, **kwargs: Any) -> None: - """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get202_none204_none_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_error400_valid.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/400/valid"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_none202_invalid(self, **kwargs: Any) -> None: - """Send a 202 response with an unexpected payload {'property': 'value'}. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none202_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none202_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/202/invalid"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_none204_none(self, **kwargs: Any) -> None: - """Send a 204 response with no payload. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none204_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/204/none"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_none400_none(self, **kwargs: Any) -> None: - """Send a 400 response with no payload. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none400_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/none"} # type: ignore - - @distributed_trace_async - async def get202_none204_none_default_none400_invalid(self, **kwargs: Any) -> None: - """Send a 400 response with an unexpected payload {'property': 'value'}. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none400_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none400_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/invalid"} # type: ignore - - @distributed_trace_async - async def get_default_model_a200_valid(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_default_model_a200_valid.metadata = {"url": "/http/payloads/default/A/response/200/valid"} # type: ignore - - @distributed_trace_async - async def get_default_model_a200_none(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with no payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a200_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_default_model_a200_none.metadata = {"url": "/http/payloads/default/A/response/200/none"} # type: ignore - - @distributed_trace_async - async def get_default_model_a400_valid(self, **kwargs: Any) -> None: - """Send a 400 response with valid payload: {'statusCode': '400'}. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyException, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_model_a400_valid.metadata = {"url": "/http/payloads/default/A/response/400/valid"} # type: ignore - - @distributed_trace_async - async def get_default_model_a400_none(self, **kwargs: Any) -> None: - """Send a 400 response with no payload. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyException, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_model_a400_none.metadata = {"url": "/http/payloads/default/A/response/400/none"} # type: ignore - - @distributed_trace_async - async def get_default_none200_invalid(self, **kwargs: Any) -> None: - """Send a 200 response with invalid payload: {'statusCode': '200'}. - - :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", {})) - - # Construct URL - url = self.get_default_none200_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none200_invalid.metadata = {"url": "/http/payloads/default/none/response/200/invalid"} # type: ignore - - @distributed_trace_async - async def get_default_none200_none(self, **kwargs: Any) -> None: - """Send a 200 response with no payload. - - :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", {})) - - # Construct URL - url = self.get_default_none200_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none200_none.metadata = {"url": "/http/payloads/default/none/response/200/none"} # type: ignore - - @distributed_trace_async - async def get_default_none400_invalid(self, **kwargs: Any) -> None: - """Send a 400 response with valid payload: {'statusCode': '400'}. - - :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", {})) - - # Construct URL - url = self.get_default_none400_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none400_invalid.metadata = {"url": "/http/payloads/default/none/response/400/invalid"} # type: ignore - - @distributed_trace_async - async def get_default_none400_none(self, **kwargs: Any) -> None: - """Send a 400 response with no payload. - - :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", {})) - - # Construct URL - url = self.get_default_none400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none400_none.metadata = {"url": "/http/payloads/default/none/response/400/none"} # type: ignore - - @distributed_trace_async - async def get200_model_a200_none(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with no payload, when a payload is expected - client should return a null - object of thde type for model A. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a200_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a200_none.metadata = {"url": "/http/payloads/200/A/response/200/none"} # type: ignore - - @distributed_trace_async - async def get200_model_a200_valid(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with payload {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a200_valid.metadata = {"url": "/http/payloads/200/A/response/200/valid"} # type: ignore - - @distributed_trace_async - async def get200_model_a200_invalid(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a200_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a200_invalid.metadata = {"url": "/http/payloads/200/A/response/200/invalid"} # type: ignore - - @distributed_trace_async - async def get200_model_a400_none(self, **kwargs: Any) -> "_models.MyException": - """Send a 400 response with no payload client should treat as an http error with no error model. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a400_none.metadata = {"url": "/http/payloads/200/A/response/400/none"} # type: ignore - - @distributed_trace_async - async def get200_model_a400_valid(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with payload {'statusCode': '400'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a400_valid.metadata = {"url": "/http/payloads/200/A/response/400/valid"} # type: ignore - - @distributed_trace_async - async def get200_model_a400_invalid(self, **kwargs: Any) -> "_models.MyException": - """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a400_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a400_invalid.metadata = {"url": "/http/payloads/200/A/response/400/invalid"} # type: ignore - - @distributed_trace_async - async def get200_model_a202_valid(self, **kwargs: Any) -> "_models.MyException": - """Send a 202 response with payload {'statusCode': '202'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a202_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a202_valid.metadata = {"url": "/http/payloads/200/A/response/202/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py deleted file mode 100644 index 6735546478e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py +++ /dev/null @@ -1,1274 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class HttpClientFailureOperations(object): - """HttpClientFailureOperations 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: ~httpinfrastructure.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 head400( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def get400( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def options400( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - options400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def put400( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def patch400( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def post400( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def delete400( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 400 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete400.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete400.metadata = {"url": "/http/failure/client/400"} # type: ignore - - @distributed_trace - def head401( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 401 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head401.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head401.metadata = {"url": "/http/failure/client/401"} # type: ignore - - @distributed_trace - def get402( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 402 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get402.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get402.metadata = {"url": "/http/failure/client/402"} # type: ignore - - @distributed_trace - def options403( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 403 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options403.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - options403.metadata = {"url": "/http/failure/client/403"} # type: ignore - - @distributed_trace - def get403( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 403 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get403.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get403.metadata = {"url": "/http/failure/client/403"} # type: ignore - - @distributed_trace - def put404( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 404 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put404.metadata = {"url": "/http/failure/client/404"} # type: ignore - - @distributed_trace - def patch405( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 405 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch405.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch405.metadata = {"url": "/http/failure/client/405"} # type: ignore - - @distributed_trace - def post406( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 406 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post406.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post406.metadata = {"url": "/http/failure/client/406"} # type: ignore - - @distributed_trace - def delete407( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 407 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete407.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete407.metadata = {"url": "/http/failure/client/407"} # type: ignore - - @distributed_trace - def put409( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 409 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put409.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put409.metadata = {"url": "/http/failure/client/409"} # type: ignore - - @distributed_trace - def head410( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 410 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head410.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head410.metadata = {"url": "/http/failure/client/410"} # type: ignore - - @distributed_trace - def get411( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 411 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get411.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get411.metadata = {"url": "/http/failure/client/411"} # type: ignore - - @distributed_trace - def options412( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 412 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options412.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - options412.metadata = {"url": "/http/failure/client/412"} # type: ignore - - @distributed_trace - def get412( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 412 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get412.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get412.metadata = {"url": "/http/failure/client/412"} # type: ignore - - @distributed_trace - def put413( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 413 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put413.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put413.metadata = {"url": "/http/failure/client/413"} # type: ignore - - @distributed_trace - def patch414( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 414 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch414.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch414.metadata = {"url": "/http/failure/client/414"} # type: ignore - - @distributed_trace - def post415( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 415 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post415.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post415.metadata = {"url": "/http/failure/client/415"} # type: ignore - - @distributed_trace - def get416( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 416 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get416.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get416.metadata = {"url": "/http/failure/client/416"} # type: ignore - - @distributed_trace - def delete417( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 417 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete417.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete417.metadata = {"url": "/http/failure/client/417"} # type: ignore - - @distributed_trace - def head429( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 429 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head429.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head429.metadata = {"url": "/http/failure/client/429"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py deleted file mode 100644 index fb7a5d3bf0b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py +++ /dev/null @@ -1,185 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class HttpFailureOperations(object): - """HttpFailureOperations 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: ~httpinfrastructure.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 get_empty_error( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get empty error form server. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_empty_error.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_error.metadata = {"url": "/http/failure/emptybody/error"} # type: ignore - - @distributed_trace - def get_no_model_error( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get empty error form server. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_no_model_error.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_no_model_error.metadata = {"url": "/http/failure/nomodel/error"} # type: ignore - - @distributed_trace - def get_no_model_empty( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get empty response from server. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_no_model_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_no_model_empty.metadata = {"url": "/http/failure/nomodel/empty"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py deleted file mode 100644 index 675ea0130bd..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py +++ /dev/null @@ -1,861 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class HttpRedirectsOperations(object): - """HttpRedirectsOperations 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: ~httpinfrastructure.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 head300( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 300 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head300.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 300]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 300: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head300.metadata = {"url": "/http/redirect/300"} # type: ignore - - @distributed_trace - def get300( - self, **kwargs # type: Any - ): - # type: (...) -> Optional[List[str]] - """Return 300 status code and redirect to /http/success/200. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of str, or the result of cls(response) - :rtype: list[str] or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional[List[str]]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get300.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 300]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - deserialized = None - if response.status_code == 300: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("[str]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - get300.metadata = {"url": "/http/redirect/300"} # type: ignore - - @distributed_trace - def head301( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 301 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head301.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 301]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 301: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head301.metadata = {"url": "/http/redirect/301"} # type: ignore - - @distributed_trace - def get301( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 301 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get301.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 301]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 301: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get301.metadata = {"url": "/http/redirect/301"} # type: ignore - - @distributed_trace - def put301( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Put true Boolean value in request returns 301. This request should not be automatically - redirected, but should return the received 301 to the caller for evaluation. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put301.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [301]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - put301.metadata = {"url": "/http/redirect/301"} # type: ignore - - @distributed_trace - def head302( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 302 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head302.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 302]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 302: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head302.metadata = {"url": "/http/redirect/302"} # type: ignore - - @distributed_trace - def get302( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 302 status code and redirect to /http/success/200. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get302.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 302]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 302: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get302.metadata = {"url": "/http/redirect/302"} # type: ignore - - @distributed_trace - def patch302( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Patch true Boolean value in request returns 302. This request should not be automatically - redirected, but should return the received 302 to the caller for evaluation. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch302.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [302]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - patch302.metadata = {"url": "/http/redirect/302"} # type: ignore - - @distributed_trace - def post303( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Post true Boolean value in request returns 303. This request should be automatically - redirected usign a get, ultimately returning a 200 status code. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post303.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 303]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 303: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - post303.metadata = {"url": "/http/redirect/303"} # type: ignore - - @distributed_trace - def head307( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Redirect with 307, resulting in a 200 success. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - head307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace - def get307( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Redirect get with 307, resulting in a 200 success. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace - def options307( - self, **kwargs # type: Any - ): - # type: (...) -> None - """options redirected with 307, resulting in a 200 after redirect. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.options307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - options307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace - def put307( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Put redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - put307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace - def patch307( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Patch redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - patch307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace - def post307( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Post redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - post307.metadata = {"url": "/http/redirect/307"} # type: ignore - - @distributed_trace - def delete307( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Delete redirected with 307, resulting in a 200 after redirect. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete307.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 307]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - if response.status_code == 307: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - delete307.metadata = {"url": "/http/redirect/307"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py deleted file mode 100644 index 4ef96ce3d8c..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py +++ /dev/null @@ -1,497 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class HttpRetryOperations(object): - """HttpRetryOperations 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: ~httpinfrastructure.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 head408( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 408 status code, then 200 after retry. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head408.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head408.metadata = {"url": "/http/retry/408"} # type: ignore - - @distributed_trace - def put500( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 500 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put500.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put500.metadata = {"url": "/http/retry/500"} # type: ignore - - @distributed_trace - def patch500( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 500 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch500.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch500.metadata = {"url": "/http/retry/500"} # type: ignore - - @distributed_trace - def get502( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 502 status code, then 200 after retry. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get502.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get502.metadata = {"url": "/http/retry/502"} # type: ignore - - @distributed_trace - def options502( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Return 502 status code, then 200 after retry. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.options502.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - options502.metadata = {"url": "/http/retry/502"} # type: ignore - - @distributed_trace - def post503( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 503 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post503.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post503.metadata = {"url": "/http/retry/503"} # type: ignore - - @distributed_trace - def delete503( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 503 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete503.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete503.metadata = {"url": "/http/retry/503"} # type: ignore - - @distributed_trace - def put504( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 504 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put504.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put504.metadata = {"url": "/http/retry/504"} # type: ignore - - @distributed_trace - def patch504( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 504 status code, then 200 after retry. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch504.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch504.metadata = {"url": "/http/retry/504"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py deleted file mode 100644 index cff601afc80..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py +++ /dev/null @@ -1,240 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class HttpServerFailureOperations(object): - """HttpServerFailureOperations 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: ~httpinfrastructure.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 head501( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 501 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head501.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head501.metadata = {"url": "/http/failure/server/501"} # type: ignore - - @distributed_trace - def get501( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 501 status code - should be represented in the client as an error. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get501.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get501.metadata = {"url": "/http/failure/server/501"} # type: ignore - - @distributed_trace - def post505( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 505 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post505.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post505.metadata = {"url": "/http/failure/server/505"} # type: ignore - - @distributed_trace - def delete505( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Return 505 status code - should be represented in the client as an error. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete505.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in []: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete505.metadata = {"url": "/http/failure/server/505"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py deleted file mode 100644 index 6473814aaa1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py +++ /dev/null @@ -1,1007 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class HttpSuccessOperations(object): - """HttpSuccessOperations 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: ~httpinfrastructure.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 head200( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 200 status code if successful. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def get200( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Get 200 success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def options200( - self, **kwargs # type: Any - ): - # type: (...) -> bool - """Options 200 success. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[bool] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.options200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.options(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("bool", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - options200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def put200( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Put boolean value true returning 200 success. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def patch200( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Patch true Boolean value in request returning 200. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def post200( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Post bollean value true in request that returns a 200. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def delete200( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Delete simple boolean value true returns 200. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete200.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete200.metadata = {"url": "/http/success/200"} # type: ignore - - @distributed_trace - def put201( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Put true Boolean value in request returns 201. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put201.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put201.metadata = {"url": "/http/success/201"} # type: ignore - - @distributed_trace - def post201( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Post true Boolean value in request returns 201 (Created). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post201.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post201.metadata = {"url": "/http/success/201"} # type: ignore - - @distributed_trace - def put202( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Put true Boolean value in request returns 202 (Accepted). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace - def patch202( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Patch true Boolean value in request returns 202. - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace - def post202( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Post true Boolean value in request returns 202 (Accepted). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace - def delete202( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Delete true Boolean value in request returns 202 (accepted). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete202.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete202.metadata = {"url": "/http/success/202"} # type: ignore - - @distributed_trace - def head204( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 204 status code if successful. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def put204( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Put true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.put204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def patch204( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Patch true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.patch204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - patch204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def post204( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Post true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.post204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def delete204( - self, - boolean_value=True, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Delete true Boolean value in request returns 204 (no content). - - :param boolean_value: Simple boolean value true. - :type boolean_value: bool - :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/json") - accept = "application/json" - - # Construct URL - url = self.delete204.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if boolean_value is not None: - body_content = self._serialize.body(boolean_value, "bool") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.delete(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete204.metadata = {"url": "/http/success/204"} # type: ignore - - @distributed_trace - def head404( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Return 404 status code. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.head404.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.head(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py deleted file mode 100644 index 4145ace525d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py +++ /dev/null @@ -1,1548 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class MultipleResponsesOperations(object): - """MultipleResponsesOperations 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: ~httpinfrastructure.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 get200_model204_no_model_default_error200_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MyException"] - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/200/valid"} # type: ignore - - @distributed_trace - def get200_model204_no_model_default_error204_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MyException"] - """Send a 204 response with no payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error204_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error204_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/204/none"} # type: ignore - - @distributed_trace - def get200_model204_no_model_default_error201_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MyException"] - """Send a 201 response with valid payload: {'statusCode': '201'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error201_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error201_invalid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/201/valid"} # type: ignore - - @distributed_trace - def get200_model204_no_model_default_error202_none( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MyException"] - """Send a 202 response with no payload:. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error202_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error202_none.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/202/none"} # type: ignore - - @distributed_trace - def get200_model204_no_model_default_error400_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MyException"] - """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model204_no_model_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model204_no_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/400/valid"} # type: ignore - - @distributed_trace - def get200_model201_model_default_error200_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.B"] - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or B, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model201_model_default_error200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("B", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model201_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/200/valid"} # type: ignore - - @distributed_trace - def get200_model201_model_default_error201_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.B"] - """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or B, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model201_model_default_error201_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("B", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model201_model_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/201/valid"} # type: ignore - - @distributed_trace - def get200_model201_model_default_error400_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.B"] - """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or B, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model201_model_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("B", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model201_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/400/valid"} # type: ignore - - @distributed_trace - def get200_model_a201_model_c404_model_d_default_error200_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid"} # type: ignore - - @distributed_trace - def get200_model_a201_model_c404_model_d_default_error201_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] - """Send a 200 response with valid payload: {'httpCode': '201'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error201_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid"} # type: ignore - - @distributed_trace - def get200_model_a201_model_c404_model_d_default_error404_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] - """Send a 200 response with valid payload: {'httpStatusCode': '404'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error404_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error404_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid"} # type: ignore - - @distributed_trace - def get200_model_a201_model_c404_model_d_default_error400_valid( - self, **kwargs # type: Any - ): - # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] - """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException or C or D, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or ~httpinfrastructure.models.D - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a201_model_c404_model_d_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if response.status_code == 200: - deserialized = self._deserialize("MyException", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("C", pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize("D", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a201_model_c404_model_d_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid"} # type: ignore - - @distributed_trace - def get202_none204_none_default_error202_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 202 response with no payload. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get202_none204_none_default_error202_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_error202_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/202/none"} # type: ignore - - @distributed_trace - def get202_none204_none_default_error204_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 204 response with no payload. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get202_none204_none_default_error204_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_error204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/204/none"} # type: ignore - - @distributed_trace - def get202_none204_none_default_error400_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get202_none204_none_default_error400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_error400_valid.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/400/valid"} # type: ignore - - @distributed_trace - def get202_none204_none_default_none202_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 202 response with an unexpected payload {'property': 'value'}. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none202_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none202_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/202/invalid"} # type: ignore - - @distributed_trace - def get202_none204_none_default_none204_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 204 response with no payload. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none204_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/204/none"} # type: ignore - - @distributed_trace - def get202_none204_none_default_none400_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with no payload. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none400_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/none"} # type: ignore - - @distributed_trace - def get202_none204_none_default_none400_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with an unexpected payload {'property': 'value'}. - - :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", {})) - - # Construct URL - url = self.get202_none204_none_default_none400_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get202_none204_none_default_none400_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/invalid"} # type: ignore - - @distributed_trace - def get_default_model_a200_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with valid payload: {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_default_model_a200_valid.metadata = {"url": "/http/payloads/default/A/response/200/valid"} # type: ignore - - @distributed_trace - def get_default_model_a200_none( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with no payload. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a200_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_default_model_a200_none.metadata = {"url": "/http/payloads/default/A/response/200/none"} # type: ignore - - @distributed_trace - def get_default_model_a400_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with valid payload: {'statusCode': '400'}. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyException, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_model_a400_valid.metadata = {"url": "/http/payloads/default/A/response/400/valid"} # type: ignore - - @distributed_trace - def get_default_model_a400_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with no payload. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_default_model_a400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyException, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_model_a400_none.metadata = {"url": "/http/payloads/default/A/response/400/none"} # type: ignore - - @distributed_trace - def get_default_none200_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 200 response with invalid payload: {'statusCode': '200'}. - - :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", {})) - - # Construct URL - url = self.get_default_none200_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none200_invalid.metadata = {"url": "/http/payloads/default/none/response/200/invalid"} # type: ignore - - @distributed_trace - def get_default_none200_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 200 response with no payload. - - :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", {})) - - # Construct URL - url = self.get_default_none200_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none200_none.metadata = {"url": "/http/payloads/default/none/response/200/none"} # type: ignore - - @distributed_trace - def get_default_none400_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with valid payload: {'statusCode': '400'}. - - :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", {})) - - # Construct URL - url = self.get_default_none400_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none400_invalid.metadata = {"url": "/http/payloads/default/none/response/400/invalid"} # type: ignore - - @distributed_trace - def get_default_none400_none( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Send a 400 response with no payload. - - :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", {})) - - # Construct URL - url = self.get_default_none400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_default_none400_none.metadata = {"url": "/http/payloads/default/none/response/400/none"} # type: ignore - - @distributed_trace - def get200_model_a200_none( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with no payload, when a payload is expected - client should return a null - object of thde type for model A. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a200_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a200_none.metadata = {"url": "/http/payloads/200/A/response/200/none"} # type: ignore - - @distributed_trace - def get200_model_a200_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with payload {'statusCode': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a200_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a200_valid.metadata = {"url": "/http/payloads/200/A/response/200/valid"} # type: ignore - - @distributed_trace - def get200_model_a200_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a200_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a200_invalid.metadata = {"url": "/http/payloads/200/A/response/200/invalid"} # type: ignore - - @distributed_trace - def get200_model_a400_none( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 400 response with no payload client should treat as an http error with no error model. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a400_none.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a400_none.metadata = {"url": "/http/payloads/200/A/response/400/none"} # type: ignore - - @distributed_trace - def get200_model_a400_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with payload {'statusCode': '400'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a400_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a400_valid.metadata = {"url": "/http/payloads/200/A/response/400/valid"} # type: ignore - - @distributed_trace - def get200_model_a400_invalid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a400_invalid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a400_invalid.metadata = {"url": "/http/payloads/200/A/response/400/invalid"} # type: ignore - - @distributed_trace - def get200_model_a202_valid( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.MyException" - """Send a 202 response with payload {'statusCode': '202'}. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MyException, or the result of cls(response) - :rtype: ~httpinfrastructure.models.MyException - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get200_model_a202_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("MyException", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get200_model_a202_valid.metadata = {"url": "/http/payloads/200/A/response/202/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/setup.py b/test/vanilla/Expected/AcceptanceTests/Http/setup.py deleted file mode 100644 index abb6248fad8..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Http/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autoresthttpinfrastructuretestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestHttpInfrastructureTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestHttpInfrastructureTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_incorrect_returned_error_model.py b/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_incorrect_returned_error_model.py deleted file mode 100644 index 7b2bc75e65f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_incorrect_returned_error_model.py +++ /dev/null @@ -1,73 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IncorrectReturnedErrorModelConfiguration -from .operations import IncorrectReturnedErrorModelOperationsMixin -from . import models - - -class IncorrectReturnedErrorModel(IncorrectReturnedErrorModelOperationsMixin): - """Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = IncorrectReturnedErrorModelConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> IncorrectReturnedErrorModel - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_incorrect_returned_error_model.py b/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_incorrect_returned_error_model.py deleted file mode 100644 index 7608ed6c29a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_incorrect_returned_error_model.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import IncorrectReturnedErrorModelConfiguration -from .operations import IncorrectReturnedErrorModelOperationsMixin -from .. import models - - -class IncorrectReturnedErrorModel(IncorrectReturnedErrorModelOperationsMixin): - """Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = IncorrectReturnedErrorModelConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "IncorrectReturnedErrorModel": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py b/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py deleted file mode 100644 index 259fbd7b184..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IncorrectReturnedErrorModelOperationsMixin: - @distributed_trace_async - async def get_incorrect_error_from_server(self, **kwargs: Any) -> None: - """Get an error response from the server that is not as described in our Error object. Want to - swallow the deserialization error and still return an HttpResponseError to the users. - - :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", {})) - - # Construct URL - url = self.get_incorrect_error_from_server.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_incorrect_error_from_server.metadata = {"url": "/incorrectError"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py b/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py deleted file mode 100644 index 519e223a798..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py +++ /dev/null @@ -1,70 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class IncorrectReturnedErrorModelOperationsMixin(object): - @distributed_trace - def get_incorrect_error_from_server( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get an error response from the server that is not as described in our Error object. Want to - swallow the deserialization error and still return an HttpResponseError to the users. - - :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", {})) - - # Construct URL - url = self.get_incorrect_error_from_server.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_incorrect_error_from_server.metadata = {"url": "/incorrectError"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/setup.py b/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/setup.py deleted file mode 100644 index ba4b91b8546..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "incorrectreturnederrormodel" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="IncorrectReturnedErrorModel", - author_email="", - url="", - keywords=["Swagger", "IncorrectReturnedErrorModel"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_media_types_client.py b/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_media_types_client.py deleted file mode 100644 index 7591dc5695b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_media_types_client.py +++ /dev/null @@ -1,73 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MediaTypesClientConfiguration -from .operations import MediaTypesClientOperationsMixin -from . import models - - -class MediaTypesClient(MediaTypesClientOperationsMixin): - """Play with produces/consumes and media-types in general. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = MediaTypesClientConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> MediaTypesClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_media_types_client.py b/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_media_types_client.py deleted file mode 100644 index 03d966983c5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_media_types_client.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import MediaTypesClientConfiguration -from .operations import MediaTypesClientOperationsMixin -from .. import models - - -class MediaTypesClient(MediaTypesClientOperationsMixin): - """Play with produces/consumes and media-types in general. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = MediaTypesClientConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MediaTypesClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py b/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py deleted file mode 100644 index c14fa81f302..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py +++ /dev/null @@ -1,146 +0,0 @@ -# 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, Callable, Dict, Generic, IO, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MediaTypesClientOperationsMixin: - @distributed_trace_async - async def analyze_body(self, input: Optional[Union[IO, "_models.SourcePath"]] = None, **kwargs: Any) -> str: - """Analyze body, that could be different media types. - - :param input: Input parameter. - :type input: IO or ~mediatypes.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.analyze_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters["Content-Type"].split(";")[0] in [ - "application/pdf", - "image/jpeg", - "image/png", - "image/tiff", - ]: - body_content_kwargs["stream_content"] = input - elif header_parameters["Content-Type"].split(";")[0] in ["application/json"]: - if input is not None: - body_content = self._serialize.body(input, "SourcePath") - else: - body_content = None - body_content_kwargs["content"] = body_content - else: - raise ValueError( - "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format( - header_parameters["Content-Type"] - ) - ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - analyze_body.metadata = {"url": "/mediatypes/analyze"} # type: ignore - - @distributed_trace_async - async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) -> str: - """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. - - :param input: Input parameter. - :type input: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "text/plain") - accept = "application/json" - - # Construct URL - url = self.content_type_with_encoding.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if input is not None: - body_content = self._serialize.body(input, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - content_type_with_encoding.metadata = {"url": "/mediatypes/contentTypeWithEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py b/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py deleted file mode 100644 index f88e612175b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class MediaTypesClientOperationsMixin(object): - @distributed_trace - def analyze_body( - self, - input=None, # type: Optional[Union[IO, "_models.SourcePath"]] - **kwargs # type: Any - ): - # type: (...) -> str - """Analyze body, that could be different media types. - - :param input: Input parameter. - :type input: IO or ~mediatypes.models.SourcePath - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json". - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.analyze_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters["Content-Type"].split(";")[0] in [ - "application/pdf", - "image/jpeg", - "image/png", - "image/tiff", - ]: - body_content_kwargs["stream_content"] = input - elif header_parameters["Content-Type"].split(";")[0] in ["application/json"]: - if input is not None: - body_content = self._serialize.body(input, "SourcePath") - else: - body_content = None - body_content_kwargs["content"] = body_content - else: - raise ValueError( - "The content_type '{}' is not one of the allowed values: " - "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format( - header_parameters["Content-Type"] - ) - ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - analyze_body.metadata = {"url": "/mediatypes/analyze"} # type: ignore - - @distributed_trace - def content_type_with_encoding( - self, - input=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> str - """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. - - :param input: Input parameter. - :type input: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "text/plain") - accept = "application/json" - - # Construct URL - url = self.content_type_with_encoding.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if input is not None: - body_content = self._serialize.body(input, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - content_type_with_encoding.metadata = {"url": "/mediatypes/contentTypeWithEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/setup.py b/test/vanilla/Expected/AcceptanceTests/MediaTypes/setup.py deleted file mode 100644 index 2589338b2b5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MediaTypes/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "mediatypesclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="MediaTypesClient", - author_email="", - url="", - keywords=["Swagger", "MediaTypesClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Play with produces/consumes and media-types in general. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_auto_rest_resource_flattening_test_service.py b/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_auto_rest_resource_flattening_test_service.py deleted file mode 100644 index 9e90731c362..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_auto_rest_resource_flattening_test_service.py +++ /dev/null @@ -1,73 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestResourceFlatteningTestServiceConfiguration -from .operations import AutoRestResourceFlatteningTestServiceOperationsMixin -from . import models - - -class AutoRestResourceFlatteningTestService(AutoRestResourceFlatteningTestServiceOperationsMixin): - """Resource Flattening for AutoRest. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestResourceFlatteningTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestResourceFlatteningTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_auto_rest_resource_flattening_test_service.py b/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_auto_rest_resource_flattening_test_service.py deleted file mode 100644 index 58f711297d1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_auto_rest_resource_flattening_test_service.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestResourceFlatteningTestServiceConfiguration -from .operations import AutoRestResourceFlatteningTestServiceOperationsMixin -from .. import models - - -class AutoRestResourceFlatteningTestService(AutoRestResourceFlatteningTestServiceOperationsMixin): - """Resource Flattening for AutoRest. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestResourceFlatteningTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestResourceFlatteningTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py b/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py deleted file mode 100644 index a5f2c554752..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py +++ /dev/null @@ -1,616 +0,0 @@ -# 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, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoRestResourceFlatteningTestServiceOperationsMixin: - @distributed_trace_async - async def put_array(self, resource_array: Optional[List["_models.Resource"]] = None, **kwargs: Any) -> None: - """Put External Resource as an Array. - - :param resource_array: External Resource as an Array to put. - :type resource_array: list[~modelflattening.models.Resource] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_array is not None: - body_content = self._serialize.body(resource_array, "[Resource]") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array.metadata = {"url": "/model-flatten/array"} # type: ignore - - @distributed_trace_async - async def get_array(self, **kwargs: Any) -> List["_models.FlattenedProduct"]: - """Get External Resource as an Array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of FlattenedProduct, or the result of cls(response) - :rtype: list[~modelflattening.models.FlattenedProduct] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.FlattenedProduct"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[FlattenedProduct]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array.metadata = {"url": "/model-flatten/array"} # type: ignore - - @distributed_trace_async - async def put_wrapped_array( - self, resource_array: Optional[List["_models.WrappedProduct"]] = None, **kwargs: Any - ) -> None: - """No need to have a route in Express server for this operation. Used to verify the type flattened - is not removed if it's referenced in an array. - - :param resource_array: External Resource as an Array to put. - :type resource_array: list[~modelflattening.models.WrappedProduct] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_wrapped_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_array is not None: - body_content = self._serialize.body(resource_array, "[WrappedProduct]") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore - - @distributed_trace_async - async def get_wrapped_array(self, **kwargs: Any) -> List["_models.ProductWrapper"]: - """No need to have a route in Express server for this operation. Used to verify the type flattened - is not removed if it's referenced in an array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ProductWrapper, or the result of cls(response) - :rtype: list[~modelflattening.models.ProductWrapper] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.ProductWrapper"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_wrapped_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[ProductWrapper]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore - - @distributed_trace_async - async def put_dictionary( - self, resource_dictionary: Optional[Dict[str, "_models.FlattenedProduct"]] = None, **kwargs: Any - ) -> None: - """Put External Resource as a Dictionary. - - :param resource_dictionary: External Resource as a Dictionary to put. - :type resource_dictionary: dict[str, ~modelflattening.models.FlattenedProduct] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_dictionary is not None: - body_content = self._serialize.body(resource_dictionary, "{FlattenedProduct}") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore - - @distributed_trace_async - async def get_dictionary(self, **kwargs: Any) -> Dict[str, "_models.FlattenedProduct"]: - """Get External Resource as a Dictionary. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to FlattenedProduct, or the result of cls(response) - :rtype: dict[str, ~modelflattening.models.FlattenedProduct] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.FlattenedProduct"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{FlattenedProduct}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore - - @distributed_trace_async - async def put_resource_collection( - self, resource_complex_object: Optional["_models.ResourceCollection"] = None, **kwargs: Any - ) -> None: - """Put External Resource as a ResourceCollection. - - :param resource_complex_object: External Resource as a ResourceCollection to put. - :type resource_complex_object: ~modelflattening.models.ResourceCollection - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_resource_collection.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_complex_object is not None: - body_content = self._serialize.body(resource_complex_object, "ResourceCollection") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore - - @distributed_trace_async - async def get_resource_collection(self, **kwargs: Any) -> "_models.ResourceCollection": - """Get External Resource as a ResourceCollection. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceCollection, or the result of cls(response) - :rtype: ~modelflattening.models.ResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ResourceCollection"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_resource_collection.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore - - @distributed_trace_async - async def put_simple_product( - self, simple_body_product: Optional["_models.SimpleProduct"] = None, **kwargs: Any - ) -> "_models.SimpleProduct": - """Put Simple Product with client flattening true on the model. - - :param simple_body_product: Simple body product to put. - :type simple_body_product: ~modelflattening.models.SimpleProduct - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimpleProduct, or the result of cls(response) - :rtype: ~modelflattening.models.SimpleProduct - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_simple_product.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if simple_body_product is not None: - body_content = self._serialize.body(simple_body_product, "SimpleProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("SimpleProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore - - @distributed_trace_async - async def post_flattened_simple_product( - self, - product_id: str, - description: Optional[str] = None, - max_product_display_name: Optional[str] = None, - capacity: Optional[str] = "Large", - generic_value: Optional[str] = None, - odata_value: Optional[str] = None, - **kwargs: Any - ) -> "_models.SimpleProduct": - """Put Flattened Simple Product with client flattening true on the parameter. - - :param product_id: Unique identifier representing a specific product for a given latitude & - longitude. For example, uberX in San Francisco will have a different product_id than uberX in - Los Angeles. - :type product_id: str - :param description: Description of product. - :type description: str - :param max_product_display_name: Display name of product. - :type max_product_display_name: str - :param capacity: Capacity of product. For example, 4 people. - :type capacity: str - :param generic_value: Generic URL value. - :type generic_value: str - :param odata_value: URL value. - :type odata_value: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimpleProduct, or the result of cls(response) - :rtype: ~modelflattening.models.SimpleProduct - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _simple_body_product = _models.SimpleProduct( - product_id=product_id, - description=description, - max_product_display_name=max_product_display_name, - capacity=capacity, - generic_value=generic_value, - odata_value=odata_value, - ) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_flattened_simple_product.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _simple_body_product is not None: - body_content = self._serialize.body(_simple_body_product, "SimpleProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("SimpleProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - post_flattened_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore - - @distributed_trace_async - async def put_simple_product_with_grouping( - self, flatten_parameter_group: "_models.FlattenParameterGroup", **kwargs: Any - ) -> "_models.SimpleProduct": - """Put Simple Product with client flattening true on the model. - - :param flatten_parameter_group: Parameter group. - :type flatten_parameter_group: ~modelflattening.models.FlattenParameterGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimpleProduct, or the result of cls(response) - :rtype: ~modelflattening.models.SimpleProduct - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _name = None - _simple_body_product = None - _product_id = None - _description = None - _max_product_display_name = None - capacity = None - _generic_value = None - _odata_value = None - if flatten_parameter_group is not None: - _name = flatten_parameter_group.name - _simple_body_product = flatten_parameter_group.simple_body_product - _product_id = flatten_parameter_group.product_id - _description = flatten_parameter_group.description - _max_product_display_name = flatten_parameter_group.max_product_display_name - capacity = flatten_parameter_group.capacity - _generic_value = flatten_parameter_group.generic_value - _odata_value = flatten_parameter_group.odata_value - - _simple_body_product = _models.SimpleProduct( - product_id=_product_id, - description=_description, - max_product_display_name=_max_product_display_name, - capacity=capacity, - generic_value=_generic_value, - odata_value=_odata_value, - ) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_simple_product_with_grouping.metadata["url"] # type: ignore - path_format_arguments = { - "name": self._serialize.url("name", _name, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _simple_body_product is not None: - body_content = self._serialize.body(_simple_body_product, "SimpleProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("SimpleProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_simple_product_with_grouping.metadata = {"url": "/model-flatten/customFlattening/parametergrouping/{name}/"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py b/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py deleted file mode 100644 index 0017fddaf60..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py +++ /dev/null @@ -1,653 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class AutoRestResourceFlatteningTestServiceOperationsMixin(object): - @distributed_trace - def put_array( - self, - resource_array=None, # type: Optional[List["_models.Resource"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put External Resource as an Array. - - :param resource_array: External Resource as an Array to put. - :type resource_array: list[~modelflattening.models.Resource] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_array is not None: - body_content = self._serialize.body(resource_array, "[Resource]") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_array.metadata = {"url": "/model-flatten/array"} # type: ignore - - @distributed_trace - def get_array( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.FlattenedProduct"] - """Get External Resource as an Array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of FlattenedProduct, or the result of cls(response) - :rtype: list[~modelflattening.models.FlattenedProduct] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.FlattenedProduct"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[FlattenedProduct]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_array.metadata = {"url": "/model-flatten/array"} # type: ignore - - @distributed_trace - def put_wrapped_array( - self, - resource_array=None, # type: Optional[List["_models.WrappedProduct"]] - **kwargs # type: Any - ): - # type: (...) -> None - """No need to have a route in Express server for this operation. Used to verify the type flattened - is not removed if it's referenced in an array. - - :param resource_array: External Resource as an Array to put. - :type resource_array: list[~modelflattening.models.WrappedProduct] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_wrapped_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_array is not None: - body_content = self._serialize.body(resource_array, "[WrappedProduct]") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore - - @distributed_trace - def get_wrapped_array( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.ProductWrapper"] - """No need to have a route in Express server for this operation. Used to verify the type flattened - is not removed if it's referenced in an array. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ProductWrapper, or the result of cls(response) - :rtype: list[~modelflattening.models.ProductWrapper] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.ProductWrapper"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_wrapped_array.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("[ProductWrapper]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore - - @distributed_trace - def put_dictionary( - self, - resource_dictionary=None, # type: Optional[Dict[str, "_models.FlattenedProduct"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Put External Resource as a Dictionary. - - :param resource_dictionary: External Resource as a Dictionary to put. - :type resource_dictionary: dict[str, ~modelflattening.models.FlattenedProduct] - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_dictionary.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_dictionary is not None: - body_content = self._serialize.body(resource_dictionary, "{FlattenedProduct}") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore - - @distributed_trace - def get_dictionary( - self, **kwargs # type: Any - ): - # type: (...) -> Dict[str, "_models.FlattenedProduct"] - """Get External Resource as a Dictionary. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to FlattenedProduct, or the result of cls(response) - :rtype: dict[str, ~modelflattening.models.FlattenedProduct] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.FlattenedProduct"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_dictionary.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{FlattenedProduct}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore - - @distributed_trace - def put_resource_collection( - self, - resource_complex_object=None, # type: Optional["_models.ResourceCollection"] - **kwargs # type: Any - ): - # type: (...) -> None - """Put External Resource as a ResourceCollection. - - :param resource_complex_object: External Resource as a ResourceCollection to put. - :type resource_complex_object: ~modelflattening.models.ResourceCollection - :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/json") - accept = "application/json" - - # Construct URL - url = self.put_resource_collection.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_complex_object is not None: - body_content = self._serialize.body(resource_complex_object, "ResourceCollection") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore - - @distributed_trace - def get_resource_collection( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceCollection" - """Get External Resource as a ResourceCollection. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceCollection, or the result of cls(response) - :rtype: ~modelflattening.models.ResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ResourceCollection"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_resource_collection.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore - - @distributed_trace - def put_simple_product( - self, - simple_body_product=None, # type: Optional["_models.SimpleProduct"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SimpleProduct" - """Put Simple Product with client flattening true on the model. - - :param simple_body_product: Simple body product to put. - :type simple_body_product: ~modelflattening.models.SimpleProduct - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimpleProduct, or the result of cls(response) - :rtype: ~modelflattening.models.SimpleProduct - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_simple_product.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if simple_body_product is not None: - body_content = self._serialize.body(simple_body_product, "SimpleProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("SimpleProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore - - @distributed_trace - def post_flattened_simple_product( - self, - product_id, # type: str - description=None, # type: Optional[str] - max_product_display_name=None, # type: Optional[str] - capacity="Large", # type: Optional[str] - generic_value=None, # type: Optional[str] - odata_value=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SimpleProduct" - """Put Flattened Simple Product with client flattening true on the parameter. - - :param product_id: Unique identifier representing a specific product for a given latitude & - longitude. For example, uberX in San Francisco will have a different product_id than uberX in - Los Angeles. - :type product_id: str - :param description: Description of product. - :type description: str - :param max_product_display_name: Display name of product. - :type max_product_display_name: str - :param capacity: Capacity of product. For example, 4 people. - :type capacity: str - :param generic_value: Generic URL value. - :type generic_value: str - :param odata_value: URL value. - :type odata_value: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimpleProduct, or the result of cls(response) - :rtype: ~modelflattening.models.SimpleProduct - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _simple_body_product = _models.SimpleProduct( - product_id=product_id, - description=description, - max_product_display_name=max_product_display_name, - capacity=capacity, - generic_value=generic_value, - odata_value=odata_value, - ) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_flattened_simple_product.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _simple_body_product is not None: - body_content = self._serialize.body(_simple_body_product, "SimpleProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("SimpleProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - post_flattened_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore - - @distributed_trace - def put_simple_product_with_grouping( - self, - flatten_parameter_group, # type: "_models.FlattenParameterGroup" - **kwargs # type: Any - ): - # type: (...) -> "_models.SimpleProduct" - """Put Simple Product with client flattening true on the model. - - :param flatten_parameter_group: Parameter group. - :type flatten_parameter_group: ~modelflattening.models.FlattenParameterGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SimpleProduct, or the result of cls(response) - :rtype: ~modelflattening.models.SimpleProduct - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _name = None - _simple_body_product = None - _product_id = None - _description = None - _max_product_display_name = None - capacity = None - _generic_value = None - _odata_value = None - if flatten_parameter_group is not None: - _name = flatten_parameter_group.name - _simple_body_product = flatten_parameter_group.simple_body_product - _product_id = flatten_parameter_group.product_id - _description = flatten_parameter_group.description - _max_product_display_name = flatten_parameter_group.max_product_display_name - capacity = flatten_parameter_group.capacity - _generic_value = flatten_parameter_group.generic_value - _odata_value = flatten_parameter_group.odata_value - - _simple_body_product = _models.SimpleProduct( - product_id=_product_id, - description=_description, - max_product_display_name=_max_product_display_name, - capacity=capacity, - generic_value=_generic_value, - odata_value=_odata_value, - ) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_simple_product_with_grouping.metadata["url"] # type: ignore - path_format_arguments = { - "name": self._serialize.url("name", _name, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _simple_body_product is not None: - body_content = self._serialize.body(_simple_body_product, "SimpleProduct") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("SimpleProduct", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_simple_product_with_grouping.metadata = {"url": "/model-flatten/customFlattening/parametergrouping/{name}/"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/setup.py b/test/vanilla/Expected/AcceptanceTests/ModelFlattening/setup.py deleted file mode 100644 index f050667ec9f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestresourceflatteningtestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestResourceFlatteningTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestResourceFlatteningTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Resource Flattening for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_multiple_inheritance_service_client.py b/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_multiple_inheritance_service_client.py deleted file mode 100644 index f63096db9b0..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_multiple_inheritance_service_client.py +++ /dev/null @@ -1,73 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MultipleInheritanceServiceClientConfiguration -from .operations import MultipleInheritanceServiceClientOperationsMixin -from . import models - - -class MultipleInheritanceServiceClient(MultipleInheritanceServiceClientOperationsMixin): - """Service client for multiinheritance client testing. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = MultipleInheritanceServiceClientConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> MultipleInheritanceServiceClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_multiple_inheritance_service_client.py b/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_multiple_inheritance_service_client.py deleted file mode 100644 index e0f0f5fe45b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_multiple_inheritance_service_client.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import MultipleInheritanceServiceClientConfiguration -from .operations import MultipleInheritanceServiceClientOperationsMixin -from .. import models - - -class MultipleInheritanceServiceClient(MultipleInheritanceServiceClientOperationsMixin): - """Service client for multiinheritance client testing. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = MultipleInheritanceServiceClientConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MultipleInheritanceServiceClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py b/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py deleted file mode 100644 index 30c03625474..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py +++ /dev/null @@ -1,482 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MultipleInheritanceServiceClientOperationsMixin: - @distributed_trace_async - async def get_horse(self, **kwargs: Any) -> "_models.Horse": - """Get a horse with name 'Fred' and isAShowHorse true. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Horse, or the result of cls(response) - :rtype: ~multipleinheritance.models.Horse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Horse"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_horse.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Horse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore - - @distributed_trace_async - async def put_horse(self, horse: "_models.Horse", **kwargs: Any) -> str: - """Put a horse with name 'General' and isAShowHorse false. - - :param horse: Put a horse with name 'General' and isAShowHorse false. - :type horse: ~multipleinheritance.models.Horse - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_horse.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(horse, "Horse") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore - - @distributed_trace_async - async def get_pet(self, **kwargs: Any) -> "_models.Pet": - """Get a pet with name 'Peanut'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~multipleinheritance.models.Pet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_pet.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore - - @distributed_trace_async - async def put_pet(self, name: str, **kwargs: Any) -> str: - """Put a pet with name 'Butter'. - - :param name: - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _pet = _models.Pet(name=name) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_pet.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_pet, "Pet") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore - - @distributed_trace_async - async def get_feline(self, **kwargs: Any) -> "_models.Feline": - """Get a feline where meows and hisses are true. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Feline, or the result of cls(response) - :rtype: ~multipleinheritance.models.Feline - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Feline"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_feline.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Feline", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore - - @distributed_trace_async - async def put_feline(self, feline: "_models.Feline", **kwargs: Any) -> str: - """Put a feline who hisses and doesn't meow. - - :param feline: Put a feline who hisses and doesn't meow. - :type feline: ~multipleinheritance.models.Feline - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_feline.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(feline, "Feline") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore - - @distributed_trace_async - async def get_cat(self, **kwargs: Any) -> "_models.Cat": - """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cat, or the result of cls(response) - :rtype: ~multipleinheritance.models.Cat - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Cat"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_cat.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Cat", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore - - @distributed_trace_async - async def put_cat(self, cat: "_models.Cat", **kwargs: Any) -> str: - """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. - - :param cat: Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. - :type cat: ~multipleinheritance.models.Cat - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_cat.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(cat, "Cat") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore - - @distributed_trace_async - async def get_kitten(self, **kwargs: Any) -> "_models.Kitten": - """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet - is false. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Kitten, or the result of cls(response) - :rtype: ~multipleinheritance.models.Kitten - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Kitten"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_kitten.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Kitten", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore - - @distributed_trace_async - async def put_kitten(self, kitten: "_models.Kitten", **kwargs: Any) -> str: - """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is - true. - - :param kitten: Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and - eatsMiceYet is true. - :type kitten: ~multipleinheritance.models.Kitten - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_kitten.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(kitten, "Kitten") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py b/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py deleted file mode 100644 index 6817eba5dec..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py +++ /dev/null @@ -1,526 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class MultipleInheritanceServiceClientOperationsMixin(object): - @distributed_trace - def get_horse( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Horse" - """Get a horse with name 'Fred' and isAShowHorse true. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Horse, or the result of cls(response) - :rtype: ~multipleinheritance.models.Horse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Horse"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_horse.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Horse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore - - @distributed_trace - def put_horse( - self, - horse, # type: "_models.Horse" - **kwargs # type: Any - ): - # type: (...) -> str - """Put a horse with name 'General' and isAShowHorse false. - - :param horse: Put a horse with name 'General' and isAShowHorse false. - :type horse: ~multipleinheritance.models.Horse - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_horse.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(horse, "Horse") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore - - @distributed_trace - def get_pet( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Pet" - """Get a pet with name 'Peanut'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~multipleinheritance.models.Pet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_pet.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore - - @distributed_trace - def put_pet( - self, - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str - """Put a pet with name 'Butter'. - - :param name: - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - - _pet = _models.Pet(name=name) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_pet.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_pet, "Pet") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore - - @distributed_trace - def get_feline( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Feline" - """Get a feline where meows and hisses are true. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Feline, or the result of cls(response) - :rtype: ~multipleinheritance.models.Feline - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Feline"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_feline.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Feline", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore - - @distributed_trace - def put_feline( - self, - feline, # type: "_models.Feline" - **kwargs # type: Any - ): - # type: (...) -> str - """Put a feline who hisses and doesn't meow. - - :param feline: Put a feline who hisses and doesn't meow. - :type feline: ~multipleinheritance.models.Feline - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_feline.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(feline, "Feline") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore - - @distributed_trace - def get_cat( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Cat" - """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cat, or the result of cls(response) - :rtype: ~multipleinheritance.models.Cat - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Cat"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_cat.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Cat", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore - - @distributed_trace - def put_cat( - self, - cat, # type: "_models.Cat" - **kwargs # type: Any - ): - # type: (...) -> str - """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. - - :param cat: Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. - :type cat: ~multipleinheritance.models.Cat - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_cat.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(cat, "Cat") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore - - @distributed_trace - def get_kitten( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Kitten" - """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet - is false. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Kitten, or the result of cls(response) - :rtype: ~multipleinheritance.models.Kitten - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Kitten"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_kitten.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Kitten", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore - - @distributed_trace - def put_kitten( - self, - kitten, # type: "_models.Kitten" - **kwargs # type: Any - ): - # type: (...) -> str - """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is - true. - - :param kitten: Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and - eatsMiceYet is true. - :type kitten: ~multipleinheritance.models.Kitten - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put_kitten.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(kitten, "Kitten") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/setup.py b/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/setup.py deleted file mode 100644 index 7f6f7552e25..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "multipleinheritanceserviceclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="MultipleInheritanceServiceClient", - author_email="", - url="", - keywords=["Swagger", "MultipleInheritanceServiceClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Service client for multiinheritance client testing. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/NoOperations/setup.py b/test/vanilla/Expected/AcceptanceTests/NoOperations/setup.py deleted file mode 100644 index 67c6446168c..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NoOperations/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "nooperationsserviceclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="NoOperationsServiceClient", - author_email="", - url="", - keywords=["Swagger", "NoOperationsServiceClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Service client with no operations. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_non_string_enums_client.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_non_string_enums_client.py deleted file mode 100644 index 4d147a1bfa9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_non_string_enums_client.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import NonStringEnumsClientConfiguration -from .operations import IntOperations -from .operations import FloatOperations - - -class NonStringEnumsClient(object): - """Testing non-string enums. - - :ivar int: IntOperations operations - :vartype int: nonstringenums.operations.IntOperations - :ivar float: FloatOperations operations - :vartype float: nonstringenums.operations.FloatOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = NonStringEnumsClientConfiguration(**kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.int = IntOperations(self._client, self._config, self._serialize, self._deserialize) - self.float = FloatOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> NonStringEnumsClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_non_string_enums_client.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_non_string_enums_client.py deleted file mode 100644 index f1b14655855..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_non_string_enums_client.py +++ /dev/null @@ -1,70 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - -from ._configuration import NonStringEnumsClientConfiguration -from .operations import IntOperations -from .operations import FloatOperations - - -class NonStringEnumsClient(object): - """Testing non-string enums. - - :ivar int: IntOperations operations - :vartype int: nonstringenums.aio.operations.IntOperations - :ivar float: FloatOperations operations - :vartype float: nonstringenums.aio.operations.FloatOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = NonStringEnumsClientConfiguration(**kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.int = IntOperations(self._client, self._config, self._serialize, self._deserialize) - self.float = FloatOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "NonStringEnumsClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py deleted file mode 100644 index 4d0a61413b5..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py +++ /dev/null @@ -1,136 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class FloatOperations: - """FloatOperations 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 put(self, input: Optional[Union[float, "_models.FloatEnum"]] = None, **kwargs: Any) -> str: - """Put a float enum. - - :param input: Input float enum. - :type input: str or ~nonstringenums.models.FloatEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if input is not None: - body_content = self._serialize.body(input, "float") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/nonStringEnums/float/put"} # type: ignore - - @distributed_trace_async - async def get(self, **kwargs: Any) -> Union[float, "_models.FloatEnum"]: - """Get a float enum. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: FloatEnum, or the result of cls(response) - :rtype: str or ~nonstringenums.models.FloatEnum - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[float, "_models.FloatEnum"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/nonStringEnums/float/get"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations.py deleted file mode 100644 index 5768efe11ab..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations.py +++ /dev/null @@ -1,136 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IntOperations: - """IntOperations 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 put(self, input: Optional[Union[int, "_models.IntEnum"]] = None, **kwargs: Any) -> str: - """Put an int enum. - - :param input: Input int enum. - :type input: str or ~nonstringenums.models.IntEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if input is not None: - body_content = self._serialize.body(input, "int") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/nonStringEnums/int/put"} # type: ignore - - @distributed_trace_async - async def get(self, **kwargs: Any) -> Union[int, "_models.IntEnum"]: - """Get an int enum. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntEnum, or the result of cls(response) - :rtype: str or ~nonstringenums.models.IntEnum - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[int, "_models.IntEnum"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/nonStringEnums/int/get"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py deleted file mode 100644 index 7da92a47cb2..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py +++ /dev/null @@ -1,148 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class FloatOperations(object): - """FloatOperations 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 put( - self, - input=None, # type: Optional[Union[float, "_models.FloatEnum"]] - **kwargs # type: Any - ): - # type: (...) -> str - """Put a float enum. - - :param input: Input float enum. - :type input: str or ~nonstringenums.models.FloatEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if input is not None: - body_content = self._serialize.body(input, "float") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/nonStringEnums/float/put"} # type: ignore - - @distributed_trace - def get( - self, **kwargs # type: Any - ): - # type: (...) -> Union[float, "_models.FloatEnum"] - """Get a float enum. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: FloatEnum, or the result of cls(response) - :rtype: str or ~nonstringenums.models.FloatEnum - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[float, "_models.FloatEnum"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("float", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/nonStringEnums/float/get"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py deleted file mode 100644 index c4407b4f10d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py +++ /dev/null @@ -1,148 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class IntOperations(object): - """IntOperations 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 put( - self, - input=None, # type: Optional[Union[int, "_models.IntEnum"]] - **kwargs # type: Any - ): - # type: (...) -> str - """Put an int enum. - - :param input: Input int enum. - :type input: str or ~nonstringenums.models.IntEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[str] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if input is not None: - body_content = self._serialize.body(input, "int") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("str", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/nonStringEnums/int/put"} # type: ignore - - @distributed_trace - def get( - self, **kwargs # type: Any - ): - # type: (...) -> Union[int, "_models.IntEnum"] - """Get an int enum. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntEnum, or the result of cls(response) - :rtype: str or ~nonstringenums.models.IntEnum - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Union[int, "_models.IntEnum"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("int", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/nonStringEnums/int/get"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/setup.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/setup.py deleted file mode 100644 index f96bd5f1eff..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "nonstringenumsclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="NonStringEnumsClient", - author_email="", - url="", - keywords=["Swagger", "NonStringEnumsClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Testing non-string enums. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_object_type_client.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_object_type_client.py deleted file mode 100644 index 2bc1732f63d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_object_type_client.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ObjectTypeClientConfiguration -from .operations import ObjectTypeClientOperationsMixin - - -class ObjectTypeClient(ObjectTypeClientOperationsMixin): - """Service client for testing basic type: object swaggers. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = ObjectTypeClientConfiguration(**kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> ObjectTypeClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/_object_type_client.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/_object_type_client.py deleted file mode 100644 index f3d259a1dc6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/_object_type_client.py +++ /dev/null @@ -1,62 +0,0 @@ -# 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, Optional, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - -from ._configuration import ObjectTypeClientConfiguration -from .operations import ObjectTypeClientOperationsMixin - - -class ObjectTypeClient(ObjectTypeClientOperationsMixin): - """Service client for testing basic type: object swaggers. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = ObjectTypeClientConfiguration(**kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {} # type: Dict[str, Any] - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "ObjectTypeClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py deleted file mode 100644 index ca2fed81527..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py +++ /dev/null @@ -1,114 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ObjectTypeClientOperationsMixin: - @distributed_trace_async - async def get(self, **kwargs: Any) -> Any: - """Basic get that returns an object. Returns object { 'message': 'An object was successfully - returned' }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize("object", response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/objectType/get"} # type: ignore - - @distributed_trace_async - async def put(self, put_object: Any, **kwargs: Any) -> None: - """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an - object error. - - :param put_object: Pass in {'foo': 'bar'} for a 200, anything else for an object error. - :type put_object: any - :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/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(put_object, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize("object", response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put.metadata = {"url": "/objectType/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py deleted file mode 100644 index d928abf0241..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -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]] - - -class ObjectTypeClientOperationsMixin(object): - @distributed_trace - def get( - self, **kwargs # type: Any - ): - # type: (...) -> Any - """Basic get that returns an object. Returns object { 'message': 'An object was successfully - returned' }. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Any] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize("object", response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/objectType/get"} # type: ignore - - @distributed_trace - def put( - self, - put_object, # type: Any - **kwargs # type: Any - ): - # type: (...) -> None - """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an - object error. - - :param put_object: Pass in {'foo': 'bar'} for a 200, anything else for an object error. - :type put_object: any - :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/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(put_object, "object") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize("object", response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put.metadata = {"url": "/objectType/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/setup.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/setup.py deleted file mode 100644 index a72ce9055ca..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "objecttypeclient" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="ObjectTypeClient", - author_email="", - url="", - keywords=["Swagger", "ObjectTypeClient"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Service client for testing basic type: object swaggers. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_auto_rest_parameter_flattening.py b/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_auto_rest_parameter_flattening.py deleted file mode 100644 index fa9af75cf07..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_auto_rest_parameter_flattening.py +++ /dev/null @@ -1,79 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestParameterFlatteningConfiguration -from .operations import AvailabilitySetsOperations -from . import models - - -class AutoRestParameterFlattening(object): - """Resource Flattening for AutoRest. - - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: parameterflattening.operations.AvailabilitySetsOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestParameterFlatteningConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestParameterFlattening - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_auto_rest_parameter_flattening.py b/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_auto_rest_parameter_flattening.py deleted file mode 100644 index 8ca690ec453..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_auto_rest_parameter_flattening.py +++ /dev/null @@ -1,65 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestParameterFlatteningConfiguration -from .operations import AvailabilitySetsOperations -from .. import models - - -class AutoRestParameterFlattening(object): - """Resource Flattening for AutoRest. - - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: parameterflattening.aio.operations.AvailabilitySetsOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestParameterFlatteningConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestParameterFlattening": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py b/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py deleted file mode 100644 index c7a74bbdad3..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py +++ /dev/null @@ -1,101 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AvailabilitySetsOperations: - """AvailabilitySetsOperations 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: ~parameterflattening.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(self, resource_group_name: str, avset: str, tags: Dict[str, str], **kwargs: Any) -> None: - """Updates the tags for an availability set. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param avset: The name of the storage availability set. - :type avset: str - :param tags: A description about the set of tags. - :type tags: dict[str, 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", {})) - - _tags = _models.AvailabilitySetUpdateParameters(tags=tags) - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": self._serialize.url("avset", avset, "str", max_length=80, min_length=0), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_tags, "AvailabilitySetUpdateParameters") - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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.metadata = {"url": "/parameterFlattening/{resourceGroupName}/{availabilitySetName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py b/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py deleted file mode 100644 index 656fb1e2732..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py +++ /dev/null @@ -1,112 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations 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: ~parameterflattening.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( - self, - resource_group_name, # type: str - avset, # type: str - tags, # type: Dict[str, str] - **kwargs # type: Any - ): - # type: (...) -> None - """Updates the tags for an availability set. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param avset: The name of the storage availability set. - :type avset: str - :param tags: A description about the set of tags. - :type tags: dict[str, 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", {})) - - _tags = _models.AvailabilitySetUpdateParameters(tags=tags) - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata["url"] # type: ignore - path_format_arguments = { - "resourceGroupName": self._serialize.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": self._serialize.url("avset", avset, "str", max_length=80, min_length=0), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_tags, "AvailabilitySetUpdateParameters") - body_content_kwargs["content"] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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.metadata = {"url": "/parameterFlattening/{resourceGroupName}/{availabilitySetName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/setup.py b/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/setup.py deleted file mode 100644 index 70b6f3f5d2b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestparameterflattening" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestParameterFlattening", - author_email="", - url="", - keywords=["Swagger", "AutoRestParameterFlattening"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Resource Flattening for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/_auto_rest_report_service.py b/test/vanilla/Expected/AcceptanceTests/Report/report/_auto_rest_report_service.py deleted file mode 100644 index 65c040472e6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Report/report/_auto_rest_report_service.py +++ /dev/null @@ -1,73 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestReportServiceConfiguration -from .operations import AutoRestReportServiceOperationsMixin -from . import models - - -class AutoRestReportService(AutoRestReportServiceOperationsMixin): - """Test Infrastructure for AutoRest. - - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestReportServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestReportService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/aio/_auto_rest_report_service.py b/test/vanilla/Expected/AcceptanceTests/Report/report/aio/_auto_rest_report_service.py deleted file mode 100644 index e205625a1bc..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Report/report/aio/_auto_rest_report_service.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestReportServiceConfiguration -from .operations import AutoRestReportServiceOperationsMixin -from .. import models - - -class AutoRestReportService(AutoRestReportServiceOperationsMixin): - """Test Infrastructure for AutoRest. - - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestReportServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestReportService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py b/test/vanilla/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py deleted file mode 100644 index 07f0d7ec3cb..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py +++ /dev/null @@ -1,123 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoRestReportServiceOperationsMixin: - @distributed_trace_async - async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str, int]: - """Get test coverage report. - - :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in - for Python). The only effect is, that generators that run all tests several times, can - distinguish the generated reports. - :type qualifier: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_report.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if qualifier is not None: - query_parameters["qualifier"] = self._serialize.query("qualifier", qualifier, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_report.metadata = {"url": "/report"} # type: ignore - - @distributed_trace_async - async def get_optional_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str, int]: - """Get optional test coverage report. - - :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in - for Python). The only effect is, that generators that run all tests several times, can - distinguish the generated reports. - :type qualifier: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_optional_report.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if qualifier is not None: - query_parameters["qualifier"] = self._serialize.query("qualifier", qualifier, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_optional_report.metadata = {"url": "/report/optional"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py b/test/vanilla/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py deleted file mode 100644 index 755ae7b9192..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class AutoRestReportServiceOperationsMixin(object): - @distributed_trace - def get_report( - self, - qualifier=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get test coverage report. - - :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in - for Python). The only effect is, that generators that run all tests several times, can - distinguish the generated reports. - :type qualifier: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_report.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if qualifier is not None: - query_parameters["qualifier"] = self._serialize.query("qualifier", qualifier, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_report.metadata = {"url": "/report"} # type: ignore - - @distributed_trace - def get_optional_report( - self, - qualifier=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Dict[str, int] - """Get optional test coverage report. - - :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in - for Python). The only effect is, that generators that run all tests several times, can - distinguish the generated reports. - :type qualifier: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to int, or the result of cls(response) - :rtype: dict[str, int] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_optional_report.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if qualifier is not None: - query_parameters["qualifier"] = self._serialize.query("qualifier", qualifier, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("{int}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_optional_report.metadata = {"url": "/report/optional"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Report/setup.py b/test/vanilla/Expected/AcceptanceTests/Report/setup.py deleted file mode 100644 index fa742b73373..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Report/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestreportservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestReportService", - author_email="", - url="", - keywords=["Swagger", "AutoRestReportService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_auto_rest_required_optional_test_service.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_auto_rest_required_optional_test_service.py deleted file mode 100644 index b1f82bb9a76..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_auto_rest_required_optional_test_service.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestRequiredOptionalTestServiceConfiguration -from .operations import ImplicitOperations -from .operations import ExplicitOperations -from . import models - - -class AutoRestRequiredOptionalTestService(object): - """Test Infrastructure for AutoRest. - - :ivar implicit: ImplicitOperations operations - :vartype implicit: requiredoptional.operations.ImplicitOperations - :ivar explicit: ExplicitOperations operations - :vartype explicit: requiredoptional.operations.ExplicitOperations - :param required_global_path: number of items to skip. - :type required_global_path: str - :param required_global_query: number of items to skip. - :type required_global_query: str - :param optional_global_query: number of items to skip. - :type optional_global_query: int - :param str base_url: Service URL - """ - - def __init__( - self, - required_global_path, # type: str - required_global_query, # type: str - optional_global_query=None, # type: Optional[int] - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestRequiredOptionalTestServiceConfiguration( - required_global_path, required_global_query, optional_global_query, **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.implicit = ImplicitOperations(self._client, self._config, self._serialize, self._deserialize) - self.explicit = ExplicitOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "required-global-path": self._serialize.url( - "self._config.required_global_path", self._config.required_global_path, "str" - ), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestRequiredOptionalTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_auto_rest_required_optional_test_service.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_auto_rest_required_optional_test_service.py deleted file mode 100644 index 00204417b08..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_auto_rest_required_optional_test_service.py +++ /dev/null @@ -1,86 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestRequiredOptionalTestServiceConfiguration -from .operations import ImplicitOperations -from .operations import ExplicitOperations -from .. import models - - -class AutoRestRequiredOptionalTestService(object): - """Test Infrastructure for AutoRest. - - :ivar implicit: ImplicitOperations operations - :vartype implicit: requiredoptional.aio.operations.ImplicitOperations - :ivar explicit: ExplicitOperations operations - :vartype explicit: requiredoptional.aio.operations.ExplicitOperations - :param required_global_path: number of items to skip. - :type required_global_path: str - :param required_global_query: number of items to skip. - :type required_global_query: str - :param optional_global_query: number of items to skip. - :type optional_global_query: int - :param str base_url: Service URL - """ - - def __init__( - self, - required_global_path: str, - required_global_query: str, - optional_global_query: Optional[int] = None, - base_url: Optional[str] = None, - **kwargs: Any - ) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestRequiredOptionalTestServiceConfiguration( - required_global_path, required_global_query, optional_global_query, **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.implicit = ImplicitOperations(self._client, self._config, self._serialize, self._deserialize) - self.explicit = ExplicitOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "required-global-path": self._serialize.url( - "self._config.required_global_path", self._config.required_global_path, "str" - ), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestRequiredOptionalTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py deleted file mode 100644 index e256d013621..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py +++ /dev/null @@ -1,1162 +0,0 @@ -# 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, Callable, Dict, Generic, IO, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ExplicitOperations: - """ExplicitOperations 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: ~requiredoptional.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 put_optional_binary_body(self, body_parameter: Optional[IO] = None, **kwargs: Any) -> None: - """Test explicitly optional body parameter. - - :param body_parameter: - :type body_parameter: IO - :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/octet-stream") - accept = "application/json" - - # Construct URL - url = self.put_optional_binary_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = body_parameter - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_binary_body.metadata = {"url": "/reqopt/explicit/optional/binary-body"} # type: ignore - - @distributed_trace_async - async def put_required_binary_body(self, body_parameter: IO, **kwargs: Any) -> None: - """Test explicitly required body parameter. - - :param body_parameter: - :type body_parameter: IO - :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/octet-stream") - accept = "application/json" - - # Construct URL - url = self.put_required_binary_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = body_parameter - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_required_binary_body.metadata = {"url": "/reqopt/explicit/required/binary-body"} # type: ignore - - @distributed_trace_async - async def post_required_integer_parameter(self, body_parameter: int, **kwargs: Any) -> None: - """Test explicitly required integer. Please put null and the client library should throw before - the request is sent. - - :param body_parameter: - :type body_parameter: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_integer_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "int") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_integer_parameter.metadata = {"url": "/reqopt/requied/integer/parameter"} # type: ignore - - @distributed_trace_async - async def post_optional_integer_parameter(self, body_parameter: Optional[int] = None, **kwargs: Any) -> None: - """Test explicitly optional integer. Please put null. - - :param body_parameter: - :type body_parameter: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_integer_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "int") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_integer_parameter.metadata = {"url": "/reqopt/optional/integer/parameter"} # type: ignore - - @distributed_trace_async - async def post_required_integer_property(self, value: int, **kwargs: Any) -> None: - """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the - client library should throw before the request is sent. - - :param value: - :type value: int - :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", {})) - - _body_parameter = _models.IntWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_integer_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "IntWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_integer_property.metadata = {"url": "/reqopt/requied/integer/property"} # type: ignore - - @distributed_trace_async - async def post_optional_integer_property(self, value: Optional[int] = None, **kwargs: Any) -> None: - """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. - - :param value: - :type value: int - :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", {})) - - _body_parameter = _models.IntOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_integer_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "IntOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_integer_property.metadata = {"url": "/reqopt/optional/integer/property"} # type: ignore - - @distributed_trace_async - async def post_required_integer_header(self, header_parameter: int, **kwargs: Any) -> None: - """Test explicitly required integer. Please put a header 'headerParameter' => null and the client - library should throw before the request is sent. - - :param header_parameter: - :type header_parameter: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_required_integer_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["headerParameter"] = self._serialize.header("header_parameter", header_parameter, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_integer_header.metadata = {"url": "/reqopt/requied/integer/header"} # type: ignore - - @distributed_trace_async - async def post_optional_integer_header(self, header_parameter: Optional[int] = None, **kwargs: Any) -> None: - """Test explicitly optional integer. Please put a header 'headerParameter' => null. - - :param header_parameter: - :type header_parameter: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_optional_integer_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if header_parameter is not None: - header_parameters["headerParameter"] = self._serialize.header("header_parameter", header_parameter, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_integer_header.metadata = {"url": "/reqopt/optional/integer/header"} # type: ignore - - @distributed_trace_async - async def post_required_string_parameter(self, body_parameter: str, **kwargs: Any) -> None: - """Test explicitly required string. Please put null and the client library should throw before the - request is sent. - - :param body_parameter: - :type body_parameter: 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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_string_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "str") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_string_parameter.metadata = {"url": "/reqopt/requied/string/parameter"} # type: ignore - - @distributed_trace_async - async def post_optional_string_parameter(self, body_parameter: Optional[str] = None, **kwargs: Any) -> None: - """Test explicitly optional string. Please put null. - - :param body_parameter: - :type body_parameter: 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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_string_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_string_parameter.metadata = {"url": "/reqopt/optional/string/parameter"} # type: ignore - - @distributed_trace_async - async def post_required_string_property(self, value: str, **kwargs: Any) -> None: - """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the - client library should throw before the request is sent. - - :param value: - :type value: 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", {})) - - _body_parameter = _models.StringWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_string_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "StringWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_string_property.metadata = {"url": "/reqopt/requied/string/property"} # type: ignore - - @distributed_trace_async - async def post_optional_string_property(self, value: Optional[str] = None, **kwargs: Any) -> None: - """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. - - :param value: - :type value: 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", {})) - - _body_parameter = _models.StringOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_string_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "StringOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_string_property.metadata = {"url": "/reqopt/optional/string/property"} # type: ignore - - @distributed_trace_async - async def post_required_string_header(self, header_parameter: str, **kwargs: Any) -> None: - """Test explicitly required string. Please put a header 'headerParameter' => null and the client - library should throw before the request is sent. - - :param header_parameter: - :type header_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_required_string_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["headerParameter"] = self._serialize.header("header_parameter", header_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_string_header.metadata = {"url": "/reqopt/requied/string/header"} # type: ignore - - @distributed_trace_async - async def post_optional_string_header(self, body_parameter: Optional[str] = None, **kwargs: Any) -> None: - """Test explicitly optional string. Please put a header 'headerParameter' => null. - - :param body_parameter: - :type body_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_optional_string_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if body_parameter is not None: - header_parameters["bodyParameter"] = self._serialize.header("body_parameter", body_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_string_header.metadata = {"url": "/reqopt/optional/string/header"} # type: ignore - - @distributed_trace_async - async def post_required_class_parameter(self, body_parameter: "_models.Product", **kwargs: Any) -> None: - """Test explicitly required complex object. Please put null and the client library should throw - before the request is sent. - - :param body_parameter: - :type body_parameter: ~requiredoptional.models.Product - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_class_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "Product") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_class_parameter.metadata = {"url": "/reqopt/requied/class/parameter"} # type: ignore - - @distributed_trace_async - async def post_optional_class_parameter( - self, body_parameter: Optional["_models.Product"] = None, **kwargs: Any - ) -> None: - """Test explicitly optional complex object. Please put null. - - :param body_parameter: - :type body_parameter: ~requiredoptional.models.Product - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_class_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_class_parameter.metadata = {"url": "/reqopt/optional/class/parameter"} # type: ignore - - @distributed_trace_async - async def post_required_class_property(self, value: "_models.Product", **kwargs: Any) -> None: - """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null - and the client library should throw before the request is sent. - - :param value: - :type value: ~requiredoptional.models.Product - :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", {})) - - _body_parameter = _models.ClassWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_class_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "ClassWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_class_property.metadata = {"url": "/reqopt/requied/class/property"} # type: ignore - - @distributed_trace_async - async def post_optional_class_property(self, value: Optional["_models.Product"] = None, **kwargs: Any) -> None: - """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. - - :param value: - :type value: ~requiredoptional.models.Product - :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", {})) - - _body_parameter = _models.ClassOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_class_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "ClassOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_class_property.metadata = {"url": "/reqopt/optional/class/property"} # type: ignore - - @distributed_trace_async - async def post_required_array_parameter(self, body_parameter: List[str], **kwargs: Any) -> None: - """Test explicitly required array. Please put null and the client library should throw before the - request is sent. - - :param body_parameter: - :type body_parameter: list[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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_array_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_array_parameter.metadata = {"url": "/reqopt/requied/array/parameter"} # type: ignore - - @distributed_trace_async - async def post_optional_array_parameter(self, body_parameter: Optional[List[str]] = None, **kwargs: Any) -> None: - """Test explicitly optional array. Please put null. - - :param body_parameter: - :type body_parameter: list[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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_array_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "[str]") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_array_parameter.metadata = {"url": "/reqopt/optional/array/parameter"} # type: ignore - - @distributed_trace_async - async def post_required_array_property(self, value: List[str], **kwargs: Any) -> None: - """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the - client library should throw before the request is sent. - - :param value: - :type value: list[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", {})) - - _body_parameter = _models.ArrayWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_array_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "ArrayWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_array_property.metadata = {"url": "/reqopt/requied/array/property"} # type: ignore - - @distributed_trace_async - async def post_optional_array_property(self, value: Optional[List[str]] = None, **kwargs: Any) -> None: - """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. - - :param value: - :type value: list[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", {})) - - _body_parameter = _models.ArrayOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_array_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "ArrayOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_array_property.metadata = {"url": "/reqopt/optional/array/property"} # type: ignore - - @distributed_trace_async - async def post_required_array_header(self, header_parameter: List[str], **kwargs: Any) -> None: - """Test explicitly required array. Please put a header 'headerParameter' => null and the client - library should throw before the request is sent. - - :param header_parameter: - :type header_parameter: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.post_required_array_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["headerParameter"] = self._serialize.header( - "header_parameter", header_parameter, "[str]", div="," - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_array_header.metadata = {"url": "/reqopt/requied/array/header"} # type: ignore - - @distributed_trace_async - async def post_optional_array_header(self, header_parameter: Optional[List[str]] = None, **kwargs: Any) -> None: - """Test explicitly optional integer. Please put a header 'headerParameter' => null. - - :param header_parameter: - :type header_parameter: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.post_optional_array_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if header_parameter is not None: - header_parameters["headerParameter"] = self._serialize.header( - "header_parameter", header_parameter, "[str]", div="," - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_array_header.metadata = {"url": "/reqopt/optional/array/header"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py deleted file mode 100644 index 84f11510fa4..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py +++ /dev/null @@ -1,395 +0,0 @@ -# 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, Callable, Dict, Generic, IO, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ImplicitOperations: - """ImplicitOperations 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: ~requiredoptional.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 get_required_path(self, path_parameter: str, **kwargs: Any) -> None: - """Test implicitly required path parameter. - - :param path_parameter: - :type path_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_required_path.metadata["url"] # type: ignore - path_format_arguments = { - "pathParameter": self._serialize.url("path_parameter", path_parameter, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_required_path.metadata = {"url": "/reqopt/implicit/required/path/{pathParameter}"} # type: ignore - - @distributed_trace_async - async def put_optional_query(self, query_parameter: Optional[str] = None, **kwargs: Any) -> None: - """Test implicitly optional query parameter. - - :param query_parameter: - :type query_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.put_optional_query.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if query_parameter is not None: - query_parameters["queryParameter"] = self._serialize.query("query_parameter", query_parameter, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_query.metadata = {"url": "/reqopt/implicit/optional/query"} # type: ignore - - @distributed_trace_async - async def put_optional_header(self, query_parameter: Optional[str] = None, **kwargs: Any) -> None: - """Test implicitly optional header parameter. - - :param query_parameter: - :type query_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.put_optional_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if query_parameter is not None: - header_parameters["queryParameter"] = self._serialize.header("query_parameter", query_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_header.metadata = {"url": "/reqopt/implicit/optional/header"} # type: ignore - - @distributed_trace_async - async def put_optional_body(self, body_parameter: Optional[str] = None, **kwargs: Any) -> None: - """Test implicitly optional body parameter. - - :param body_parameter: - :type body_parameter: 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/json") - accept = "application/json" - - # Construct URL - url = self.put_optional_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_body.metadata = {"url": "/reqopt/implicit/optional/body"} # type: ignore - - @distributed_trace_async - async def put_optional_binary_body(self, body_parameter: Optional[IO] = None, **kwargs: Any) -> None: - """Test implicitly optional body parameter. - - :param body_parameter: - :type body_parameter: IO - :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/octet-stream") - accept = "application/json" - - # Construct URL - url = self.put_optional_binary_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = body_parameter - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_binary_body.metadata = {"url": "/reqopt/implicit/optional/binary-body"} # type: ignore - - @distributed_trace_async - async def get_required_global_path(self, **kwargs: Any) -> None: - """Test implicitly required path parameter. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_required_global_path.metadata["url"] # type: ignore - path_format_arguments = { - "required-global-path": self._serialize.url( - "self._config.required_global_path", self._config.required_global_path, "str" - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_required_global_path.metadata = {"url": "/reqopt/global/required/path/{required-global-path}"} # type: ignore - - @distributed_trace_async - async def get_required_global_query(self, **kwargs: Any) -> None: - """Test implicitly required query parameter. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_required_global_query.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["required-global-query"] = self._serialize.query( - "self._config.required_global_query", self._config.required_global_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_required_global_query.metadata = {"url": "/reqopt/global/required/query"} # type: ignore - - @distributed_trace_async - async def get_optional_global_query(self, **kwargs: Any) -> None: - """Test implicitly optional query parameter. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_optional_global_query.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if self._config.optional_global_query is not None: - query_parameters["optional-global-query"] = self._serialize.query( - "self._config.optional_global_query", self._config.optional_global_query, "int" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_optional_global_query.metadata = {"url": "/reqopt/global/optional/query"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py deleted file mode 100644 index 1f6a636fd98..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py +++ /dev/null @@ -1,1284 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class ExplicitOperations(object): - """ExplicitOperations 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: ~requiredoptional.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 put_optional_binary_body( - self, - body_parameter=None, # type: Optional[IO] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional body parameter. - - :param body_parameter: - :type body_parameter: IO - :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/octet-stream") - accept = "application/json" - - # Construct URL - url = self.put_optional_binary_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = body_parameter - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_binary_body.metadata = {"url": "/reqopt/explicit/optional/binary-body"} # type: ignore - - @distributed_trace - def put_required_binary_body( - self, - body_parameter, # type: IO - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required body parameter. - - :param body_parameter: - :type body_parameter: IO - :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/octet-stream") - accept = "application/json" - - # Construct URL - url = self.put_required_binary_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = body_parameter - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_required_binary_body.metadata = {"url": "/reqopt/explicit/required/binary-body"} # type: ignore - - @distributed_trace - def post_required_integer_parameter( - self, - body_parameter, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required integer. Please put null and the client library should throw before - the request is sent. - - :param body_parameter: - :type body_parameter: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_integer_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "int") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_integer_parameter.metadata = {"url": "/reqopt/requied/integer/parameter"} # type: ignore - - @distributed_trace - def post_optional_integer_parameter( - self, - body_parameter=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional integer. Please put null. - - :param body_parameter: - :type body_parameter: int - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_integer_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "int") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_integer_parameter.metadata = {"url": "/reqopt/optional/integer/parameter"} # type: ignore - - @distributed_trace - def post_required_integer_property( - self, - value, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the - client library should throw before the request is sent. - - :param value: - :type value: int - :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", {})) - - _body_parameter = _models.IntWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_integer_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "IntWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_integer_property.metadata = {"url": "/reqopt/requied/integer/property"} # type: ignore - - @distributed_trace - def post_optional_integer_property( - self, - value=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. - - :param value: - :type value: int - :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", {})) - - _body_parameter = _models.IntOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_integer_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "IntOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_integer_property.metadata = {"url": "/reqopt/optional/integer/property"} # type: ignore - - @distributed_trace - def post_required_integer_header( - self, - header_parameter, # type: int - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required integer. Please put a header 'headerParameter' => null and the client - library should throw before the request is sent. - - :param header_parameter: - :type header_parameter: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_required_integer_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["headerParameter"] = self._serialize.header("header_parameter", header_parameter, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_integer_header.metadata = {"url": "/reqopt/requied/integer/header"} # type: ignore - - @distributed_trace - def post_optional_integer_header( - self, - header_parameter=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional integer. Please put a header 'headerParameter' => null. - - :param header_parameter: - :type header_parameter: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.post_optional_integer_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if header_parameter is not None: - header_parameters["headerParameter"] = self._serialize.header("header_parameter", header_parameter, "int") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_integer_header.metadata = {"url": "/reqopt/optional/integer/header"} # type: ignore - - @distributed_trace - def post_required_string_parameter( - self, - body_parameter, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required string. Please put null and the client library should throw before the - request is sent. - - :param body_parameter: - :type body_parameter: 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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_string_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "str") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_string_parameter.metadata = {"url": "/reqopt/requied/string/parameter"} # type: ignore - - @distributed_trace - def post_optional_string_parameter( - self, - body_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional string. Please put null. - - :param body_parameter: - :type body_parameter: 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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_string_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_string_parameter.metadata = {"url": "/reqopt/optional/string/parameter"} # type: ignore - - @distributed_trace - def post_required_string_property( - self, - value, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the - client library should throw before the request is sent. - - :param value: - :type value: 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", {})) - - _body_parameter = _models.StringWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_string_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "StringWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_string_property.metadata = {"url": "/reqopt/requied/string/property"} # type: ignore - - @distributed_trace - def post_optional_string_property( - self, - value=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. - - :param value: - :type value: 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", {})) - - _body_parameter = _models.StringOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_string_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "StringOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_string_property.metadata = {"url": "/reqopt/optional/string/property"} # type: ignore - - @distributed_trace - def post_required_string_header( - self, - header_parameter, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required string. Please put a header 'headerParameter' => null and the client - library should throw before the request is sent. - - :param header_parameter: - :type header_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_required_string_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["headerParameter"] = self._serialize.header("header_parameter", header_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_string_header.metadata = {"url": "/reqopt/requied/string/header"} # type: ignore - - @distributed_trace - def post_optional_string_header( - self, - body_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional string. Please put a header 'headerParameter' => null. - - :param body_parameter: - :type body_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.post_optional_string_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if body_parameter is not None: - header_parameters["bodyParameter"] = self._serialize.header("body_parameter", body_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_string_header.metadata = {"url": "/reqopt/optional/string/header"} # type: ignore - - @distributed_trace - def post_required_class_parameter( - self, - body_parameter, # type: "_models.Product" - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required complex object. Please put null and the client library should throw - before the request is sent. - - :param body_parameter: - :type body_parameter: ~requiredoptional.models.Product - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_class_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "Product") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_class_parameter.metadata = {"url": "/reqopt/requied/class/parameter"} # type: ignore - - @distributed_trace - def post_optional_class_parameter( - self, - body_parameter=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional complex object. Please put null. - - :param body_parameter: - :type body_parameter: ~requiredoptional.models.Product - :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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_class_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_class_parameter.metadata = {"url": "/reqopt/optional/class/parameter"} # type: ignore - - @distributed_trace - def post_required_class_property( - self, - value, # type: "_models.Product" - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null - and the client library should throw before the request is sent. - - :param value: - :type value: ~requiredoptional.models.Product - :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", {})) - - _body_parameter = _models.ClassWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_class_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "ClassWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_class_property.metadata = {"url": "/reqopt/requied/class/property"} # type: ignore - - @distributed_trace - def post_optional_class_property( - self, - value=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. - - :param value: - :type value: ~requiredoptional.models.Product - :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", {})) - - _body_parameter = _models.ClassOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_class_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "ClassOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_class_property.metadata = {"url": "/reqopt/optional/class/property"} # type: ignore - - @distributed_trace - def post_required_array_parameter( - self, - body_parameter, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required array. Please put null and the client library should throw before the - request is sent. - - :param body_parameter: - :type body_parameter: list[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/json") - accept = "application/json" - - # Construct URL - url = self.post_required_array_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body_parameter, "[str]") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_array_parameter.metadata = {"url": "/reqopt/requied/array/parameter"} # type: ignore - - @distributed_trace - def post_optional_array_parameter( - self, - body_parameter=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional array. Please put null. - - :param body_parameter: - :type body_parameter: list[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/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_array_parameter.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "[str]") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_array_parameter.metadata = {"url": "/reqopt/optional/array/parameter"} # type: ignore - - @distributed_trace - def post_required_array_property( - self, - value, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the - client library should throw before the request is sent. - - :param value: - :type value: list[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", {})) - - _body_parameter = _models.ArrayWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_required_array_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body_parameter, "ArrayWrapper") - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_array_property.metadata = {"url": "/reqopt/requied/array/property"} # type: ignore - - @distributed_trace - def post_optional_array_property( - self, - value=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. - - :param value: - :type value: list[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", {})) - - _body_parameter = _models.ArrayOptionalWrapper(value=value) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_optional_array_property.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if _body_parameter is not None: - body_content = self._serialize.body(_body_parameter, "ArrayOptionalWrapper") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_array_property.metadata = {"url": "/reqopt/optional/array/property"} # type: ignore - - @distributed_trace - def post_required_array_header( - self, - header_parameter, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly required array. Please put a header 'headerParameter' => null and the client - library should throw before the request is sent. - - :param header_parameter: - :type header_parameter: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.post_required_array_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["headerParameter"] = self._serialize.header( - "header_parameter", header_parameter, "[str]", div="," - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_required_array_header.metadata = {"url": "/reqopt/requied/array/header"} # type: ignore - - @distributed_trace - def post_optional_array_header( - self, - header_parameter=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Test explicitly optional integer. Please put a header 'headerParameter' => null. - - :param header_parameter: - :type header_parameter: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.post_optional_array_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if header_parameter is not None: - header_parameters["headerParameter"] = self._serialize.header( - "header_parameter", header_parameter, "[str]", div="," - ) - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - post_optional_array_header.metadata = {"url": "/reqopt/optional/array/header"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py deleted file mode 100644 index 093d433caf9..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py +++ /dev/null @@ -1,433 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class ImplicitOperations(object): - """ImplicitOperations 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: ~requiredoptional.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 get_required_path( - self, - path_parameter, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly required path parameter. - - :param path_parameter: - :type path_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_required_path.metadata["url"] # type: ignore - path_format_arguments = { - "pathParameter": self._serialize.url("path_parameter", path_parameter, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_required_path.metadata = {"url": "/reqopt/implicit/required/path/{pathParameter}"} # type: ignore - - @distributed_trace - def put_optional_query( - self, - query_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly optional query parameter. - - :param query_parameter: - :type query_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.put_optional_query.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if query_parameter is not None: - query_parameters["queryParameter"] = self._serialize.query("query_parameter", query_parameter, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_query.metadata = {"url": "/reqopt/implicit/optional/query"} # type: ignore - - @distributed_trace - def put_optional_header( - self, - query_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly optional header parameter. - - :param query_parameter: - :type query_parameter: 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", {})) - accept = "application/json" - - # Construct URL - url = self.put_optional_header.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if query_parameter is not None: - header_parameters["queryParameter"] = self._serialize.header("query_parameter", query_parameter, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_header.metadata = {"url": "/reqopt/implicit/optional/header"} # type: ignore - - @distributed_trace - def put_optional_body( - self, - body_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly optional body parameter. - - :param body_parameter: - :type body_parameter: 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/json") - accept = "application/json" - - # Construct URL - url = self.put_optional_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body_parameter is not None: - body_content = self._serialize.body(body_parameter, "str") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_body.metadata = {"url": "/reqopt/implicit/optional/body"} # type: ignore - - @distributed_trace - def put_optional_binary_body( - self, - body_parameter=None, # type: Optional[IO] - **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly optional body parameter. - - :param body_parameter: - :type body_parameter: IO - :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/octet-stream") - accept = "application/json" - - # Construct URL - url = self.put_optional_binary_body.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content_kwargs["stream_content"] = body_parameter - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_optional_binary_body.metadata = {"url": "/reqopt/implicit/optional/binary-body"} # type: ignore - - @distributed_trace - def get_required_global_path( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly required path parameter. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_required_global_path.metadata["url"] # type: ignore - path_format_arguments = { - "required-global-path": self._serialize.url( - "self._config.required_global_path", self._config.required_global_path, "str" - ), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_required_global_path.metadata = {"url": "/reqopt/global/required/path/{required-global-path}"} # type: ignore - - @distributed_trace - def get_required_global_query( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly required query parameter. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_required_global_query.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["required-global-query"] = self._serialize.query( - "self._config.required_global_query", self._config.required_global_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_required_global_query.metadata = {"url": "/reqopt/global/required/query"} # type: ignore - - @distributed_trace - def get_optional_global_query( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Test implicitly optional query parameter. - - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_optional_global_query.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if self._config.optional_global_query is not None: - query_parameters["optional-global-query"] = self._serialize.query( - "self._config.optional_global_query", self._config.optional_global_query, "int" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_optional_global_query.metadata = {"url": "/reqopt/global/optional/query"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/setup.py b/test/vanilla/Expected/AcceptanceTests/RequiredOptional/setup.py deleted file mode 100644 index aa9c7153540..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestrequiredoptionaltestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestRequiredOptionalTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestRequiredOptionalTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/setup.py b/test/vanilla/Expected/AcceptanceTests/Url/setup.py deleted file mode 100644 index 7ee4a52370b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autoresturltestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestUrlTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestUrlTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/_auto_rest_url_test_service.py b/test/vanilla/Expected/AcceptanceTests/Url/url/_auto_rest_url_test_service.py deleted file mode 100644 index 2c56f13d036..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/_auto_rest_url_test_service.py +++ /dev/null @@ -1,95 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestUrlTestServiceConfiguration -from .operations import PathsOperations -from .operations import QueriesOperations -from .operations import PathItemsOperations -from . import models - - -class AutoRestUrlTestService(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: url.operations.PathsOperations - :ivar queries: QueriesOperations operations - :vartype queries: url.operations.QueriesOperations - :ivar path_items: PathItemsOperations operations - :vartype path_items: url.operations.PathItemsOperations - :param global_string_path: A string value 'globalItemStringPath' that appears in the path. - :type global_string_path: str - :param global_string_query: should contain value null. - :type global_string_query: str - :param str base_url: Service URL - """ - - def __init__( - self, - global_string_path, # type: str - global_string_query=None, # type: Optional[str] - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.path_items = PathItemsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestUrlTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/_auto_rest_url_test_service.py b/test/vanilla/Expected/AcceptanceTests/Url/url/aio/_auto_rest_url_test_service.py deleted file mode 100644 index 26b3644c07e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/_auto_rest_url_test_service.py +++ /dev/null @@ -1,85 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestUrlTestServiceConfiguration -from .operations import PathsOperations -from .operations import QueriesOperations -from .operations import PathItemsOperations -from .. import models - - -class AutoRestUrlTestService(object): - """Test Infrastructure for AutoRest. - - :ivar paths: PathsOperations operations - :vartype paths: url.aio.operations.PathsOperations - :ivar queries: QueriesOperations operations - :vartype queries: url.aio.operations.QueriesOperations - :ivar path_items: PathItemsOperations operations - :vartype path_items: url.aio.operations.PathItemsOperations - :param global_string_path: A string value 'globalItemStringPath' that appears in the path. - :type global_string_path: str - :param global_string_query: should contain value null. - :type global_string_query: str - :param str base_url: Service URL - """ - - def __init__( - self, - global_string_path: str, - global_string_query: Optional[str] = None, - base_url: Optional[str] = None, - **kwargs: Any - ) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) - self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.path_items = PathItemsOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestUrlTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py b/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py deleted file mode 100644 index 0f4eadf9fbf..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py +++ /dev/null @@ -1,351 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PathItemsOperations: - """PathItemsOperations 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: ~url.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 get_all_with_values( - self, - path_item_string_path: str, - local_string_path: str, - path_item_string_query: Optional[str] = None, - local_string_query: Optional[str] = None, - **kwargs: Any - ) -> None: - """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery='globalStringQuery', - pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query - parameter. - :type path_item_string_query: str - :param local_string_query: should contain value 'localStringQuery'. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_all_with_values.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_all_with_values.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery"} # type: ignore - - @distributed_trace_async - async def get_global_query_null( - self, - path_item_string_path: str, - local_string_path: str, - path_item_string_query: Optional[str] = None, - local_string_query: Optional[str] = None, - **kwargs: Any - ) -> None: - """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery=null, - pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query - parameter. - :type path_item_string_query: str - :param local_string_query: should contain value 'localStringQuery'. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_global_query_null.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_global_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery"} # type: ignore - - @distributed_trace_async - async def get_global_and_local_query_null( - self, - path_item_string_path: str, - local_string_path: str, - path_item_string_query: Optional[str] = None, - local_string_query: Optional[str] = None, - **kwargs: Any - ) -> None: - """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery=null, - pathItemStringQuery='pathItemStringQuery', localStringQuery=null. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query - parameter. - :type path_item_string_query: str - :param local_string_query: should contain null value. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_global_and_local_query_null.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_global_and_local_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null"} # type: ignore - - @distributed_trace_async - async def get_local_path_item_query_null( - self, - path_item_string_path: str, - local_string_path: str, - path_item_string_query: Optional[str] = None, - local_string_query: Optional[str] = None, - **kwargs: Any - ) -> None: - """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery='globalStringQuery', - pathItemStringQuery=null, localStringQuery=null. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: should contain value null. - :type path_item_string_query: str - :param local_string_query: should contain value null. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_path_item_query_null.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_local_path_item_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py b/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py deleted file mode 100644 index 55db702e39f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py +++ /dev/null @@ -1,1225 +0,0 @@ -# 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 datetime -from typing import Any, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PathsOperations: - """PathsOperations 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: ~url.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 get_boolean_true(self, **kwargs: Any) -> None: - """Get true Boolean value on path. - - :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", {})) - bool_path = True - accept = "application/json" - - # Construct URL - url = self.get_boolean_true.metadata["url"] # type: ignore - path_format_arguments = { - "boolPath": self._serialize.url("bool_path", bool_path, "bool"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_true.metadata = {"url": "/paths/bool/true/{boolPath}"} # type: ignore - - @distributed_trace_async - async def get_boolean_false(self, **kwargs: Any) -> None: - """Get false Boolean value on path. - - :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", {})) - bool_path = False - accept = "application/json" - - # Construct URL - url = self.get_boolean_false.metadata["url"] # type: ignore - path_format_arguments = { - "boolPath": self._serialize.url("bool_path", bool_path, "bool"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_false.metadata = {"url": "/paths/bool/false/{boolPath}"} # type: ignore - - @distributed_trace_async - async def get_int_one_million(self, **kwargs: Any) -> None: - """Get '1000000' integer value. - - :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", {})) - int_path = 1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_one_million.metadata["url"] # type: ignore - path_format_arguments = { - "intPath": self._serialize.url("int_path", int_path, "int"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_one_million.metadata = {"url": "/paths/int/1000000/{intPath}"} # type: ignore - - @distributed_trace_async - async def get_int_negative_one_million(self, **kwargs: Any) -> None: - """Get '-1000000' integer value. - - :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", {})) - int_path = -1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_negative_one_million.metadata["url"] # type: ignore - path_format_arguments = { - "intPath": self._serialize.url("int_path", int_path, "int"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_negative_one_million.metadata = {"url": "/paths/int/-1000000/{intPath}"} # type: ignore - - @distributed_trace_async - async def get_ten_billion(self, **kwargs: Any) -> None: - """Get '10000000000' 64 bit integer value. - - :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", {})) - long_path = 10000000000 - accept = "application/json" - - # Construct URL - url = self.get_ten_billion.metadata["url"] # type: ignore - path_format_arguments = { - "longPath": self._serialize.url("long_path", long_path, "long"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_ten_billion.metadata = {"url": "/paths/long/10000000000/{longPath}"} # type: ignore - - @distributed_trace_async - async def get_negative_ten_billion(self, **kwargs: Any) -> None: - """Get '-10000000000' 64 bit integer value. - - :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", {})) - long_path = -10000000000 - accept = "application/json" - - # Construct URL - url = self.get_negative_ten_billion.metadata["url"] # type: ignore - path_format_arguments = { - "longPath": self._serialize.url("long_path", long_path, "long"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_negative_ten_billion.metadata = {"url": "/paths/long/-10000000000/{longPath}"} # type: ignore - - @distributed_trace_async - async def float_scientific_positive(self, **kwargs: Any) -> None: - """Get '1.034E+20' numeric value. - - :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", {})) - float_path = 103400000000000000000 - accept = "application/json" - - # Construct URL - url = self.float_scientific_positive.metadata["url"] # type: ignore - path_format_arguments = { - "floatPath": self._serialize.url("float_path", float_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_positive.metadata = {"url": "/paths/float/1.034E+20/{floatPath}"} # type: ignore - - @distributed_trace_async - async def float_scientific_negative(self, **kwargs: Any) -> None: - """Get '-1.034E-20' numeric value. - - :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", {})) - float_path = -1.034e-20 - accept = "application/json" - - # Construct URL - url = self.float_scientific_negative.metadata["url"] # type: ignore - path_format_arguments = { - "floatPath": self._serialize.url("float_path", float_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_negative.metadata = {"url": "/paths/float/-1.034E-20/{floatPath}"} # type: ignore - - @distributed_trace_async - async def double_decimal_positive(self, **kwargs: Any) -> None: - """Get '9999999.999' numeric value. - - :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", {})) - double_path = 9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_positive.metadata["url"] # type: ignore - path_format_arguments = { - "doublePath": self._serialize.url("double_path", double_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_positive.metadata = {"url": "/paths/double/9999999.999/{doublePath}"} # type: ignore - - @distributed_trace_async - async def double_decimal_negative(self, **kwargs: Any) -> None: - """Get '-9999999.999' numeric value. - - :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", {})) - double_path = -9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_negative.metadata["url"] # type: ignore - path_format_arguments = { - "doublePath": self._serialize.url("double_path", double_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_negative.metadata = {"url": "/paths/double/-9999999.999/{doublePath}"} # type: ignore - - @distributed_trace_async - async def string_unicode(self, **kwargs: Any) -> None: - """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. - - :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", {})) - string_path = "啊齄丂狛狜隣郎隣兀﨩" - accept = "application/json" - - # Construct URL - url = self.string_unicode.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_unicode.metadata = {"url": "/paths/string/unicode/{stringPath}"} # type: ignore - - @distributed_trace_async - async def string_url_encoded(self, **kwargs: Any) -> None: - """Get 'begin!*'();:@ &=+$,/?#[]end. - - :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", {})) - string_path = "begin!*'();:@ &=+$,/?#[]end" - accept = "application/json" - - # Construct URL - url = self.string_url_encoded.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_url_encoded.metadata = {"url": "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}"} # type: ignore - - @distributed_trace_async - async def string_url_non_encoded(self, **kwargs: Any) -> None: - """Get 'begin!*'();:@&=+$,end. - - https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. - - :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", {})) - string_path = "begin!*'();:@&=+$,end" - accept = "application/json" - - # Construct URL - url = self.string_url_non_encoded.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_url_non_encoded.metadata = {"url": "/paths/string/begin!*'();:@&=+$,end/{stringPath}"} # type: ignore - - @distributed_trace_async - async def string_empty(self, **kwargs: Any) -> None: - """Get ''. - - :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", {})) - string_path = "" - accept = "application/json" - - # Construct URL - url = self.string_empty.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_empty.metadata = {"url": "/paths/string/empty/{stringPath}"} # type: ignore - - @distributed_trace_async - async def string_null(self, string_path: str, **kwargs: Any) -> None: - """Get null (should throw). - - :param string_path: null string value. - :type string_path: 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", {})) - accept = "application/json" - - # Construct URL - url = self.string_null.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_null.metadata = {"url": "/paths/string/null/{stringPath}"} # type: ignore - - @distributed_trace_async - async def enum_valid(self, enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> None: - """Get using uri with 'green color' in path parameter. - - :param enum_path: send the value green. - :type enum_path: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_valid.metadata["url"] # type: ignore - path_format_arguments = { - "enumPath": self._serialize.url("enum_path", enum_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_valid.metadata = {"url": "/paths/enum/green%20color/{enumPath}"} # type: ignore - - @distributed_trace_async - async def enum_null(self, enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> None: - """Get null (should throw on the client before the request is sent on wire). - - :param enum_path: send null should throw. - :type enum_path: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_null.metadata["url"] # type: ignore - path_format_arguments = { - "enumPath": self._serialize.url("enum_path", enum_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_null.metadata = {"url": "/paths/string/null/{enumPath}"} # type: ignore - - @distributed_trace_async - async def byte_multi_byte(self, byte_path: bytearray, **kwargs: Any) -> None: - """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - - :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - :type byte_path: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_multi_byte.metadata["url"] # type: ignore - path_format_arguments = { - "bytePath": self._serialize.url("byte_path", byte_path, "bytearray"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_multi_byte.metadata = {"url": "/paths/byte/multibyte/{bytePath}"} # type: ignore - - @distributed_trace_async - async def byte_empty(self, **kwargs: Any) -> None: - """Get '' as byte array. - - :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", {})) - byte_path = bytearray("", encoding="utf-8") - accept = "application/json" - - # Construct URL - url = self.byte_empty.metadata["url"] # type: ignore - path_format_arguments = { - "bytePath": self._serialize.url("byte_path", byte_path, "bytearray"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_empty.metadata = {"url": "/paths/byte/empty/{bytePath}"} # type: ignore - - @distributed_trace_async - async def byte_null(self, byte_path: bytearray, **kwargs: Any) -> None: - """Get null as byte array (should throw). - - :param byte_path: null as byte array (should throw). - :type byte_path: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_null.metadata["url"] # type: ignore - path_format_arguments = { - "bytePath": self._serialize.url("byte_path", byte_path, "bytearray"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_null.metadata = {"url": "/paths/byte/null/{bytePath}"} # type: ignore - - @distributed_trace_async - async def date_valid(self, **kwargs: Any) -> None: - """Get '2012-01-01' as date. - - :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", {})) - date_path = "2012-01-01" - accept = "application/json" - - # Construct URL - url = self.date_valid.metadata["url"] # type: ignore - path_format_arguments = { - "datePath": self._serialize.url("date_path", date_path, "date"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_valid.metadata = {"url": "/paths/date/2012-01-01/{datePath}"} # type: ignore - - @distributed_trace_async - async def date_null(self, date_path: datetime.date, **kwargs: Any) -> None: - """Get null as date - this should throw or be unusable on the client side, depending on date - representation. - - :param date_path: null as date (should throw). - :type date_path: ~datetime.date - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_null.metadata["url"] # type: ignore - path_format_arguments = { - "datePath": self._serialize.url("date_path", date_path, "date"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_null.metadata = {"url": "/paths/date/null/{datePath}"} # type: ignore - - @distributed_trace_async - async def date_time_valid(self, **kwargs: Any) -> None: - """Get '2012-01-01T01:01:01Z' as date-time. - - :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", {})) - date_time_path = "2012-01-01T01:01:01Z" - accept = "application/json" - - # Construct URL - url = self.date_time_valid.metadata["url"] # type: ignore - path_format_arguments = { - "dateTimePath": self._serialize.url("date_time_path", date_time_path, "iso-8601"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_valid.metadata = {"url": "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}"} # type: ignore - - @distributed_trace_async - async def date_time_null(self, date_time_path: datetime.datetime, **kwargs: Any) -> None: - """Get null as date-time, should be disallowed or throw depending on representation of date-time. - - :param date_time_path: null as date-time. - :type date_time_path: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_time_null.metadata["url"] # type: ignore - path_format_arguments = { - "dateTimePath": self._serialize.url("date_time_path", date_time_path, "iso-8601"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_null.metadata = {"url": "/paths/datetime/null/{dateTimePath}"} # type: ignore - - @distributed_trace_async - async def base64_url(self, base64_url_path: bytes, **kwargs: Any) -> None: - """Get 'lorem' encoded value as 'bG9yZW0' (base64url). - - :param base64_url_path: base64url encoded value. - :type base64_url_path: bytes - :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", {})) - accept = "application/json" - - # Construct URL - url = self.base64_url.metadata["url"] # type: ignore - path_format_arguments = { - "base64UrlPath": self._serialize.url("base64_url_path", base64_url_path, "base64"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - base64_url.metadata = {"url": "/paths/string/bG9yZW0/{base64UrlPath}"} # type: ignore - - @distributed_trace_async - async def array_csv_in_path(self, array_path: List[str], **kwargs: Any) -> None: - """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - csv-array format. - - :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] - using the csv-array format. - :type array_path: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_csv_in_path.metadata["url"] # type: ignore - path_format_arguments = { - "arrayPath": self._serialize.url("array_path", array_path, "[str]", div=","), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_csv_in_path.metadata = {"url": "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}"} # type: ignore - - @distributed_trace_async - async def unix_time_url(self, unix_time_url_path: datetime.datetime, **kwargs: Any) -> None: - """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). - - :param unix_time_url_path: Unix time encoded value. - :type unix_time_url_path: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.unix_time_url.metadata["url"] # type: ignore - path_format_arguments = { - "unixTimeUrlPath": self._serialize.url("unix_time_url_path", unix_time_url_path, "unix-time"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - unix_time_url.metadata = {"url": "/paths/int/1460505600/{unixTimeUrlPath}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py b/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py deleted file mode 100644 index a702064bbf7..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py +++ /dev/null @@ -1,1498 +0,0 @@ -# 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 datetime -from typing import Any, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class QueriesOperations: - """QueriesOperations 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: ~url.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 get_boolean_true(self, **kwargs: Any) -> None: - """Get true Boolean value on path. - - :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", {})) - bool_query = True - accept = "application/json" - - # Construct URL - url = self.get_boolean_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["boolQuery"] = self._serialize.query("bool_query", bool_query, "bool") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_true.metadata = {"url": "/queries/bool/true"} # type: ignore - - @distributed_trace_async - async def get_boolean_false(self, **kwargs: Any) -> None: - """Get false Boolean value on path. - - :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", {})) - bool_query = False - accept = "application/json" - - # Construct URL - url = self.get_boolean_false.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["boolQuery"] = self._serialize.query("bool_query", bool_query, "bool") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_false.metadata = {"url": "/queries/bool/false"} # type: ignore - - @distributed_trace_async - async def get_boolean_null(self, bool_query: Optional[bool] = None, **kwargs: Any) -> None: - """Get null Boolean value on query (query string should be absent). - - :param bool_query: null boolean value. - :type bool_query: bool - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if bool_query is not None: - query_parameters["boolQuery"] = self._serialize.query("bool_query", bool_query, "bool") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_null.metadata = {"url": "/queries/bool/null"} # type: ignore - - @distributed_trace_async - async def get_int_one_million(self, **kwargs: Any) -> None: - """Get '1000000' integer value. - - :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", {})) - int_query = 1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_one_million.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["intQuery"] = self._serialize.query("int_query", int_query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_one_million.metadata = {"url": "/queries/int/1000000"} # type: ignore - - @distributed_trace_async - async def get_int_negative_one_million(self, **kwargs: Any) -> None: - """Get '-1000000' integer value. - - :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", {})) - int_query = -1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_negative_one_million.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["intQuery"] = self._serialize.query("int_query", int_query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_negative_one_million.metadata = {"url": "/queries/int/-1000000"} # type: ignore - - @distributed_trace_async - async def get_int_null(self, int_query: Optional[int] = None, **kwargs: Any) -> None: - """Get null integer value (no query parameter). - - :param int_query: null integer value. - :type int_query: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if int_query is not None: - query_parameters["intQuery"] = self._serialize.query("int_query", int_query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_null.metadata = {"url": "/queries/int/null"} # type: ignore - - @distributed_trace_async - async def get_ten_billion(self, **kwargs: Any) -> None: - """Get '10000000000' 64 bit integer value. - - :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", {})) - long_query = 10000000000 - accept = "application/json" - - # Construct URL - url = self.get_ten_billion.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["longQuery"] = self._serialize.query("long_query", long_query, "long") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_ten_billion.metadata = {"url": "/queries/long/10000000000"} # type: ignore - - @distributed_trace_async - async def get_negative_ten_billion(self, **kwargs: Any) -> None: - """Get '-10000000000' 64 bit integer value. - - :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", {})) - long_query = -10000000000 - accept = "application/json" - - # Construct URL - url = self.get_negative_ten_billion.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["longQuery"] = self._serialize.query("long_query", long_query, "long") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_negative_ten_billion.metadata = {"url": "/queries/long/-10000000000"} # type: ignore - - @distributed_trace_async - async def get_long_null(self, long_query: Optional[int] = None, **kwargs: Any) -> None: - """Get 'null 64 bit integer value (no query param in uri). - - :param long_query: null 64 bit integer value. - :type long_query: long - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if long_query is not None: - query_parameters["longQuery"] = self._serialize.query("long_query", long_query, "long") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_long_null.metadata = {"url": "/queries/long/null"} # type: ignore - - @distributed_trace_async - async def float_scientific_positive(self, **kwargs: Any) -> None: - """Get '1.034E+20' numeric value. - - :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", {})) - float_query = 103400000000000000000 - accept = "application/json" - - # Construct URL - url = self.float_scientific_positive.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["floatQuery"] = self._serialize.query("float_query", float_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_positive.metadata = {"url": "/queries/float/1.034E+20"} # type: ignore - - @distributed_trace_async - async def float_scientific_negative(self, **kwargs: Any) -> None: - """Get '-1.034E-20' numeric value. - - :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", {})) - float_query = -1.034e-20 - accept = "application/json" - - # Construct URL - url = self.float_scientific_negative.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["floatQuery"] = self._serialize.query("float_query", float_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_negative.metadata = {"url": "/queries/float/-1.034E-20"} # type: ignore - - @distributed_trace_async - async def float_null(self, float_query: Optional[float] = None, **kwargs: Any) -> None: - """Get null numeric value (no query parameter). - - :param float_query: null numeric value. - :type float_query: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.float_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if float_query is not None: - query_parameters["floatQuery"] = self._serialize.query("float_query", float_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_null.metadata = {"url": "/queries/float/null"} # type: ignore - - @distributed_trace_async - async def double_decimal_positive(self, **kwargs: Any) -> None: - """Get '9999999.999' numeric value. - - :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", {})) - double_query = 9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_positive.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["doubleQuery"] = self._serialize.query("double_query", double_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_positive.metadata = {"url": "/queries/double/9999999.999"} # type: ignore - - @distributed_trace_async - async def double_decimal_negative(self, **kwargs: Any) -> None: - """Get '-9999999.999' numeric value. - - :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", {})) - double_query = -9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_negative.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["doubleQuery"] = self._serialize.query("double_query", double_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_negative.metadata = {"url": "/queries/double/-9999999.999"} # type: ignore - - @distributed_trace_async - async def double_null(self, double_query: Optional[float] = None, **kwargs: Any) -> None: - """Get null numeric value (no query parameter). - - :param double_query: null numeric value. - :type double_query: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.double_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if double_query is not None: - query_parameters["doubleQuery"] = self._serialize.query("double_query", double_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_null.metadata = {"url": "/queries/double/null"} # type: ignore - - @distributed_trace_async - async def string_unicode(self, **kwargs: Any) -> None: - """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. - - :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", {})) - string_query = "啊齄丂狛狜隣郎隣兀﨩" - accept = "application/json" - - # Construct URL - url = self.string_unicode.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_unicode.metadata = {"url": "/queries/string/unicode/"} # type: ignore - - @distributed_trace_async - async def string_url_encoded(self, **kwargs: Any) -> None: - """Get 'begin!*'();:@ &=+$,/?#[]end. - - :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", {})) - string_query = "begin!*'();:@ &=+$,/?#[]end" - accept = "application/json" - - # Construct URL - url = self.string_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_url_encoded.metadata = {"url": "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend"} # type: ignore - - @distributed_trace_async - async def string_empty(self, **kwargs: Any) -> None: - """Get ''. - - :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", {})) - string_query = "" - accept = "application/json" - - # Construct URL - url = self.string_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_empty.metadata = {"url": "/queries/string/empty"} # type: ignore - - @distributed_trace_async - async def string_null(self, string_query: Optional[str] = None, **kwargs: Any) -> None: - """Get null (no query parameter in url). - - :param string_query: null string value. - :type string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.string_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if string_query is not None: - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_null.metadata = {"url": "/queries/string/null"} # type: ignore - - @distributed_trace_async - async def enum_valid(self, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any) -> None: - """Get using uri with query parameter 'green color'. - - :param enum_query: 'green color' enum value. - :type enum_query: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if enum_query is not None: - query_parameters["enumQuery"] = self._serialize.query("enum_query", enum_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_valid.metadata = {"url": "/queries/enum/green%20color"} # type: ignore - - @distributed_trace_async - async def enum_null(self, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any) -> None: - """Get null (no query parameter in url). - - :param enum_query: null string value. - :type enum_query: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if enum_query is not None: - query_parameters["enumQuery"] = self._serialize.query("enum_query", enum_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_null.metadata = {"url": "/queries/enum/null"} # type: ignore - - @distributed_trace_async - async def byte_multi_byte(self, byte_query: Optional[bytearray] = None, **kwargs: Any) -> None: - """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - - :param byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - :type byte_query: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_multi_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if byte_query is not None: - query_parameters["byteQuery"] = self._serialize.query("byte_query", byte_query, "bytearray") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_multi_byte.metadata = {"url": "/queries/byte/multibyte"} # type: ignore - - @distributed_trace_async - async def byte_empty(self, **kwargs: Any) -> None: - """Get '' as byte array. - - :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", {})) - byte_query = bytearray("", encoding="utf-8") - accept = "application/json" - - # Construct URL - url = self.byte_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["byteQuery"] = self._serialize.query("byte_query", byte_query, "bytearray") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_empty.metadata = {"url": "/queries/byte/empty"} # type: ignore - - @distributed_trace_async - async def byte_null(self, byte_query: Optional[bytearray] = None, **kwargs: Any) -> None: - """Get null as byte array (no query parameters in uri). - - :param byte_query: null as byte array (no query parameters in uri). - :type byte_query: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if byte_query is not None: - query_parameters["byteQuery"] = self._serialize.query("byte_query", byte_query, "bytearray") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_null.metadata = {"url": "/queries/byte/null"} # type: ignore - - @distributed_trace_async - async def date_valid(self, **kwargs: Any) -> None: - """Get '2012-01-01' as date. - - :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", {})) - date_query = "2012-01-01" - accept = "application/json" - - # Construct URL - url = self.date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["dateQuery"] = self._serialize.query("date_query", date_query, "date") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_valid.metadata = {"url": "/queries/date/2012-01-01"} # type: ignore - - @distributed_trace_async - async def date_null(self, date_query: Optional[datetime.date] = None, **kwargs: Any) -> None: - """Get null as date - this should result in no query parameters in uri. - - :param date_query: null as date (no query parameters in uri). - :type date_query: ~datetime.date - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if date_query is not None: - query_parameters["dateQuery"] = self._serialize.query("date_query", date_query, "date") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_null.metadata = {"url": "/queries/date/null"} # type: ignore - - @distributed_trace_async - async def date_time_valid(self, **kwargs: Any) -> None: - """Get '2012-01-01T01:01:01Z' as date-time. - - :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", {})) - date_time_query = "2012-01-01T01:01:01Z" - accept = "application/json" - - # Construct URL - url = self.date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["dateTimeQuery"] = self._serialize.query("date_time_query", date_time_query, "iso-8601") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_valid.metadata = {"url": "/queries/datetime/2012-01-01T01%3A01%3A01Z"} # type: ignore - - @distributed_trace_async - async def date_time_null(self, date_time_query: Optional[datetime.datetime] = None, **kwargs: Any) -> None: - """Get null as date-time, should result in no query parameters in uri. - - :param date_time_query: null as date-time (no query parameters). - :type date_time_query: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_time_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if date_time_query is not None: - query_parameters["dateTimeQuery"] = self._serialize.query("date_time_query", date_time_query, "iso-8601") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_null.metadata = {"url": "/queries/datetime/null"} # type: ignore - - @distributed_trace_async - async def array_string_csv_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - csv-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the csv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_csv_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_csv_valid.metadata = {"url": "/queries/array/csv/string/valid"} # type: ignore - - @distributed_trace_async - async def array_string_csv_null(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get a null array of string using the csv-array format. - - :param array_query: a null array of string using the csv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_csv_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_csv_null.metadata = {"url": "/queries/array/csv/string/null"} # type: ignore - - @distributed_trace_async - async def array_string_csv_empty(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an empty array [] of string using the csv-array format. - - :param array_query: an empty array [] of string using the csv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_csv_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_csv_empty.metadata = {"url": "/queries/array/csv/string/empty"} # type: ignore - - @distributed_trace_async - async def array_string_no_collection_format_empty( - self, array_query: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', - 'bonjour'] for the 'arrayQuery' parameter to the service. - - :param array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_no_collection_format_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_no_collection_format_empty.metadata = {"url": "/queries/array/none/string/empty"} # type: ignore - - @distributed_trace_async - async def array_string_ssv_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - ssv-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the ssv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_ssv_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=" ") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_ssv_valid.metadata = {"url": "/queries/array/ssv/string/valid"} # type: ignore - - @distributed_trace_async - async def array_string_tsv_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - tsv-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the tsv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_tsv_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=" ") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_tsv_valid.metadata = {"url": "/queries/array/tsv/string/valid"} # type: ignore - - @distributed_trace_async - async def array_string_pipes_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - pipes-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the pipes-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_pipes_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div="|") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_pipes_valid.metadata = {"url": "/queries/array/pipes/string/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py b/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py deleted file mode 100644 index 0602471254d..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py +++ /dev/null @@ -1,359 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PathItemsOperations(object): - """PathItemsOperations 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: ~url.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 get_all_with_values( - self, - path_item_string_path, # type: str - local_string_path, # type: str - path_item_string_query=None, # type: Optional[str] - local_string_query=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery='globalStringQuery', - pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query - parameter. - :type path_item_string_query: str - :param local_string_query: should contain value 'localStringQuery'. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_all_with_values.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_all_with_values.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery"} # type: ignore - - @distributed_trace - def get_global_query_null( - self, - path_item_string_path, # type: str - local_string_path, # type: str - path_item_string_query=None, # type: Optional[str] - local_string_query=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery=null, - pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query - parameter. - :type path_item_string_query: str - :param local_string_query: should contain value 'localStringQuery'. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_global_query_null.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_global_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery"} # type: ignore - - @distributed_trace - def get_global_and_local_query_null( - self, - path_item_string_path, # type: str - local_string_path, # type: str - path_item_string_query=None, # type: Optional[str] - local_string_query=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery=null, - pathItemStringQuery='pathItemStringQuery', localStringQuery=null. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query - parameter. - :type path_item_string_query: str - :param local_string_query: should contain null value. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_global_and_local_query_null.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_global_and_local_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null"} # type: ignore - - @distributed_trace - def get_local_path_item_query_null( - self, - path_item_string_path, # type: str - local_string_path, # type: str - path_item_string_query=None, # type: Optional[str] - local_string_query=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', - localStringPath='localStringPath', globalStringQuery='globalStringQuery', - pathItemStringQuery=null, localStringQuery=null. - - :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. - :type path_item_string_path: str - :param local_string_path: should contain value 'localStringPath'. - :type local_string_path: str - :param path_item_string_query: should contain value null. - :type path_item_string_query: str - :param local_string_query: should contain value null. - :type local_string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.get_local_path_item_query_null.metadata["url"] # type: ignore - path_format_arguments = { - "pathItemStringPath": self._serialize.url("path_item_string_path", path_item_string_path, "str"), - "globalStringPath": self._serialize.url( - "self._config.global_string_path", self._config.global_string_path, "str" - ), - "localStringPath": self._serialize.url("local_string_path", local_string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if path_item_string_query is not None: - query_parameters["pathItemStringQuery"] = self._serialize.query( - "path_item_string_query", path_item_string_query, "str" - ) - if self._config.global_string_query is not None: - query_parameters["globalStringQuery"] = self._serialize.query( - "self._config.global_string_query", self._config.global_string_query, "str" - ) - if local_string_query is not None: - query_parameters["localStringQuery"] = self._serialize.query( - "local_string_query", local_string_query, "str" - ) - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_local_path_item_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py b/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py deleted file mode 100644 index 47097d9f44c..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py +++ /dev/null @@ -1,1330 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class PathsOperations(object): - """PathsOperations 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: ~url.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 get_boolean_true( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get true Boolean value on path. - - :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", {})) - bool_path = True - accept = "application/json" - - # Construct URL - url = self.get_boolean_true.metadata["url"] # type: ignore - path_format_arguments = { - "boolPath": self._serialize.url("bool_path", bool_path, "bool"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_true.metadata = {"url": "/paths/bool/true/{boolPath}"} # type: ignore - - @distributed_trace - def get_boolean_false( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get false Boolean value on path. - - :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", {})) - bool_path = False - accept = "application/json" - - # Construct URL - url = self.get_boolean_false.metadata["url"] # type: ignore - path_format_arguments = { - "boolPath": self._serialize.url("bool_path", bool_path, "bool"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_false.metadata = {"url": "/paths/bool/false/{boolPath}"} # type: ignore - - @distributed_trace - def get_int_one_million( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '1000000' integer value. - - :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", {})) - int_path = 1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_one_million.metadata["url"] # type: ignore - path_format_arguments = { - "intPath": self._serialize.url("int_path", int_path, "int"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_one_million.metadata = {"url": "/paths/int/1000000/{intPath}"} # type: ignore - - @distributed_trace - def get_int_negative_one_million( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-1000000' integer value. - - :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", {})) - int_path = -1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_negative_one_million.metadata["url"] # type: ignore - path_format_arguments = { - "intPath": self._serialize.url("int_path", int_path, "int"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_negative_one_million.metadata = {"url": "/paths/int/-1000000/{intPath}"} # type: ignore - - @distributed_trace - def get_ten_billion( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '10000000000' 64 bit integer value. - - :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", {})) - long_path = 10000000000 - accept = "application/json" - - # Construct URL - url = self.get_ten_billion.metadata["url"] # type: ignore - path_format_arguments = { - "longPath": self._serialize.url("long_path", long_path, "long"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_ten_billion.metadata = {"url": "/paths/long/10000000000/{longPath}"} # type: ignore - - @distributed_trace - def get_negative_ten_billion( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-10000000000' 64 bit integer value. - - :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", {})) - long_path = -10000000000 - accept = "application/json" - - # Construct URL - url = self.get_negative_ten_billion.metadata["url"] # type: ignore - path_format_arguments = { - "longPath": self._serialize.url("long_path", long_path, "long"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_negative_ten_billion.metadata = {"url": "/paths/long/-10000000000/{longPath}"} # type: ignore - - @distributed_trace - def float_scientific_positive( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '1.034E+20' numeric value. - - :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", {})) - float_path = 103400000000000000000 - accept = "application/json" - - # Construct URL - url = self.float_scientific_positive.metadata["url"] # type: ignore - path_format_arguments = { - "floatPath": self._serialize.url("float_path", float_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_positive.metadata = {"url": "/paths/float/1.034E+20/{floatPath}"} # type: ignore - - @distributed_trace - def float_scientific_negative( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-1.034E-20' numeric value. - - :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", {})) - float_path = -1.034e-20 - accept = "application/json" - - # Construct URL - url = self.float_scientific_negative.metadata["url"] # type: ignore - path_format_arguments = { - "floatPath": self._serialize.url("float_path", float_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_negative.metadata = {"url": "/paths/float/-1.034E-20/{floatPath}"} # type: ignore - - @distributed_trace - def double_decimal_positive( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '9999999.999' numeric value. - - :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", {})) - double_path = 9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_positive.metadata["url"] # type: ignore - path_format_arguments = { - "doublePath": self._serialize.url("double_path", double_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_positive.metadata = {"url": "/paths/double/9999999.999/{doublePath}"} # type: ignore - - @distributed_trace - def double_decimal_negative( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-9999999.999' numeric value. - - :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", {})) - double_path = -9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_negative.metadata["url"] # type: ignore - path_format_arguments = { - "doublePath": self._serialize.url("double_path", double_path, "float"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_negative.metadata = {"url": "/paths/double/-9999999.999/{doublePath}"} # type: ignore - - @distributed_trace - def string_unicode( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. - - :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", {})) - string_path = "啊齄丂狛狜隣郎隣兀﨩" - accept = "application/json" - - # Construct URL - url = self.string_unicode.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_unicode.metadata = {"url": "/paths/string/unicode/{stringPath}"} # type: ignore - - @distributed_trace - def string_url_encoded( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get 'begin!*'();:@ &=+$,/?#[]end. - - :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", {})) - string_path = "begin!*'();:@ &=+$,/?#[]end" - accept = "application/json" - - # Construct URL - url = self.string_url_encoded.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_url_encoded.metadata = {"url": "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}"} # type: ignore - - @distributed_trace - def string_url_non_encoded( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get 'begin!*'();:@&=+$,end. - - https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. - - :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", {})) - string_path = "begin!*'();:@&=+$,end" - accept = "application/json" - - # Construct URL - url = self.string_url_non_encoded.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str", skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_url_non_encoded.metadata = {"url": "/paths/string/begin!*'();:@&=+$,end/{stringPath}"} # type: ignore - - @distributed_trace - def string_empty( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get ''. - - :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", {})) - string_path = "" - accept = "application/json" - - # Construct URL - url = self.string_empty.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_empty.metadata = {"url": "/paths/string/empty/{stringPath}"} # type: ignore - - @distributed_trace - def string_null( - self, - string_path, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Get null (should throw). - - :param string_path: null string value. - :type string_path: 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", {})) - accept = "application/json" - - # Construct URL - url = self.string_null.metadata["url"] # type: ignore - path_format_arguments = { - "stringPath": self._serialize.url("string_path", string_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_null.metadata = {"url": "/paths/string/null/{stringPath}"} # type: ignore - - @distributed_trace - def enum_valid( - self, - enum_path, # type: Union[str, "_models.UriColor"] - **kwargs # type: Any - ): - # type: (...) -> None - """Get using uri with 'green color' in path parameter. - - :param enum_path: send the value green. - :type enum_path: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_valid.metadata["url"] # type: ignore - path_format_arguments = { - "enumPath": self._serialize.url("enum_path", enum_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_valid.metadata = {"url": "/paths/enum/green%20color/{enumPath}"} # type: ignore - - @distributed_trace - def enum_null( - self, - enum_path, # type: Union[str, "_models.UriColor"] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null (should throw on the client before the request is sent on wire). - - :param enum_path: send null should throw. - :type enum_path: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_null.metadata["url"] # type: ignore - path_format_arguments = { - "enumPath": self._serialize.url("enum_path", enum_path, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_null.metadata = {"url": "/paths/string/null/{enumPath}"} # type: ignore - - @distributed_trace - def byte_multi_byte( - self, - byte_path, # type: bytearray - **kwargs # type: Any - ): - # type: (...) -> None - """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - - :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - :type byte_path: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_multi_byte.metadata["url"] # type: ignore - path_format_arguments = { - "bytePath": self._serialize.url("byte_path", byte_path, "bytearray"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_multi_byte.metadata = {"url": "/paths/byte/multibyte/{bytePath}"} # type: ignore - - @distributed_trace - def byte_empty( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '' as byte array. - - :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", {})) - byte_path = bytearray("", encoding="utf-8") - accept = "application/json" - - # Construct URL - url = self.byte_empty.metadata["url"] # type: ignore - path_format_arguments = { - "bytePath": self._serialize.url("byte_path", byte_path, "bytearray"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_empty.metadata = {"url": "/paths/byte/empty/{bytePath}"} # type: ignore - - @distributed_trace - def byte_null( - self, - byte_path, # type: bytearray - **kwargs # type: Any - ): - # type: (...) -> None - """Get null as byte array (should throw). - - :param byte_path: null as byte array (should throw). - :type byte_path: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_null.metadata["url"] # type: ignore - path_format_arguments = { - "bytePath": self._serialize.url("byte_path", byte_path, "bytearray"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_null.metadata = {"url": "/paths/byte/null/{bytePath}"} # type: ignore - - @distributed_trace - def date_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '2012-01-01' as date. - - :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", {})) - date_path = "2012-01-01" - accept = "application/json" - - # Construct URL - url = self.date_valid.metadata["url"] # type: ignore - path_format_arguments = { - "datePath": self._serialize.url("date_path", date_path, "date"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_valid.metadata = {"url": "/paths/date/2012-01-01/{datePath}"} # type: ignore - - @distributed_trace - def date_null( - self, - date_path, # type: datetime.date - **kwargs # type: Any - ): - # type: (...) -> None - """Get null as date - this should throw or be unusable on the client side, depending on date - representation. - - :param date_path: null as date (should throw). - :type date_path: ~datetime.date - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_null.metadata["url"] # type: ignore - path_format_arguments = { - "datePath": self._serialize.url("date_path", date_path, "date"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_null.metadata = {"url": "/paths/date/null/{datePath}"} # type: ignore - - @distributed_trace - def date_time_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '2012-01-01T01:01:01Z' as date-time. - - :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", {})) - date_time_path = "2012-01-01T01:01:01Z" - accept = "application/json" - - # Construct URL - url = self.date_time_valid.metadata["url"] # type: ignore - path_format_arguments = { - "dateTimePath": self._serialize.url("date_time_path", date_time_path, "iso-8601"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_valid.metadata = {"url": "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}"} # type: ignore - - @distributed_trace - def date_time_null( - self, - date_time_path, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Get null as date-time, should be disallowed or throw depending on representation of date-time. - - :param date_time_path: null as date-time. - :type date_time_path: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_time_null.metadata["url"] # type: ignore - path_format_arguments = { - "dateTimePath": self._serialize.url("date_time_path", date_time_path, "iso-8601"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [400]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_null.metadata = {"url": "/paths/datetime/null/{dateTimePath}"} # type: ignore - - @distributed_trace - def base64_url( - self, - base64_url_path, # type: bytes - **kwargs # type: Any - ): - # type: (...) -> None - """Get 'lorem' encoded value as 'bG9yZW0' (base64url). - - :param base64_url_path: base64url encoded value. - :type base64_url_path: bytes - :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", {})) - accept = "application/json" - - # Construct URL - url = self.base64_url.metadata["url"] # type: ignore - path_format_arguments = { - "base64UrlPath": self._serialize.url("base64_url_path", base64_url_path, "base64"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - base64_url.metadata = {"url": "/paths/string/bG9yZW0/{base64UrlPath}"} # type: ignore - - @distributed_trace - def array_csv_in_path( - self, - array_path, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - csv-array format. - - :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] - using the csv-array format. - :type array_path: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_csv_in_path.metadata["url"] # type: ignore - path_format_arguments = { - "arrayPath": self._serialize.url("array_path", array_path, "[str]", div=","), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_csv_in_path.metadata = {"url": "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}"} # type: ignore - - @distributed_trace - def unix_time_url( - self, - unix_time_url_path, # type: datetime.datetime - **kwargs # type: Any - ): - # type: (...) -> None - """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). - - :param unix_time_url_path: Unix time encoded value. - :type unix_time_url_path: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.unix_time_url.metadata["url"] # type: ignore - path_format_arguments = { - "unixTimeUrlPath": self._serialize.url("unix_time_url_path", unix_time_url_path, "unix-time"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - unix_time_url.metadata = {"url": "/paths/int/1460505600/{unixTimeUrlPath}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py b/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py deleted file mode 100644 index eb7b7fc901b..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py +++ /dev/null @@ -1,1643 +0,0 @@ -# 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 datetime -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class QueriesOperations(object): - """QueriesOperations 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: ~url.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 get_boolean_true( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get true Boolean value on path. - - :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", {})) - bool_query = True - accept = "application/json" - - # Construct URL - url = self.get_boolean_true.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["boolQuery"] = self._serialize.query("bool_query", bool_query, "bool") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_true.metadata = {"url": "/queries/bool/true"} # type: ignore - - @distributed_trace - def get_boolean_false( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get false Boolean value on path. - - :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", {})) - bool_query = False - accept = "application/json" - - # Construct URL - url = self.get_boolean_false.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["boolQuery"] = self._serialize.query("bool_query", bool_query, "bool") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_false.metadata = {"url": "/queries/bool/false"} # type: ignore - - @distributed_trace - def get_boolean_null( - self, - bool_query=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null Boolean value on query (query string should be absent). - - :param bool_query: null boolean value. - :type bool_query: bool - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_boolean_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if bool_query is not None: - query_parameters["boolQuery"] = self._serialize.query("bool_query", bool_query, "bool") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_boolean_null.metadata = {"url": "/queries/bool/null"} # type: ignore - - @distributed_trace - def get_int_one_million( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '1000000' integer value. - - :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", {})) - int_query = 1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_one_million.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["intQuery"] = self._serialize.query("int_query", int_query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_one_million.metadata = {"url": "/queries/int/1000000"} # type: ignore - - @distributed_trace - def get_int_negative_one_million( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-1000000' integer value. - - :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", {})) - int_query = -1000000 - accept = "application/json" - - # Construct URL - url = self.get_int_negative_one_million.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["intQuery"] = self._serialize.query("int_query", int_query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_negative_one_million.metadata = {"url": "/queries/int/-1000000"} # type: ignore - - @distributed_trace - def get_int_null( - self, - int_query=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null integer value (no query parameter). - - :param int_query: null integer value. - :type int_query: int - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_int_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if int_query is not None: - query_parameters["intQuery"] = self._serialize.query("int_query", int_query, "int") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_int_null.metadata = {"url": "/queries/int/null"} # type: ignore - - @distributed_trace - def get_ten_billion( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '10000000000' 64 bit integer value. - - :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", {})) - long_query = 10000000000 - accept = "application/json" - - # Construct URL - url = self.get_ten_billion.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["longQuery"] = self._serialize.query("long_query", long_query, "long") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_ten_billion.metadata = {"url": "/queries/long/10000000000"} # type: ignore - - @distributed_trace - def get_negative_ten_billion( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-10000000000' 64 bit integer value. - - :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", {})) - long_query = -10000000000 - accept = "application/json" - - # Construct URL - url = self.get_negative_ten_billion.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["longQuery"] = self._serialize.query("long_query", long_query, "long") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_negative_ten_billion.metadata = {"url": "/queries/long/-10000000000"} # type: ignore - - @distributed_trace - def get_long_null( - self, - long_query=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """Get 'null 64 bit integer value (no query param in uri). - - :param long_query: null 64 bit integer value. - :type long_query: long - :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", {})) - accept = "application/json" - - # Construct URL - url = self.get_long_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if long_query is not None: - query_parameters["longQuery"] = self._serialize.query("long_query", long_query, "long") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - get_long_null.metadata = {"url": "/queries/long/null"} # type: ignore - - @distributed_trace - def float_scientific_positive( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '1.034E+20' numeric value. - - :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", {})) - float_query = 103400000000000000000 - accept = "application/json" - - # Construct URL - url = self.float_scientific_positive.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["floatQuery"] = self._serialize.query("float_query", float_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_positive.metadata = {"url": "/queries/float/1.034E+20"} # type: ignore - - @distributed_trace - def float_scientific_negative( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-1.034E-20' numeric value. - - :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", {})) - float_query = -1.034e-20 - accept = "application/json" - - # Construct URL - url = self.float_scientific_negative.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["floatQuery"] = self._serialize.query("float_query", float_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_scientific_negative.metadata = {"url": "/queries/float/-1.034E-20"} # type: ignore - - @distributed_trace - def float_null( - self, - float_query=None, # type: Optional[float] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null numeric value (no query parameter). - - :param float_query: null numeric value. - :type float_query: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.float_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if float_query is not None: - query_parameters["floatQuery"] = self._serialize.query("float_query", float_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - float_null.metadata = {"url": "/queries/float/null"} # type: ignore - - @distributed_trace - def double_decimal_positive( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '9999999.999' numeric value. - - :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", {})) - double_query = 9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_positive.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["doubleQuery"] = self._serialize.query("double_query", double_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_positive.metadata = {"url": "/queries/double/9999999.999"} # type: ignore - - @distributed_trace - def double_decimal_negative( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '-9999999.999' numeric value. - - :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", {})) - double_query = -9999999.999 - accept = "application/json" - - # Construct URL - url = self.double_decimal_negative.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["doubleQuery"] = self._serialize.query("double_query", double_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_decimal_negative.metadata = {"url": "/queries/double/-9999999.999"} # type: ignore - - @distributed_trace - def double_null( - self, - double_query=None, # type: Optional[float] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null numeric value (no query parameter). - - :param double_query: null numeric value. - :type double_query: float - :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", {})) - accept = "application/json" - - # Construct URL - url = self.double_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if double_query is not None: - query_parameters["doubleQuery"] = self._serialize.query("double_query", double_query, "float") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - double_null.metadata = {"url": "/queries/double/null"} # type: ignore - - @distributed_trace - def string_unicode( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. - - :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", {})) - string_query = "啊齄丂狛狜隣郎隣兀﨩" - accept = "application/json" - - # Construct URL - url = self.string_unicode.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_unicode.metadata = {"url": "/queries/string/unicode/"} # type: ignore - - @distributed_trace - def string_url_encoded( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get 'begin!*'();:@ &=+$,/?#[]end. - - :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", {})) - string_query = "begin!*'();:@ &=+$,/?#[]end" - accept = "application/json" - - # Construct URL - url = self.string_url_encoded.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_url_encoded.metadata = {"url": "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend"} # type: ignore - - @distributed_trace - def string_empty( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get ''. - - :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", {})) - string_query = "" - accept = "application/json" - - # Construct URL - url = self.string_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_empty.metadata = {"url": "/queries/string/empty"} # type: ignore - - @distributed_trace - def string_null( - self, - string_query=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null (no query parameter in url). - - :param string_query: null string value. - :type string_query: 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", {})) - accept = "application/json" - - # Construct URL - url = self.string_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if string_query is not None: - query_parameters["stringQuery"] = self._serialize.query("string_query", string_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - string_null.metadata = {"url": "/queries/string/null"} # type: ignore - - @distributed_trace - def enum_valid( - self, - enum_query=None, # type: Optional[Union[str, "_models.UriColor"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get using uri with query parameter 'green color'. - - :param enum_query: 'green color' enum value. - :type enum_query: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if enum_query is not None: - query_parameters["enumQuery"] = self._serialize.query("enum_query", enum_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_valid.metadata = {"url": "/queries/enum/green%20color"} # type: ignore - - @distributed_trace - def enum_null( - self, - enum_query=None, # type: Optional[Union[str, "_models.UriColor"]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null (no query parameter in url). - - :param enum_query: null string value. - :type enum_query: str or ~url.models.UriColor - :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", {})) - accept = "application/json" - - # Construct URL - url = self.enum_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if enum_query is not None: - query_parameters["enumQuery"] = self._serialize.query("enum_query", enum_query, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - enum_null.metadata = {"url": "/queries/enum/null"} # type: ignore - - @distributed_trace - def byte_multi_byte( - self, - byte_query=None, # type: Optional[bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - - :param byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. - :type byte_query: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_multi_byte.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if byte_query is not None: - query_parameters["byteQuery"] = self._serialize.query("byte_query", byte_query, "bytearray") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_multi_byte.metadata = {"url": "/queries/byte/multibyte"} # type: ignore - - @distributed_trace - def byte_empty( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '' as byte array. - - :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", {})) - byte_query = bytearray("", encoding="utf-8") - accept = "application/json" - - # Construct URL - url = self.byte_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["byteQuery"] = self._serialize.query("byte_query", byte_query, "bytearray") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_empty.metadata = {"url": "/queries/byte/empty"} # type: ignore - - @distributed_trace - def byte_null( - self, - byte_query=None, # type: Optional[bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null as byte array (no query parameters in uri). - - :param byte_query: null as byte array (no query parameters in uri). - :type byte_query: bytearray - :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", {})) - accept = "application/json" - - # Construct URL - url = self.byte_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if byte_query is not None: - query_parameters["byteQuery"] = self._serialize.query("byte_query", byte_query, "bytearray") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - byte_null.metadata = {"url": "/queries/byte/null"} # type: ignore - - @distributed_trace - def date_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '2012-01-01' as date. - - :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", {})) - date_query = "2012-01-01" - accept = "application/json" - - # Construct URL - url = self.date_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["dateQuery"] = self._serialize.query("date_query", date_query, "date") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_valid.metadata = {"url": "/queries/date/2012-01-01"} # type: ignore - - @distributed_trace - def date_null( - self, - date_query=None, # type: Optional[datetime.date] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null as date - this should result in no query parameters in uri. - - :param date_query: null as date (no query parameters in uri). - :type date_query: ~datetime.date - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if date_query is not None: - query_parameters["dateQuery"] = self._serialize.query("date_query", date_query, "date") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_null.metadata = {"url": "/queries/date/null"} # type: ignore - - @distributed_trace - def date_time_valid( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get '2012-01-01T01:01:01Z' as date-time. - - :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", {})) - date_time_query = "2012-01-01T01:01:01Z" - accept = "application/json" - - # Construct URL - url = self.date_time_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["dateTimeQuery"] = self._serialize.query("date_time_query", date_time_query, "iso-8601") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_valid.metadata = {"url": "/queries/datetime/2012-01-01T01%3A01%3A01Z"} # type: ignore - - @distributed_trace - def date_time_null( - self, - date_time_query=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Get null as date-time, should result in no query parameters in uri. - - :param date_time_query: null as date-time (no query parameters). - :type date_time_query: ~datetime.datetime - :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", {})) - accept = "application/json" - - # Construct URL - url = self.date_time_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if date_time_query is not None: - query_parameters["dateTimeQuery"] = self._serialize.query("date_time_query", date_time_query, "iso-8601") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - date_time_null.metadata = {"url": "/queries/datetime/null"} # type: ignore - - @distributed_trace - def array_string_csv_valid( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - csv-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the csv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_csv_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_csv_valid.metadata = {"url": "/queries/array/csv/string/valid"} # type: ignore - - @distributed_trace - def array_string_csv_null( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get a null array of string using the csv-array format. - - :param array_query: a null array of string using the csv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_csv_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_csv_null.metadata = {"url": "/queries/array/csv/string/null"} # type: ignore - - @distributed_trace - def array_string_csv_empty( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an empty array [] of string using the csv-array format. - - :param array_query: an empty array [] of string using the csv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_csv_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_csv_empty.metadata = {"url": "/queries/array/csv/string/empty"} # type: ignore - - @distributed_trace - def array_string_no_collection_format_empty( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', - 'bonjour'] for the 'arrayQuery' parameter to the service. - - :param array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_no_collection_format_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=",") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_no_collection_format_empty.metadata = {"url": "/queries/array/none/string/empty"} # type: ignore - - @distributed_trace - def array_string_ssv_valid( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - ssv-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the ssv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_ssv_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=" ") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_ssv_valid.metadata = {"url": "/queries/array/ssv/string/valid"} # type: ignore - - @distributed_trace - def array_string_tsv_valid( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - tsv-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the tsv-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_tsv_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div=" ") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_tsv_valid.metadata = {"url": "/queries/array/tsv/string/valid"} # type: ignore - - @distributed_trace - def array_string_pipes_valid( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - pipes-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the pipes-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_pipes_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = self._serialize.query("array_query", array_query, "[str]", div="|") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_pipes_valid.metadata = {"url": "/queries/array/pipes/string/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/setup.py b/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/setup.py deleted file mode 100644 index 18001b9fb09..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autoresturlmutlicollectionformattestservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestUrlMutliCollectionFormatTestService", - author_email="", - url="", - keywords=["Swagger", "AutoRestUrlMutliCollectionFormatTestService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_auto_rest_url_mutli_collection_format_test_service.py b/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_auto_rest_url_mutli_collection_format_test_service.py deleted file mode 100644 index aae48db5bc1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_auto_rest_url_mutli_collection_format_test_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestUrlMutliCollectionFormatTestServiceConfiguration -from .operations import QueriesOperations -from . import models - - -class AutoRestUrlMutliCollectionFormatTestService(object): - """Test Infrastructure for AutoRest. - - :ivar queries: QueriesOperations operations - :vartype queries: urlmulticollectionformat.operations.QueriesOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestUrlMutliCollectionFormatTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestUrlMutliCollectionFormatTestService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_auto_rest_url_mutli_collection_format_test_service.py b/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_auto_rest_url_mutli_collection_format_test_service.py deleted file mode 100644 index 89b4ea135c6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_auto_rest_url_mutli_collection_format_test_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestUrlMutliCollectionFormatTestServiceConfiguration -from .operations import QueriesOperations -from .. import models - - -class AutoRestUrlMutliCollectionFormatTestService(object): - """Test Infrastructure for AutoRest. - - :ivar queries: QueriesOperations operations - :vartype queries: urlmulticollectionformat.aio.operations.QueriesOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestUrlMutliCollectionFormatTestServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestUrlMutliCollectionFormatTestService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py b/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py deleted file mode 100644 index a7875d71992..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py +++ /dev/null @@ -1,182 +0,0 @@ -# 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, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class QueriesOperations: - """QueriesOperations 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: ~urlmulticollectionformat.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 array_string_multi_null(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get a null array of string using the multi-array format. - - :param array_query: a null array of string using the multi-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_multi_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = [ - self._serialize.query("array_query", q, "str") if q is not None else "" for q in array_query - ] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_multi_null.metadata = {"url": "/queries/array/multi/string/null"} # type: ignore - - @distributed_trace_async - async def array_string_multi_empty(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an empty array [] of string using the multi-array format. - - :param array_query: an empty array [] of string using the multi-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_multi_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = [ - self._serialize.query("array_query", q, "str") if q is not None else "" for q in array_query - ] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_multi_empty.metadata = {"url": "/queries/array/multi/string/empty"} # type: ignore - - @distributed_trace_async - async def array_string_multi_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - mult-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the mult-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_multi_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = [ - self._serialize.query("array_query", q, "str") if q is not None else "" for q in array_query - ] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_multi_valid.metadata = {"url": "/queries/array/multi/string/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py b/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py deleted file mode 100644 index ae5d1417757..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py +++ /dev/null @@ -1,201 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class QueriesOperations(object): - """QueriesOperations 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: ~urlmulticollectionformat.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 array_string_multi_null( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get a null array of string using the multi-array format. - - :param array_query: a null array of string using the multi-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_multi_null.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = [ - self._serialize.query("array_query", q, "str") if q is not None else "" for q in array_query - ] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_multi_null.metadata = {"url": "/queries/array/multi/string/null"} # type: ignore - - @distributed_trace - def array_string_multi_empty( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an empty array [] of string using the multi-array format. - - :param array_query: an empty array [] of string using the multi-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_multi_empty.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = [ - self._serialize.query("array_query", q, "str") if q is not None else "" for q in array_query - ] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_multi_empty.metadata = {"url": "/queries/array/multi/string/empty"} # type: ignore - - @distributed_trace - def array_string_multi_valid( - self, - array_query=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> None - """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the - mult-array format. - - :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, - ''] using the mult-array format. - :type array_query: list[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", {})) - accept = "application/json" - - # Construct URL - url = self.array_string_multi_valid.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if array_query is not None: - query_parameters["arrayQuery"] = [ - self._serialize.query("array_query", q, "str") if q is not None else "" for q in array_query - ] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - array_string_multi_valid.metadata = {"url": "/queries/array/multi/string/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/setup.py b/test/vanilla/Expected/AcceptanceTests/Validation/setup.py deleted file mode 100644 index b8198b9ed0a..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Validation/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestvalidationtest" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestValidationTest", - author_email="", - url="", - keywords=["Swagger", "AutoRestValidationTest"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest. No server backend exists for these tests. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/_auto_rest_validation_test.py b/test/vanilla/Expected/AcceptanceTests/Validation/validation/_auto_rest_validation_test.py deleted file mode 100644 index 7d88636e2ba..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Validation/validation/_auto_rest_validation_test.py +++ /dev/null @@ -1,78 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestValidationTestConfiguration -from .operations import AutoRestValidationTestOperationsMixin -from . import models - - -class AutoRestValidationTest(AutoRestValidationTestOperationsMixin): - """Test Infrastructure for AutoRest. No server backend exists for these tests. - - :param subscription_id: Subscription ID. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestValidationTestConfiguration(subscription_id, **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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestValidationTest - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/_auto_rest_validation_test.py b/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/_auto_rest_validation_test.py deleted file mode 100644 index fcd091ae749..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/_auto_rest_validation_test.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestValidationTestConfiguration -from .operations import AutoRestValidationTestOperationsMixin -from .. import models - - -class AutoRestValidationTest(AutoRestValidationTestOperationsMixin): - """Test Infrastructure for AutoRest. No server backend exists for these tests. - - :param subscription_id: Subscription ID. - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__(self, subscription_id: str, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestValidationTestConfiguration(subscription_id, **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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestValidationTest": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py b/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py deleted file mode 100644 index 02b3c5b86f8..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py +++ /dev/null @@ -1,256 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoRestValidationTestOperationsMixin: - @distributed_trace_async - async def validation_of_method_parameters( - self, resource_group_name: str, id: int, **kwargs: Any - ) -> "_models.Product": - """Validates input parameters on the method. See swagger for details. - - :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. - :type resource_group_name: str - :param id: Required int multiple of 10 from 100 to 1000. - :type id: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Product, or the result of cls(response) - :rtype: ~validation.models.Product - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.validation_of_method_parameters.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "resourceGroupName": self._serialize.url( - "resource_group_name", - resource_group_name, - "str", - max_length=10, - min_length=3, - pattern=r"[a-zA-Z0-9\']+", - ), - "id": self._serialize.url("id", id, "int", maximum=1000, minimum=100, multiple=10), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["apiVersion"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validation_of_method_parameters.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore - - @distributed_trace_async - async def validation_of_body( - self, resource_group_name: str, id: int, body: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - """Validates body parameters on the method. See swagger for details. - - :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. - :type resource_group_name: str - :param id: Required int multiple of 10 from 100 to 1000. - :type id: int - :param body: - :type body: ~validation.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Product, or the result of cls(response) - :rtype: ~validation.models.Product - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "1.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validation_of_body.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "resourceGroupName": self._serialize.url( - "resource_group_name", resource_group_name, "str", max_length=10, min_length=3, pattern=r"[a-zA-Z0-9]+" - ), - "id": self._serialize.url("id", id, "int", maximum=1000, minimum=100, multiple=10), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["apiVersion"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validation_of_body.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore - - @distributed_trace_async - async def get_with_constant_in_path(self, **kwargs: Any) -> None: - """get_with_constant_in_path. - - :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", {})) - constant_param = "constant" - - # Construct URL - url = self.get_with_constant_in_path.metadata["url"] # type: ignore - path_format_arguments = { - "constantParam": self._serialize.url("constant_param", constant_param, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_with_constant_in_path.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore - - @distributed_trace_async - async def post_with_constant_in_body( - self, body: Optional["_models.Product"] = None, **kwargs: Any - ) -> "_models.Product": - """post_with_constant_in_body. - - :param body: - :type body: ~validation.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Product, or the result of cls(response) - :rtype: ~validation.models.Product - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - constant_param = "constant" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_with_constant_in_body.metadata["url"] # type: ignore - path_format_arguments = { - "constantParam": self._serialize.url("constant_param", constant_param, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - post_with_constant_in_body.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py b/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py deleted file mode 100644 index 7323a12fc59..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py +++ /dev/null @@ -1,275 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class AutoRestValidationTestOperationsMixin(object): - @distributed_trace - def validation_of_method_parameters( - self, - resource_group_name, # type: str - id, # type: int - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - """Validates input parameters on the method. See swagger for details. - - :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. - :type resource_group_name: str - :param id: Required int multiple of 10 from 100 to 1000. - :type id: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Product, or the result of cls(response) - :rtype: ~validation.models.Product - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "1.0.0" - accept = "application/json" - - # Construct URL - url = self.validation_of_method_parameters.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "resourceGroupName": self._serialize.url( - "resource_group_name", - resource_group_name, - "str", - max_length=10, - min_length=3, - pattern=r"[a-zA-Z0-9\']+", - ), - "id": self._serialize.url("id", id, "int", maximum=1000, minimum=100, multiple=10), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["apiVersion"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validation_of_method_parameters.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore - - @distributed_trace - def validation_of_body( - self, - resource_group_name, # type: str - id, # type: int - body=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - """Validates body parameters on the method. See swagger for details. - - :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. - :type resource_group_name: str - :param id: Required int multiple of 10 from 100 to 1000. - :type id: int - :param body: - :type body: ~validation.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Product, or the result of cls(response) - :rtype: ~validation.models.Product - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - api_version = "1.0.0" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validation_of_body.metadata["url"] # type: ignore - path_format_arguments = { - "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), - "resourceGroupName": self._serialize.url( - "resource_group_name", resource_group_name, "str", max_length=10, min_length=3, pattern=r"[a-zA-Z0-9]+" - ), - "id": self._serialize.url("id", id, "int", maximum=1000, minimum=100, multiple=10), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["apiVersion"] = self._serialize.query("api_version", api_version, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validation_of_body.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore - - @distributed_trace - def get_with_constant_in_path( - self, **kwargs # type: Any - ): - # type: (...) -> None - """get_with_constant_in_path. - - :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", {})) - constant_param = "constant" - - # Construct URL - url = self.get_with_constant_in_path.metadata["url"] # type: ignore - path_format_arguments = { - "constantParam": self._serialize.url("constant_param", constant_param, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - get_with_constant_in_path.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore - - @distributed_trace - def post_with_constant_in_body( - self, - body=None, # type: Optional["_models.Product"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" - """post_with_constant_in_body. - - :param body: - :type body: ~validation.models.Product - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Product, or the result of cls(response) - :rtype: ~validation.models.Product - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - constant_param = "constant" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.post_with_constant_in_body.metadata["url"] # type: ignore - path_format_arguments = { - "constantParam": self._serialize.url("constant_param", constant_param, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, "Product") - else: - body_content = None - body_content_kwargs["content"] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Product", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - post_with_constant_in_body.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/setup.py b/test/vanilla/Expected/AcceptanceTests/Xml/setup.py deleted file mode 100644 index a1080d5e8c2..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Xml/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "autorestswaggerbatxmlservice" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="AutoRestSwaggerBATXMLService", - author_email="", - url="", - keywords=["Swagger", "AutoRestSwaggerBATXMLService"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - Test Infrastructure for AutoRest Swagger BAT. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_auto_rest_swagger_batxml_service.py b/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_auto_rest_swagger_batxml_service.py deleted file mode 100644 index ddcc7f102ed..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_auto_rest_swagger_batxml_service.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AutoRestSwaggerBATXMLServiceConfiguration -from .operations import XmlOperations -from . import models - - -class AutoRestSwaggerBATXMLService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar xml: XmlOperations operations - :vartype xml: xmlservice.operations.XmlOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATXMLServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.xml = XmlOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> AutoRestSwaggerBATXMLService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/_auto_rest_swagger_batxml_service.py b/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/_auto_rest_swagger_batxml_service.py deleted file mode 100644 index 1e119808677..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/_auto_rest_swagger_batxml_service.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import AutoRestSwaggerBATXMLServiceConfiguration -from .operations import XmlOperations -from .. import models - - -class AutoRestSwaggerBATXMLService(object): - """Test Infrastructure for AutoRest Swagger BAT. - - :ivar xml: XmlOperations operations - :vartype xml: xmlservice.aio.operations.XmlOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost:3000" - self._config = AutoRestSwaggerBATXMLServiceConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.xml = XmlOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutoRestSwaggerBATXMLService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py b/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py deleted file mode 100644 index 6c593a1eff6..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py +++ /dev/null @@ -1,1505 +0,0 @@ -# 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, Callable, Dict, Generic, List, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class XmlOperations: - """XmlOperations 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: ~xmlservice.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 get_complex_type_ref_no_meta(self, **kwargs: Any) -> "_models.RootWithRefAndNoMeta": - """Get a complex type that has a ref to a complex type with no XML node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RootWithRefAndNoMeta, or the result of cls(response) - :rtype: ~xmlservice.models.RootWithRefAndNoMeta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndNoMeta"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_complex_type_ref_no_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("RootWithRefAndNoMeta", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore - - @distributed_trace_async - async def put_complex_type_ref_no_meta(self, model: "_models.RootWithRefAndNoMeta", **kwargs: Any) -> None: - """Puts a complex type that has a ref to a complex type with no XML node. - - :param model: - :type model: ~xmlservice.models.RootWithRefAndNoMeta - :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/xml") - - # Construct URL - url = self.put_complex_type_ref_no_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(model, "RootWithRefAndNoMeta", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore - - @distributed_trace_async - async def get_complex_type_ref_with_meta(self, **kwargs: Any) -> "_models.RootWithRefAndMeta": - """Get a complex type that has a ref to a complex type with XML node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RootWithRefAndMeta, or the result of cls(response) - :rtype: ~xmlservice.models.RootWithRefAndMeta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndMeta"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_complex_type_ref_with_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("RootWithRefAndMeta", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore - - @distributed_trace_async - async def put_complex_type_ref_with_meta(self, model: "_models.RootWithRefAndMeta", **kwargs: Any) -> None: - """Puts a complex type that has a ref to a complex type with XML node. - - :param model: - :type model: ~xmlservice.models.RootWithRefAndMeta - :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/xml") - - # Construct URL - url = self.put_complex_type_ref_with_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(model, "RootWithRefAndMeta", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore - - @distributed_trace_async - async def get_simple(self, **kwargs: Any) -> "_models.Slideshow": - """Get a simple XML document. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Slideshow, or the result of cls(response) - :rtype: ~xmlservice.models.Slideshow - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_simple.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Slideshow", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_simple.metadata = {"url": "/xml/simple"} # type: ignore - - @distributed_trace_async - async def put_simple(self, slideshow: "_models.Slideshow", **kwargs: Any) -> None: - """Put a simple XML document. - - :param slideshow: - :type slideshow: ~xmlservice.models.Slideshow - :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/xml") - accept = "application/xml" - - # Construct URL - url = self.put_simple.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(slideshow, "Slideshow", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_simple.metadata = {"url": "/xml/simple"} # type: ignore - - @distributed_trace_async - async def get_wrapped_lists(self, **kwargs: Any) -> "_models.AppleBarrel": - """Get an XML document with multiple wrapped lists. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppleBarrel, or the result of cls(response) - :rtype: ~xmlservice.models.AppleBarrel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("AppleBarrel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore - - @distributed_trace_async - async def put_wrapped_lists(self, wrapped_lists: "_models.AppleBarrel", **kwargs: Any) -> None: - """Put an XML document with multiple wrapped lists. - - :param wrapped_lists: - :type wrapped_lists: ~xmlservice.models.AppleBarrel - :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/xml") - accept = "application/xml" - - # Construct URL - url = self.put_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(wrapped_lists, "AppleBarrel", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore - - @distributed_trace_async - async def get_headers(self, **kwargs: Any) -> None: - """Get strongly-typed response headers. - - :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", {})) - - # Construct URL - url = self.get_headers.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["Custom-Header"] = self._deserialize("str", response.headers.get("Custom-Header")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get_headers.metadata = {"url": "/xml/headers"} # type: ignore - - @distributed_trace_async - async def get_empty_list(self, **kwargs: Any) -> "_models.Slideshow": - """Get an empty list. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Slideshow, or the result of cls(response) - :rtype: ~xmlservice.models.Slideshow - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Slideshow", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore - - @distributed_trace_async - async def put_empty_list(self, slideshow: "_models.Slideshow", **kwargs: Any) -> None: - """Puts an empty list. - - :param slideshow: - :type slideshow: ~xmlservice.models.Slideshow - :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/xml") - - # Construct URL - url = self.put_empty_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(slideshow, "Slideshow", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore - - @distributed_trace_async - async def get_empty_wrapped_lists(self, **kwargs: Any) -> "_models.AppleBarrel": - """Gets some empty wrapped lists. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppleBarrel, or the result of cls(response) - :rtype: ~xmlservice.models.AppleBarrel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("AppleBarrel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore - - @distributed_trace_async - async def put_empty_wrapped_lists(self, apple_barrel: "_models.AppleBarrel", **kwargs: Any) -> None: - """Puts some empty wrapped lists. - - :param apple_barrel: - :type apple_barrel: ~xmlservice.models.AppleBarrel - :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/xml") - - # Construct URL - url = self.put_empty_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(apple_barrel, "AppleBarrel", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore - - @distributed_trace_async - async def get_root_list(self, **kwargs: Any) -> List["_models.Banana"]: - """Gets a list as the root element. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Banana, or the result of cls(response) - :rtype: list[~xmlservice.models.Banana] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[Banana]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_root_list.metadata = {"url": "/xml/root-list"} # type: ignore - - @distributed_trace_async - async def put_root_list(self, bananas: List["_models.Banana"], **kwargs: Any) -> None: - """Puts a list as the root element. - - :param bananas: - :type bananas: list[~xmlservice.models.Banana] - :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/xml") - - # Construct URL - url = self.put_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} - body_content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_root_list.metadata = {"url": "/xml/root-list"} # type: ignore - - @distributed_trace_async - async def get_root_list_single_item(self, **kwargs: Any) -> List["_models.Banana"]: - """Gets a list with a single item. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Banana, or the result of cls(response) - :rtype: list[~xmlservice.models.Banana] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_root_list_single_item.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[Banana]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore - - @distributed_trace_async - async def put_root_list_single_item(self, bananas: List["_models.Banana"], **kwargs: Any) -> None: - """Puts a list with a single item. - - :param bananas: - :type bananas: list[~xmlservice.models.Banana] - :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/xml") - - # Construct URL - url = self.put_root_list_single_item.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} - body_content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore - - @distributed_trace_async - async def get_empty_root_list(self, **kwargs: Any) -> List["_models.Banana"]: - """Gets an empty list as the root element. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Banana, or the result of cls(response) - :rtype: list[~xmlservice.models.Banana] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[Banana]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore - - @distributed_trace_async - async def put_empty_root_list(self, bananas: List["_models.Banana"], **kwargs: Any) -> None: - """Puts an empty list as the root element. - - :param bananas: - :type bananas: list[~xmlservice.models.Banana] - :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/xml") - - # Construct URL - url = self.put_empty_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} - body_content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore - - @distributed_trace_async - async def get_empty_child_element(self, **kwargs: Any) -> "_models.Banana": - """Gets an XML document with an empty child element. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Banana, or the result of cls(response) - :rtype: ~xmlservice.models.Banana - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Banana"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_child_element.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Banana", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore - - @distributed_trace_async - async def put_empty_child_element(self, banana: "_models.Banana", **kwargs: Any) -> None: - """Puts a value with an empty child element. - - :param banana: - :type banana: ~xmlservice.models.Banana - :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/xml") - - # Construct URL - url = self.put_empty_child_element.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(banana, "Banana", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore - - @distributed_trace_async - async def list_containers(self, **kwargs: Any) -> "_models.ListContainersResponse": - """Lists containers in a storage account. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainersResponse, or the result of cls(response) - :rtype: ~xmlservice.models.ListContainersResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ListContainersResponse"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "list" - accept = "application/xml" - - # Construct URL - url = self.list_containers.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ListContainersResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_containers.metadata = {"url": "/xml/"} # type: ignore - - @distributed_trace_async - async def get_service_properties(self, **kwargs: Any) -> "_models.StorageServiceProperties": - """Gets storage service properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageServiceProperties, or the result of cls(response) - :rtype: ~xmlservice.models.StorageServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageServiceProperties"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "properties" - restype = "service" - accept = "application/xml" - - # Construct URL - url = self.get_service_properties.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("StorageServiceProperties", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_service_properties.metadata = {"url": "/xml/"} # type: ignore - - @distributed_trace_async - async def put_service_properties(self, properties: "_models.StorageServiceProperties", **kwargs: Any) -> None: - """Puts storage service properties. - - :param properties: - :type properties: ~xmlservice.models.StorageServiceProperties - :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", {})) - comp = "properties" - restype = "service" - content_type = kwargs.pop("content_type", "application/xml") - - # Construct URL - url = self.put_service_properties.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, "StorageServiceProperties", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_service_properties.metadata = {"url": "/xml/"} # type: ignore - - @distributed_trace_async - async def get_acls(self, **kwargs: Any) -> List["_models.SignedIdentifier"]: - """Gets storage ACLs for a container. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of SignedIdentifier, or the result of cls(response) - :rtype: list[~xmlservice.models.SignedIdentifier] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.SignedIdentifier"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "acl" - restype = "container" - accept = "application/xml" - - # Construct URL - url = self.get_acls.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[SignedIdentifier]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore - - @distributed_trace_async - async def put_acls(self, properties: List["_models.SignedIdentifier"], **kwargs: Any) -> None: - """Puts storage ACLs for a container. - - :param properties: - :type properties: list[~xmlservice.models.SignedIdentifier] - :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", {})) - comp = "acl" - restype = "container" - content_type = kwargs.pop("content_type", "application/xml") - - # Construct URL - url = self.put_acls.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "SignedIdentifiers", "wrapped": True, "itemsName": "SignedIdentifier"}} - body_content = self._serialize.body( - properties, "[SignedIdentifier]", is_xml=True, serialization_ctxt=serialization_ctxt - ) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore - - @distributed_trace_async - async def list_blobs(self, **kwargs: Any) -> "_models.ListBlobsResponse": - """Lists blobs in a storage container. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListBlobsResponse, or the result of cls(response) - :rtype: ~xmlservice.models.ListBlobsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ListBlobsResponse"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "list" - restype = "container" - accept = "application/xml" - - # Construct URL - url = self.list_blobs.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ListBlobsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_blobs.metadata = {"url": "/xml/mycontainer"} # type: ignore - - @distributed_trace_async - async def json_input(self, id: Optional[int] = None, **kwargs: Any) -> None: - """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID - number 42. - - :param id: - :type id: int - :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", {})) - - _properties = _models.JSONInput(id=id) - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.json_input.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_properties, "JSONInput") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - json_input.metadata = {"url": "/xml/jsoninput"} # type: ignore - - @distributed_trace_async - async def json_output(self, **kwargs: Any) -> "_models.JSONOutput": - """A Swagger with XML that has one operation that returns JSON. ID number 42. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JSONOutput, or the result of cls(response) - :rtype: ~xmlservice.models.JSONOutput - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.JSONOutput"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.json_output.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("JSONOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - json_output.metadata = {"url": "/xml/jsonoutput"} # type: ignore - - @distributed_trace_async - async def get_xms_text(self, **kwargs: Any) -> "_models.ObjectWithXMsTextProperty": - """Get back an XML object with an x-ms-text property, which should translate to the returned - object's 'language' property being 'english' and its 'content' property being 'I am text'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectWithXMsTextProperty, or the result of cls(response) - :rtype: ~xmlservice.models.ObjectWithXMsTextProperty - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ObjectWithXMsTextProperty"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_xms_text.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ObjectWithXMsTextProperty", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_xms_text.metadata = {"url": "/xml/x-ms-text"} # type: ignore - - @distributed_trace_async - async def get_bytes(self, **kwargs: Any) -> "_models.ModelWithByteProperty": - """Get an XML document with binary property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ModelWithByteProperty, or the result of cls(response) - :rtype: ~xmlservice.models.ModelWithByteProperty - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithByteProperty"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_bytes.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ModelWithByteProperty", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_bytes.metadata = {"url": "/xml/bytes"} # type: ignore - - @distributed_trace_async - async def put_binary(self, bytes: Optional[bytearray] = None, **kwargs: Any) -> None: - """Put an XML document with binary property. - - :param bytes: - :type bytes: bytearray - :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", {})) - - _slideshow = _models.ModelWithByteProperty(bytes=bytes) - content_type = kwargs.pop("content_type", "application/xml") - accept = "application/xml" - - # Construct URL - url = self.put_binary.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_slideshow, "ModelWithByteProperty", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_binary.metadata = {"url": "/xml/bytes"} # type: ignore - - @distributed_trace_async - async def get_uri(self, **kwargs: Any) -> "_models.ModelWithUrlProperty": - """Get an XML document with uri property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ModelWithUrlProperty, or the result of cls(response) - :rtype: ~xmlservice.models.ModelWithUrlProperty - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithUrlProperty"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_uri.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ModelWithUrlProperty", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uri.metadata = {"url": "/xml/url"} # type: ignore - - @distributed_trace_async - async def put_uri(self, url: Optional[str] = None, **kwargs: Any) -> None: - """Put an XML document with uri property. - - :param url: - :type url: 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", {})) - - _model = _models.ModelWithUrlProperty(url=url) - content_type = kwargs.pop("content_type", "application/xml") - accept = "application/xml" - - # Construct URL - url = self.put_uri.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_model, "ModelWithUrlProperty", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_uri.metadata = {"url": "/xml/url"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py b/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py deleted file mode 100644 index 9d6098ffae1..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py +++ /dev/null @@ -1,1641 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar("T") - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class XmlOperations(object): - """XmlOperations 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: ~xmlservice.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 get_complex_type_ref_no_meta( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.RootWithRefAndNoMeta" - """Get a complex type that has a ref to a complex type with no XML node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RootWithRefAndNoMeta, or the result of cls(response) - :rtype: ~xmlservice.models.RootWithRefAndNoMeta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndNoMeta"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_complex_type_ref_no_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("RootWithRefAndNoMeta", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore - - @distributed_trace - def put_complex_type_ref_no_meta( - self, - model, # type: "_models.RootWithRefAndNoMeta" - **kwargs # type: Any - ): - # type: (...) -> None - """Puts a complex type that has a ref to a complex type with no XML node. - - :param model: - :type model: ~xmlservice.models.RootWithRefAndNoMeta - :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/xml") - - # Construct URL - url = self.put_complex_type_ref_no_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(model, "RootWithRefAndNoMeta", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore - - @distributed_trace - def get_complex_type_ref_with_meta( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.RootWithRefAndMeta" - """Get a complex type that has a ref to a complex type with XML node. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RootWithRefAndMeta, or the result of cls(response) - :rtype: ~xmlservice.models.RootWithRefAndMeta - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndMeta"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_complex_type_ref_with_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("RootWithRefAndMeta", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore - - @distributed_trace - def put_complex_type_ref_with_meta( - self, - model, # type: "_models.RootWithRefAndMeta" - **kwargs # type: Any - ): - # type: (...) -> None - """Puts a complex type that has a ref to a complex type with XML node. - - :param model: - :type model: ~xmlservice.models.RootWithRefAndMeta - :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/xml") - - # Construct URL - url = self.put_complex_type_ref_with_meta.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(model, "RootWithRefAndMeta", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore - - @distributed_trace - def get_simple( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Slideshow" - """Get a simple XML document. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Slideshow, or the result of cls(response) - :rtype: ~xmlservice.models.Slideshow - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_simple.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("Slideshow", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_simple.metadata = {"url": "/xml/simple"} # type: ignore - - @distributed_trace - def put_simple( - self, - slideshow, # type: "_models.Slideshow" - **kwargs # type: Any - ): - # type: (...) -> None - """Put a simple XML document. - - :param slideshow: - :type slideshow: ~xmlservice.models.Slideshow - :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/xml") - accept = "application/xml" - - # Construct URL - url = self.put_simple.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(slideshow, "Slideshow", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_simple.metadata = {"url": "/xml/simple"} # type: ignore - - @distributed_trace - def get_wrapped_lists( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.AppleBarrel" - """Get an XML document with multiple wrapped lists. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppleBarrel, or the result of cls(response) - :rtype: ~xmlservice.models.AppleBarrel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("AppleBarrel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore - - @distributed_trace - def put_wrapped_lists( - self, - wrapped_lists, # type: "_models.AppleBarrel" - **kwargs # type: Any - ): - # type: (...) -> None - """Put an XML document with multiple wrapped lists. - - :param wrapped_lists: - :type wrapped_lists: ~xmlservice.models.AppleBarrel - :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/xml") - accept = "application/xml" - - # Construct URL - url = self.put_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(wrapped_lists, "AppleBarrel", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore - - @distributed_trace - def get_headers( - self, **kwargs # type: Any - ): - # type: (...) -> None - """Get strongly-typed response headers. - - :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", {})) - - # Construct URL - url = self.get_headers.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["Custom-Header"] = self._deserialize("str", response.headers.get("Custom-Header")) - - if cls: - return cls(pipeline_response, None, response_headers) - - get_headers.metadata = {"url": "/xml/headers"} # type: ignore - - @distributed_trace - def get_empty_list( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Slideshow" - """Get an empty list. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Slideshow, or the result of cls(response) - :rtype: ~xmlservice.models.Slideshow - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Slideshow", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore - - @distributed_trace - def put_empty_list( - self, - slideshow, # type: "_models.Slideshow" - **kwargs # type: Any - ): - # type: (...) -> None - """Puts an empty list. - - :param slideshow: - :type slideshow: ~xmlservice.models.Slideshow - :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/xml") - - # Construct URL - url = self.put_empty_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(slideshow, "Slideshow", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore - - @distributed_trace - def get_empty_wrapped_lists( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.AppleBarrel" - """Gets some empty wrapped lists. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AppleBarrel, or the result of cls(response) - :rtype: ~xmlservice.models.AppleBarrel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("AppleBarrel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore - - @distributed_trace - def put_empty_wrapped_lists( - self, - apple_barrel, # type: "_models.AppleBarrel" - **kwargs # type: Any - ): - # type: (...) -> None - """Puts some empty wrapped lists. - - :param apple_barrel: - :type apple_barrel: ~xmlservice.models.AppleBarrel - :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/xml") - - # Construct URL - url = self.put_empty_wrapped_lists.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(apple_barrel, "AppleBarrel", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore - - @distributed_trace - def get_root_list( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Banana"] - """Gets a list as the root element. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Banana, or the result of cls(response) - :rtype: list[~xmlservice.models.Banana] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[Banana]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_root_list.metadata = {"url": "/xml/root-list"} # type: ignore - - @distributed_trace - def put_root_list( - self, - bananas, # type: List["_models.Banana"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts a list as the root element. - - :param bananas: - :type bananas: list[~xmlservice.models.Banana] - :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/xml") - - # Construct URL - url = self.put_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} - body_content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_root_list.metadata = {"url": "/xml/root-list"} # type: ignore - - @distributed_trace - def get_root_list_single_item( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Banana"] - """Gets a list with a single item. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Banana, or the result of cls(response) - :rtype: list[~xmlservice.models.Banana] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_root_list_single_item.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[Banana]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore - - @distributed_trace - def put_root_list_single_item( - self, - bananas, # type: List["_models.Banana"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts a list with a single item. - - :param bananas: - :type bananas: list[~xmlservice.models.Banana] - :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/xml") - - # Construct URL - url = self.put_root_list_single_item.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} - body_content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore - - @distributed_trace - def get_empty_root_list( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.Banana"] - """Gets an empty list as the root element. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of Banana, or the result of cls(response) - :rtype: list[~xmlservice.models.Banana] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[Banana]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore - - @distributed_trace - def put_empty_root_list( - self, - bananas, # type: List["_models.Banana"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts an empty list as the root element. - - :param bananas: - :type bananas: list[~xmlservice.models.Banana] - :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/xml") - - # Construct URL - url = self.put_empty_root_list.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} - body_content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore - - @distributed_trace - def get_empty_child_element( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.Banana" - """Gets an XML document with an empty child element. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Banana, or the result of cls(response) - :rtype: ~xmlservice.models.Banana - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.Banana"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_empty_child_element.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("Banana", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore - - @distributed_trace - def put_empty_child_element( - self, - banana, # type: "_models.Banana" - **kwargs # type: Any - ): - # type: (...) -> None - """Puts a value with an empty child element. - - :param banana: - :type banana: ~xmlservice.models.Banana - :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/xml") - - # Construct URL - url = self.put_empty_child_element.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(banana, "Banana", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore - - @distributed_trace - def list_containers( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ListContainersResponse" - """Lists containers in a storage account. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainersResponse, or the result of cls(response) - :rtype: ~xmlservice.models.ListContainersResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ListContainersResponse"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "list" - accept = "application/xml" - - # Construct URL - url = self.list_containers.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ListContainersResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_containers.metadata = {"url": "/xml/"} # type: ignore - - @distributed_trace - def get_service_properties( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.StorageServiceProperties" - """Gets storage service properties. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageServiceProperties, or the result of cls(response) - :rtype: ~xmlservice.models.StorageServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageServiceProperties"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "properties" - restype = "service" - accept = "application/xml" - - # Construct URL - url = self.get_service_properties.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("StorageServiceProperties", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_service_properties.metadata = {"url": "/xml/"} # type: ignore - - @distributed_trace - def put_service_properties( - self, - properties, # type: "_models.StorageServiceProperties" - **kwargs # type: Any - ): - # type: (...) -> None - """Puts storage service properties. - - :param properties: - :type properties: ~xmlservice.models.StorageServiceProperties - :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", {})) - comp = "properties" - restype = "service" - content_type = kwargs.pop("content_type", "application/xml") - - # Construct URL - url = self.put_service_properties.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, "StorageServiceProperties", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_service_properties.metadata = {"url": "/xml/"} # type: ignore - - @distributed_trace - def get_acls( - self, **kwargs # type: Any - ): - # type: (...) -> List["_models.SignedIdentifier"] - """Gets storage ACLs for a container. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of SignedIdentifier, or the result of cls(response) - :rtype: list[~xmlservice.models.SignedIdentifier] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[List["_models.SignedIdentifier"]] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "acl" - restype = "container" - accept = "application/xml" - - # Construct URL - url = self.get_acls.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("[SignedIdentifier]", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore - - @distributed_trace - def put_acls( - self, - properties, # type: List["_models.SignedIdentifier"] - **kwargs # type: Any - ): - # type: (...) -> None - """Puts storage ACLs for a container. - - :param properties: - :type properties: list[~xmlservice.models.SignedIdentifier] - :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", {})) - comp = "acl" - restype = "container" - content_type = kwargs.pop("content_type", "application/xml") - - # Construct URL - url = self.put_acls.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - serialization_ctxt = {"xml": {"name": "SignedIdentifiers", "wrapped": True, "itemsName": "SignedIdentifier"}} - body_content = self._serialize.body( - properties, "[SignedIdentifier]", is_xml=True, serialization_ctxt=serialization_ctxt - ) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - put_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore - - @distributed_trace - def list_blobs( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ListBlobsResponse" - """Lists blobs in a storage container. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListBlobsResponse, or the result of cls(response) - :rtype: ~xmlservice.models.ListBlobsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ListBlobsResponse"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - comp = "list" - restype = "container" - accept = "application/xml" - - # Construct URL - url = self.list_blobs.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters["comp"] = self._serialize.query("comp", comp, "str") - query_parameters["restype"] = self._serialize.query("restype", restype, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ListBlobsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_blobs.metadata = {"url": "/xml/mycontainer"} # type: ignore - - @distributed_trace - def json_input( - self, - id=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> None - """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID - number 42. - - :param id: - :type id: int - :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", {})) - - _properties = _models.JSONInput(id=id) - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.json_input.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_properties, "JSONInput") - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - json_input.metadata = {"url": "/xml/jsoninput"} # type: ignore - - @distributed_trace - def json_output( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.JSONOutput" - """A Swagger with XML that has one operation that returns JSON. ID number 42. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JSONOutput, or the result of cls(response) - :rtype: ~xmlservice.models.JSONOutput - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.JSONOutput"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.json_output.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("JSONOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - json_output.metadata = {"url": "/xml/jsonoutput"} # type: ignore - - @distributed_trace - def get_xms_text( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ObjectWithXMsTextProperty" - """Get back an XML object with an x-ms-text property, which should translate to the returned - object's 'language' property being 'english' and its 'content' property being 'I am text'. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectWithXMsTextProperty, or the result of cls(response) - :rtype: ~xmlservice.models.ObjectWithXMsTextProperty - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ObjectWithXMsTextProperty"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_xms_text.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("ObjectWithXMsTextProperty", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_xms_text.metadata = {"url": "/xml/x-ms-text"} # type: ignore - - @distributed_trace - def get_bytes( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ModelWithByteProperty" - """Get an XML document with binary property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ModelWithByteProperty, or the result of cls(response) - :rtype: ~xmlservice.models.ModelWithByteProperty - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithByteProperty"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_bytes.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ModelWithByteProperty", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_bytes.metadata = {"url": "/xml/bytes"} # type: ignore - - @distributed_trace - def put_binary( - self, - bytes=None, # type: Optional[bytearray] - **kwargs # type: Any - ): - # type: (...) -> None - """Put an XML document with binary property. - - :param bytes: - :type bytes: bytearray - :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", {})) - - _slideshow = _models.ModelWithByteProperty(bytes=bytes) - content_type = kwargs.pop("content_type", "application/xml") - accept = "application/xml" - - # Construct URL - url = self.put_binary.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_slideshow, "ModelWithByteProperty", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_binary.metadata = {"url": "/xml/bytes"} # type: ignore - - @distributed_trace - def get_uri( - self, **kwargs # type: Any - ): - # type: (...) -> "_models.ModelWithUrlProperty" - """Get an XML document with uri property. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ModelWithUrlProperty, or the result of cls(response) - :rtype: ~xmlservice.models.ModelWithUrlProperty - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithUrlProperty"] - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop("error_map", {})) - accept = "application/xml" - - # Construct URL - url = self.get_uri.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("ModelWithUrlProperty", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_uri.metadata = {"url": "/xml/url"} # type: ignore - - @distributed_trace - def put_uri( - self, - url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Put an XML document with uri property. - - :param url: - :type url: 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", {})) - - _model = _models.ModelWithUrlProperty(url=url) - content_type = kwargs.pop("content_type", "application/xml") - accept = "application/xml" - - # Construct URL - url = self.put_uri.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_model, "ModelWithUrlProperty", is_xml=True) - body_content_kwargs["content"] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - put_uri.metadata = {"url": "/xml/url"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/setup.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/setup.py deleted file mode 100644 index 0af1b27e8f0..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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 = "xmserrorresponseextensions" -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.8.2"] - -setup( - name=NAME, - version=VERSION, - description="XMSErrorResponseExtensions", - author_email="", - url="", - keywords=["Swagger", "XMSErrorResponseExtensions"], - install_requires=REQUIRES, - packages=find_packages(), - include_package_data=True, - long_description="""\ - XMS Error Response Extensions. - """, -) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_xms_error_response_extensions.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_xms_error_response_extensions.py deleted file mode 100644 index 58d0a37afd7..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_xms_error_response_extensions.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import XMSErrorResponseExtensionsConfiguration -from .operations import PetOperations -from . import models - - -class XMSErrorResponseExtensions(object): - """XMS Error Response Extensions. - - :ivar pet: PetOperations operations - :vartype pet: xmserrorresponse.operations.PetOperations - :param str base_url: Service URL - """ - - def __init__( - self, - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = "http://localhost" - self._config = XMSErrorResponseExtensionsConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.pet = PetOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> XMSErrorResponseExtensions - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_xms_error_response_extensions.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_xms_error_response_extensions.py deleted file mode 100644 index d91413ad63e..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_xms_error_response_extensions.py +++ /dev/null @@ -1,63 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -from ._configuration import XMSErrorResponseExtensionsConfiguration -from .operations import PetOperations -from .. import models - - -class XMSErrorResponseExtensions(object): - """XMS Error Response Extensions. - - :ivar pet: PetOperations operations - :vartype pet: xmserrorresponse.aio.operations.PetOperations - :param str base_url: Service URL - """ - - def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: - if not base_url: - base_url = "http://localhost" - self._config = XMSErrorResponseExtensionsConfiguration(**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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.pet = PetOperations(self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "XMSErrorResponseExtensions": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py deleted file mode 100644 index 9fb98eee475..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py +++ /dev/null @@ -1,211 +0,0 @@ -# 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, 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, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ... import models as _models - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PetOperations: - """PetOperations 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: ~xmserrorresponse.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 get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional["_models.Pet"]: - """Gets pets by id. - - :param pet_id: pet id. - :type pet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~xmserrorresponse.models.Pet or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Pet"]] - error_map = { - 401: ClientAuthenticationError, - 409: ResourceExistsError, - 400: HttpResponseError, - 404: lambda response: ResourceNotFoundError( - response=response, model=self._deserialize(_models.NotFoundErrorBase, response) - ), - 501: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_pet_by_id.metadata["url"] # type: ignore - path_format_arguments = { - "petId": self._serialize.url("pet_id", pet_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_pet_by_id.metadata = {"url": "/errorStatusCodes/Pets/{petId}/GetPet"} # type: ignore - - @distributed_trace_async - async def do_something(self, what_action: str, **kwargs: Any) -> "_models.PetAction": - """Asks pet to do something. - - :param what_action: what action the pet should do. - :type what_action: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAction, or the result of cls(response) - :rtype: ~xmserrorresponse.models.PetAction - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAction"] - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 500: lambda response: HttpResponseError( - response=response, model=self._deserialize(_models.PetActionError, response) - ), - } - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.do_something.metadata["url"] # type: ignore - path_format_arguments = { - "whatAction": self._serialize.url("what_action", what_action, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAction", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - do_something.metadata = {"url": "/errorStatusCodes/Pets/doSomething/{whatAction}"} # type: ignore - - @distributed_trace_async - async def has_models_param(self, models: Optional[str] = "value1", **kwargs: Any) -> None: - """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't - conflict with the input param name 'models'. - - :param models: Make sure model deserialization doesn't conflict with this param name, which has - input name 'models'. Use client default value in call. - :type models: 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, - 500: lambda response: HttpResponseError( - response=response, model=self._deserialize(_models.PetActionError, response) - ), - } - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.has_models_param.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if models is not None: - query_parameters["models"] = self._serialize.query("models", models, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - has_models_param.metadata = {"url": "/errorStatusCodes/Pets/hasModelsParam"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py deleted file mode 100644 index 8604d93313f..00000000000 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py +++ /dev/null @@ -1,230 +0,0 @@ -# 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 -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .. import models as _models - -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]] - - -class PetOperations(object): - """PetOperations 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: ~xmserrorresponse.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 get_pet_by_id( - self, - pet_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Pet"] - """Gets pets by id. - - :param pet_id: pet id. - :type pet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pet, or the result of cls(response) - :rtype: ~xmserrorresponse.models.Pet or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Pet"]] - error_map = { - 401: ClientAuthenticationError, - 409: ResourceExistsError, - 400: HttpResponseError, - 404: lambda response: ResourceNotFoundError( - response=response, model=self._deserialize(_models.NotFoundErrorBase, response) - ), - 501: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.get_pet_by_id.metadata["url"] # type: ignore - path_format_arguments = { - "petId": self._serialize.url("pet_id", pet_id, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Pet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_pet_by_id.metadata = {"url": "/errorStatusCodes/Pets/{petId}/GetPet"} # type: ignore - - @distributed_trace - def do_something( - self, - what_action, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PetAction" - """Asks pet to do something. - - :param what_action: what action the pet should do. - :type what_action: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PetAction, or the result of cls(response) - :rtype: ~xmserrorresponse.models.PetAction - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAction"] - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 500: lambda response: HttpResponseError( - response=response, model=self._deserialize(_models.PetActionError, response) - ), - } - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.do_something.metadata["url"] # type: ignore - path_format_arguments = { - "whatAction": self._serialize.url("what_action", what_action, "str"), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize("PetAction", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - do_something.metadata = {"url": "/errorStatusCodes/Pets/doSomething/{whatAction}"} # type: ignore - - @distributed_trace - def has_models_param( - self, - models="value1", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't - conflict with the input param name 'models'. - - :param models: Make sure model deserialization doesn't conflict with this param name, which has - input name 'models'. Use client default value in call. - :type models: 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, - 500: lambda response: HttpResponseError( - response=response, model=self._deserialize(_models.PetActionError, response) - ), - } - error_map.update(kwargs.pop("error_map", {})) - accept = "application/json" - - # Construct URL - url = self.has_models_param.metadata["url"] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if models is not None: - query_parameters["models"] = self._serialize.query("models", models, "str") - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters["Accept"] = self._serialize.header("accept", accept, "str") - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - has_models_param.metadata = {"url": "/errorStatusCodes/Pets/hasModelsParam"} # type: ignore diff --git a/test/vanilla/Python.Tests.pyproj b/test/vanilla/Python.Tests.pyproj deleted file mode 100644 index 82da9073dce..00000000000 --- a/test/vanilla/Python.Tests.pyproj +++ /dev/null @@ -1 +0,0 @@ -autorest F:\azure_rest_api_specs_venv\azure-rest-api-specs\specification\compute\resource-manager\readme.md --python --use=F:\autorest.python --python=update --multiapi --python-sdks-folder=F:\azure_sdk_python_virtualenv\Scripts\azure-sdk-for-python \ No newline at end of file diff --git a/test/vanilla/app.config b/test/vanilla/app.config deleted file mode 100644 index 3e39b50f08a..00000000000 --- a/test/vanilla/app.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/vanilla/AcceptanceTests/asynctests/__init__.py b/test/vanilla/legacy/AcceptanceTests/__init__.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/__init__.py rename to test/vanilla/legacy/AcceptanceTests/__init__.py diff --git a/test/vanilla/legacy/AcceptanceTests/asynctests/__init__.py b/test/vanilla/legacy/AcceptanceTests/asynctests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/vanilla/AcceptanceTests/asynctests/test_additional_properties.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_additional_properties.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_additional_properties.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_additional_properties.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_anything.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_anything.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_anything.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_anything.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_array.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_array.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_array.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_array.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_bool.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_bool.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_bool.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_bool.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_byte.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_byte.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_byte.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_byte.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_complex.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_complex.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_complex.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_complex.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_config.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_config.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_config.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_config.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_custom_base_uri.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_custom_base_uri.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_custom_base_uri.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_custom_base_uri.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_date.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_date.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_date.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_date.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_datetime.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_datetime.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_datetime.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_datetime.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_datetime_rfc.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_datetime_rfc.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_datetime_rfc.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_datetime_rfc.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_dictionary.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_dictionary.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_dictionary.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_dictionary.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_duration.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_duration.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_duration.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_duration.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_extensible_enums.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_extensible_enums.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_extensible_enums.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_extensible_enums.py diff --git a/test/vanilla/legacy/AcceptanceTests/asynctests/test_file.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_file.py new file mode 100644 index 00000000000..848ef6551fa --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/asynctests/test_file.py @@ -0,0 +1,147 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +import unittest +import subprocess +import sys +import isodate +import tempfile +import io +from datetime import date, datetime, timedelta +import os +from os.path import dirname, pardir, join, realpath + +from msrest.exceptions import DeserializationError + +from bodyfile.aio import AutoRestSwaggerBATFileService + +import pytest + +cwd = dirname(realpath(__file__)) + + +@pytest.fixture +@async_generator +async def client(connection_data_block_size=None): + async with AutoRestSwaggerBATFileService( + base_url="http://localhost:3000", connection_data_block_size=connection_data_block_size + ) as client: + await yield_(client) + +@pytest.fixture +def callback(): + def _callback(response, data_stream, headers): + assert not data_stream.response.internal_response._released + return data_stream + return _callback + +class TestFile(object): + @pytest.mark.asyncio + @pytest.mark.parametrize('client', [1000], indirect=True) + async def test_get_file(self, client): + file_length = 0 + with io.BytesIO() as file_handle: + stream = await client.files.get_file() + total = len(stream) + assert not stream.response.internal_response._released + + async for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + print("Downloading... {}%".format(int(file_length*100/total))) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + @pytest.mark.asyncio + @pytest.mark.parametrize('client', [4096], indirect=True) + async def test_get_empty_file(self, client): + file_length = 0 + with io.BytesIO() as file_handle: + stream = await client.files.get_empty_file() + assert len(stream) == 0 + assert not stream.response.internal_response._released + + async for data in stream: + file_length += len(data) + file_handle.write(data) + + assert file_length == 0 + + @pytest.mark.asyncio + @pytest.mark.parametrize('client', [4096], indirect=True) + async def test_files_long_running(self, client): + file_length = 0 + stream = await client.files.get_file_large() + async for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + + assert file_length == 3000 * 1024 * 1024 + + @pytest.mark.asyncio + @pytest.mark.parametrize('client', [None], indirect=True) + async def test_get_file_with_callback(self, client, callback): + file_length = 0 + with io.BytesIO() as file_handle: + stream = await client.files.get_file(cls=callback) + assert len(stream) > 0 + async for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + @pytest.mark.asyncio + @pytest.mark.parametrize('client', [None], indirect=True) + async def test_get_empty_file_with_callback(self, client, callback): + file_length = 0 + with io.BytesIO() as file_handle: + stream = await client.files.get_empty_file(cls=callback) + async for data in stream: + file_length += len(data) + file_handle.write(data) + + assert stream.response.internal_response._released + assert file_length == 0 diff --git a/test/vanilla/AcceptanceTests/asynctests/test_form_data.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_form_data.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_form_data.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_form_data.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_header.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_header.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_header.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_header.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_http.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_http.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_http.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_http.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_incorrect_error_response.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_incorrect_error_response.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_incorrect_error_response.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_incorrect_error_response.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_integer.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_integer.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_integer.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_integer.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_media_types.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_media_types.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_media_types.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_media_types.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_model_flattening.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_model_flattening.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_model_flattening.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_model_flattening.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_multiple_inheritance.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_multiple_inheritance.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_multiple_inheritance.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_multiple_inheritance.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_non_string_enums.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_non_string_enums.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_non_string_enums.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_non_string_enums.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_number.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_number.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_number.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_number.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_object_type.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_object_type.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_object_type.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_object_type.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_required_optional.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_required_optional.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_required_optional.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_required_optional.py diff --git a/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py new file mode 100644 index 00000000000..17eb32103f3 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/asynctests/test_send_request.py @@ -0,0 +1,229 @@ +# -------------------------------------------------------------------------- +# +# 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 io +import json + +from azure.core.pipeline.transport import HttpRequest + +from os.path import dirname, pardir, join, realpath +import pytest + +cwd = dirname(realpath(__file__)) + + +class TestSendRequest(object): + + @pytest.mark.asyncio + async def test_send_request_with_body_get_model_deserialize(self): + from bodycomplex.aio import AutoRestComplexTestService + from bodycomplex.models import Siamese + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + async with AutoRestComplexTestService(base_url="http://localhost:3000") as client: + response = await client._send_request(request) + + deserialized = Siamese.deserialize(response) + assert 2 == deserialized.id + assert "Siameeee" == deserialized.name + assert -1 == deserialized.hates[1].id + assert "Tomato" == deserialized.hates[1].name + + @pytest.mark.asyncio + async def test_send_request_with_body_get_direct_json(self): + from bodycomplex.aio import AutoRestComplexTestService + from bodycomplex.models import Siamese + + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + async with AutoRestComplexTestService(base_url="http://localhost:3000") as client: + response = await client._send_request(request, stream=True) + chunks = [] + async for chunk in response.stream_download(None): + chunks.append(chunk) + data = b''.join(chunks).decode('utf-8') + json_response = json.loads(data) + assert 2 == json_response['id'] + assert "Siameeee" == json_response['name'] + assert - 1 == json_response['hates'][1]['id'] + assert "Tomato" == json_response['hates'][1]['name'] + + @pytest.mark.asyncio + async def test_send_request_with_body_put_json_dumps(self): + from bodycomplex.aio import AutoRestComplexTestService + + siamese_body = { + "id": 2, + "name": "Siameeee", + "color": "green", + "hates": + [ + { + "id": 1, + "name": "Potato", + "food": "tomato" + }, + { + "id": -1, + "name": "Tomato", + "food": "french fries" + } + ], + "breed": "persian" + } + + request = HttpRequest("PUT", "/complex/inheritance/valid", + headers={ + 'Content-Type': 'application/json' + } + ) + request.set_json_body(siamese_body) + async with AutoRestComplexTestService(base_url="http://localhost:3000") as client: + response = await client._send_request(request) + assert response.status_code == 200 + + @pytest.mark.asyncio + async def test_send_request_with_body_serialize(self): + from bodycomplex.aio import AutoRestComplexTestService + from bodycomplex.models import Siamese, Dog + + siamese = Siamese( + id=2, + name="Siameeee", + color="green", + hates=[ + Dog( + id=1, + name="Potato", + food="tomato" + ), + Dog( + id=-1, + name="Tomato", + food="french fries" + ) + ], + breed="persian" + ) + + request = HttpRequest("PUT", "/complex/inheritance/valid", + headers={ + 'Content-Type': 'application/json' + } + ) + request.set_json_body(siamese.serialize()) + async with AutoRestComplexTestService(base_url="http://localhost:3000") as client: + response = await client._send_request(request) + assert response.status_code == 200 + + @pytest.mark.asyncio + async def test_send_request_get_stream(self): + from bodyfile.aio import AutoRestSwaggerBATFileService + + client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000", connection_data_block_size=1000) + file_length = 0 + with io.BytesIO() as file_handle: + + request = HttpRequest("GET", "/files/stream/nonempty", + headers={ + 'Accept': 'image/png, application/json' + }, + ) + + response = await client._send_request(request, stream=True) + assert response.status_code == 200 + + stream = response.stream_download(None) # want to make pipeline client an optional param in azure-core + + total = len(stream) + assert not stream.response.internal_response._released + + async for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + print("Downloading... {}%".format(int(file_length*100/total))) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + await client.close() + + @pytest.mark.asyncio + async def test_send_request_put_stream(self): + from bodyformdata.aio import AutoRestSwaggerBATFormDataService + + client = AutoRestSwaggerBATFormDataService( + base_url="http://localhost:3000", + ) + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = HttpRequest("PUT", '/formdata/stream/uploadfile', + headers={ + 'Content-Type': 'application/octet-stream' + }, + data=stream_data, + ) + response = await client._send_request(request, stream=True) + assert response.status_code == 200 + await client.close() + + @pytest.mark.asyncio + async def test_send_request_full_url(self): + from bodycomplex.aio import AutoRestComplexTestService + from bodycomplex.models import Siamese + + request = HttpRequest("GET", "http://localhost:3000/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + async with AutoRestComplexTestService(base_url="http://fakeUrl") as client: + response = await client._send_request(request) + + deserialized = Siamese.deserialize(response) + assert 2 == deserialized.id + assert "Siameeee" == deserialized.name + assert -1 == deserialized.hates[1].id + assert "Tomato" == deserialized.hates[1].name diff --git a/test/vanilla/AcceptanceTests/asynctests/test_string_tests.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_string_tests.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_string_tests.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_string_tests.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_time.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_time.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_time.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_time.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_tracing.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_tracing.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_tracing.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_tracing.py diff --git a/test/vanilla/legacy/AcceptanceTests/asynctests/test_url.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_url.py new file mode 100644 index 00000000000..11b47b3af7b --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/asynctests/test_url.py @@ -0,0 +1,284 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +import unittest +import subprocess +import sys +import isodate +import tempfile +from datetime import date, datetime, timedelta +import os +from os.path import dirname, pardir, join, realpath + +from msrest.exceptions import DeserializationError, ValidationError + +from url.aio import AutoRestUrlTestService +from urlmulticollectionformat.aio import AutoRestUrlMutliCollectionFormatTestService +from url.models import UriColor + +import pytest + + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestUrlTestService('', base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +@async_generator +async def multi_client(): + async with AutoRestUrlMutliCollectionFormatTestService("http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +def test_array_query(): + return ["ArrayQuery1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + +class TestUrl(object): + + @pytest.mark.asyncio + async def test_byte_empty_and_null(self, client): + await client.paths.byte_empty() + + with pytest.raises(ValidationError): + await client.paths.byte_null(None) + + @pytest.mark.asyncio + async def test_byte_multi_byte(self, client): + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + await client.paths.byte_multi_byte(u_bytes) + + @pytest.mark.asyncio + async def test_date_null(self, client): + with pytest.raises(ValidationError): + await client.paths.date_null(None) + + @pytest.mark.asyncio + async def test_date_time_null(self, client): + with pytest.raises(ValidationError): + await client.paths.date_time_null(None) + + @pytest.mark.asyncio + async def test_date_time_valid(self, client): + await client.paths.date_time_valid() + + @pytest.mark.asyncio + async def test_date_valid(self, client): + await client.paths.date_valid() + + @pytest.mark.asyncio + async def test_unix_time_url(self, client): + await client.paths.unix_time_url(datetime(year=2016, month=4, day=13)) + + @pytest.mark.asyncio + async def test_double_decimal(self, client): + await client.paths.double_decimal_negative() + await client.paths.double_decimal_positive() + + @pytest.mark.asyncio + async def test_float_scientific(self, client): + await client.paths.float_scientific_negative() + await client.paths.float_scientific_positive() + + @pytest.mark.asyncio + async def test_get_boolean(self, client): + await client.paths.get_boolean_false() + await client.paths.get_boolean_true() + + @pytest.mark.asyncio + async def test_int(self, client): + await client.paths.get_int_negative_one_million() + await client.paths.get_int_one_million() + + @pytest.mark.asyncio + async def test_get_long(self, client): + await client.paths.get_negative_ten_billion() + await client.paths.get_ten_billion() + + @pytest.mark.asyncio + async def test_string_empty_and_null(self, client): + await client.paths.string_empty() + + with pytest.raises(ValidationError): + await client.paths.string_null(None) + + @pytest.mark.asyncio + async def test_array_csv_in_path(self, client): + test_array = ["ArrayPath1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + await client.paths.array_csv_in_path(test_array) + + @pytest.mark.asyncio + async def test_string_url_encoded(self, client): + await client.paths.string_url_encoded() + + @pytest.mark.asyncio + async def test_paths_unicode(self, client): + await client.paths.string_unicode() + + @pytest.mark.asyncio + async def test_string_url_non_encoded(self, client): + await client.paths.string_url_non_encoded() + + @pytest.mark.asyncio + async def test_enum_valid(self, client): + await client.paths.enum_valid(UriColor.green_color) + + @pytest.mark.asyncio + async def test_enum_null(self, client): + with pytest.raises(ValidationError): + await client.paths.enum_null(None) + + @pytest.mark.asyncio + async def test_base64_url(self, client): + await client.paths.base64_url("lorem".encode()) + + @pytest.mark.asyncio + async def test_queries_byte(self, client): + await client.queries.byte_empty() + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + await client.queries.byte_multi_byte(u_bytes) + await client.queries.byte_null() + + @pytest.mark.asyncio + async def test_queries_date(self, client): + await client.queries.date_null() + await client.queries.date_valid() + + @pytest.mark.asyncio + async def test_queries_date_time(self, client): + await client.queries.date_time_null() + await client.queries.date_time_valid() + + @pytest.mark.asyncio + async def test_queries_double(self, client): + await client.queries.double_null() + await client.queries.double_decimal_negative() + await client.queries.double_decimal_positive() + + @pytest.mark.asyncio + async def test_queries_float_scientific(self, client): + await client.queries.float_scientific_negative() + await client.queries.float_scientific_positive() + await client.queries.float_null() + + @pytest.mark.asyncio + async def test_queries_boolean(self, client): + await client.queries.get_boolean_false() + await client.queries.get_boolean_true() + await client.queries.get_boolean_null() + + @pytest.mark.asyncio + async def test_queries_int(self, client): + await client.queries.get_int_negative_one_million() + await client.queries.get_int_one_million() + await client.queries.get_int_null() + + @pytest.mark.asyncio + async def test_queries_long(self, client): + await client.queries.get_negative_ten_billion() + await client.queries.get_ten_billion() + await client.queries.get_long_null() + + @pytest.mark.asyncio + async def test_queries_string(self, client): + await client.queries.string_empty() + await client.queries.string_null() + await client.queries.string_url_encoded() + + @pytest.mark.asyncio + async def test_queries_enum(self, client): + await client.queries.enum_valid(UriColor.green_color) + await client.queries.enum_null(None) + + @pytest.mark.asyncio + async def test_queries_unicode(self, client): + await client.queries.string_unicode() + + @pytest.mark.asyncio + async def test_array_string_csv(self, client, test_array_query): + await client.queries.array_string_csv_empty([]) + await client.queries.array_string_csv_null(None) + await client.queries.array_string_csv_valid(test_array_query) + + @pytest.mark.asyncio + async def test_array_string_miscellaneous(self, client, test_array_query): + # await client.queries.array_string_pipes_valid(test_array_query) + # await client.queries.array_string_ssv_valid(test_array_query) + await client.queries.array_string_tsv_valid(test_array_query) + + @pytest.mark.asyncio + async def test_array_string_multi(self, multi_client, test_array_query): + await multi_client.queries.array_string_multi_empty([]) + await multi_client.queries.array_string_multi_null() + await multi_client.queries.array_string_multi_valid(test_array_query) + + @pytest.mark.asyncio + async def test_array_string_no_collection_format(self, client): + await client.queries.array_string_no_collection_format_empty(['hello', 'nihao', 'bonjour']) + + @pytest.mark.asyncio + async def test_get_all_with_values(self, client): + client._config.global_string_path = "globalStringPath" + client._config.global_string_query = "globalStringQuery" + await client.path_items.get_all_with_values( + "pathItemStringPath", + "localStringPath", + "pathItemStringQuery", + "localStringQuery", + ) + + @pytest.mark.asyncio + async def test_get_global_and_local_query_null(self, client): + client._config.global_string_path = "globalStringPath" + await client.path_items.get_global_and_local_query_null( + "pathItemStringPath", + "localStringPath", + "pathItemStringQuery", + None, + ) + + @pytest.mark.asyncio + async def test_get_global_query_null(self, client): + client._config.global_string_path = "globalStringPath" + await client.path_items.get_global_query_null( + "pathItemStringPath", + "localStringPath", + "pathItemStringQuery", + "localStringQuery", + ) + + @pytest.mark.asyncio + async def test_get_local_path_item_query_null(self, client): + client._config.global_string_path = "globalStringPath" + client._config.global_string_query = "globalStringQuery" + await client.path_items.get_local_path_item_query_null( + "pathItemStringPath", + "localStringPath", + None, + None, + ) diff --git a/test/vanilla/AcceptanceTests/asynctests/test_validation.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_validation.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_validation.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_validation.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_xml.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_xml.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_xml.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_xml.py diff --git a/test/vanilla/AcceptanceTests/asynctests/test_xms_error.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_xms_error.py similarity index 100% rename from test/vanilla/AcceptanceTests/asynctests/test_xms_error.py rename to test/vanilla/legacy/AcceptanceTests/asynctests/test_xms_error.py diff --git a/test/vanilla/legacy/AcceptanceTests/conftest.py b/test/vanilla/legacy/AcceptanceTests/conftest.py new file mode 100644 index 00000000000..df307b81cec --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/conftest.py @@ -0,0 +1,93 @@ +# -------------------------------------------------------------------------- +# +# 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 glob +import sys +import subprocess +import os +import signal +from os.path import dirname, realpath +from unittest import TestLoader, TextTestRunner + +from os.path import dirname, pardir, join, realpath + +from azure.core.pipeline.policies import SansIOHTTPPolicy + +import pytest + + +cwd = dirname(realpath(__file__)) + +#Ideally this would be in a common helper library shared between the tests +def start_server_process(): + cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) + if os.name == 'nt': #On windows, subprocess creation works without being in the shell + return subprocess.Popen(cmd) + + return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True + +#Ideally this would be in a common helper library shared between the tests +def terminate_server_process(process): + if os.name == 'nt': + process.kill() + else: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups + +@pytest.fixture(scope="session") +def testserver(): + """Start the Autorest testserver.""" + server = start_server_process() + yield + terminate_server_process(server) + +# Ignore collection of async tests for Python 2 +collect_ignore = [] +if sys.version_info < (3,5): + collect_ignore.append("asynctests") + + +class CookiePolicy(SansIOHTTPPolicy): + def __init__(self, *args, **kwargs): + self._current_cookie = None + + def on_request(self, request, **kwargs): + # type: (PipelineRequest, Any) -> None + http_request = request.http_request + if self._current_cookie: + http_request.headers["Cookie"] = self._current_cookie + self._current_cookie = None + + def on_response(self, request, response, **kwargs): + # type: (PipelineRequest, PipelineResponse, Any) -> None + http_response = response.http_response + + if "Set-Cookie" in http_response.headers: + self._current_cookie = http_response.headers["Set-Cookie"] + +@pytest.fixture() +def cookie_policy(): + return CookiePolicy() + diff --git a/test/vanilla/AcceptanceTests/test_additional_properties.py b/test/vanilla/legacy/AcceptanceTests/test_additional_properties.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_additional_properties.py rename to test/vanilla/legacy/AcceptanceTests/test_additional_properties.py diff --git a/test/vanilla/AcceptanceTests/test_anything.py b/test/vanilla/legacy/AcceptanceTests/test_anything.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_anything.py rename to test/vanilla/legacy/AcceptanceTests/test_anything.py diff --git a/test/vanilla/AcceptanceTests/test_array.py b/test/vanilla/legacy/AcceptanceTests/test_array.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_array.py rename to test/vanilla/legacy/AcceptanceTests/test_array.py diff --git a/test/vanilla/AcceptanceTests/test_bool.py b/test/vanilla/legacy/AcceptanceTests/test_bool.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_bool.py rename to test/vanilla/legacy/AcceptanceTests/test_bool.py diff --git a/test/vanilla/AcceptanceTests/test_byte.py b/test/vanilla/legacy/AcceptanceTests/test_byte.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_byte.py rename to test/vanilla/legacy/AcceptanceTests/test_byte.py diff --git a/test/vanilla/AcceptanceTests/test_complex.py b/test/vanilla/legacy/AcceptanceTests/test_complex.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_complex.py rename to test/vanilla/legacy/AcceptanceTests/test_complex.py diff --git a/test/vanilla/AcceptanceTests/test_config.py b/test/vanilla/legacy/AcceptanceTests/test_config.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_config.py rename to test/vanilla/legacy/AcceptanceTests/test_config.py diff --git a/test/vanilla/AcceptanceTests/test_custom_base_uri.py b/test/vanilla/legacy/AcceptanceTests/test_custom_base_uri.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_custom_base_uri.py rename to test/vanilla/legacy/AcceptanceTests/test_custom_base_uri.py diff --git a/test/vanilla/AcceptanceTests/test_date.py b/test/vanilla/legacy/AcceptanceTests/test_date.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_date.py rename to test/vanilla/legacy/AcceptanceTests/test_date.py diff --git a/test/vanilla/AcceptanceTests/test_datetime.py b/test/vanilla/legacy/AcceptanceTests/test_datetime.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_datetime.py rename to test/vanilla/legacy/AcceptanceTests/test_datetime.py diff --git a/test/vanilla/AcceptanceTests/test_datetime_rfc.py b/test/vanilla/legacy/AcceptanceTests/test_datetime_rfc.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_datetime_rfc.py rename to test/vanilla/legacy/AcceptanceTests/test_datetime_rfc.py diff --git a/test/vanilla/AcceptanceTests/test_dictionary.py b/test/vanilla/legacy/AcceptanceTests/test_dictionary.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_dictionary.py rename to test/vanilla/legacy/AcceptanceTests/test_dictionary.py diff --git a/test/vanilla/AcceptanceTests/test_duration.py b/test/vanilla/legacy/AcceptanceTests/test_duration.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_duration.py rename to test/vanilla/legacy/AcceptanceTests/test_duration.py diff --git a/test/vanilla/AcceptanceTests/test_extensible_enums.py b/test/vanilla/legacy/AcceptanceTests/test_extensible_enums.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_extensible_enums.py rename to test/vanilla/legacy/AcceptanceTests/test_extensible_enums.py diff --git a/test/vanilla/legacy/AcceptanceTests/test_file.py b/test/vanilla/legacy/AcceptanceTests/test_file.py new file mode 100644 index 00000000000..dfa859f4302 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/test_file.py @@ -0,0 +1,149 @@ +# -------------------------------------------------------------------------- +# +# 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 unittest +import subprocess +import sys +import isodate +import tempfile +import io +from datetime import date, datetime, timedelta +import os +from os.path import dirname, pardir, join, realpath + +from msrest.exceptions import DeserializationError + +from bodyfile import AutoRestSwaggerBATFileService + +import pytest + +cwd = dirname(realpath(__file__)) + + +@pytest.fixture +def client(connection_data_block_size): + with AutoRestSwaggerBATFileService( + base_url="http://localhost:3000", connection_data_block_size=connection_data_block_size) as client: + yield client + +@pytest.fixture +def callback(): + def _callback(response, data_stream, headers): + assert not data_stream.response.internal_response._content_consumed + return data_stream + return _callback + +class TestFile(object): + + @pytest.mark.parametrize('connection_data_block_size', [1000]) + def test_get_file(self, client): + file_length = 0 + with io.BytesIO() as file_handle: + stream = client.files.get_file() + total = len(stream) + assert not stream.response.internal_response._content_consumed + + for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + print("Downloading... {}%".format(int(file_length*100/total))) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + @pytest.mark.parametrize('connection_data_block_size', [4096]) + def test_get_empty_file(self, client): + file_length = 0 + with io.BytesIO() as file_handle: + stream = client.files.get_empty_file() + assert len(stream) == 0 + assert not stream.response.internal_response._content_consumed + + for data in stream: + file_length += len(data) + file_handle.write(data) + + assert file_length == 0 + + @pytest.mark.parametrize('connection_data_block_size', [4096]) + def test_files_long_running(self, client): + file_length = 0 + stream = client.files.get_file_large() + for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + + assert file_length == 3000 * 1024 * 1024 + + @pytest.mark.parametrize('connection_data_block_size', [None]) + def test_get_file_with_callback(self, client, callback): + file_length = 0 + with io.BytesIO() as file_handle: + stream = client.files.get_file(cls=callback) + assert len(stream) > 0 + for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + @pytest.mark.parametrize('connection_data_block_size', [None]) + def test_get_empty_file_with_callback(self, client, callback): + file_length = 0 + with io.BytesIO() as file_handle: + stream = client.files.get_empty_file(cls=callback) + for data in stream: + file_length += len(data) + file_handle.write(data) + + assert file_length == 0 + + def test_models(self): + from bodyfile.models import Error + + if sys.version_info >= (3,5): + from bodyfile.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from bodyfile.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_form_data.py b/test/vanilla/legacy/AcceptanceTests/test_form_data.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_form_data.py rename to test/vanilla/legacy/AcceptanceTests/test_form_data.py diff --git a/test/vanilla/AcceptanceTests/test_header.py b/test/vanilla/legacy/AcceptanceTests/test_header.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_header.py rename to test/vanilla/legacy/AcceptanceTests/test_header.py diff --git a/test/vanilla/legacy/AcceptanceTests/test_http.py b/test/vanilla/legacy/AcceptanceTests/test_http.py new file mode 100644 index 00000000000..78059ef5934 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/test_http.py @@ -0,0 +1,431 @@ +# -------------------------------------------------------------------------- +# +# 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 unittest +import subprocess +import sys +from azure.core.pipeline import PipelineResponse +import isodate +import tempfile +import requests +from datetime import date, datetime, timedelta +import os +from os.path import dirname, pardir, join, realpath + +import requests + +from azure.core.exceptions import HttpResponseError +from azure.core.pipeline.policies import ContentDecodePolicy, RetryPolicy, HeadersPolicy, RedirectPolicy +from msrest.exceptions import DeserializationError + +from httpinfrastructure import AutoRestHttpInfrastructureTestService +from httpinfrastructure.models import MyException, B, C, D + +import pytest + + +@pytest.fixture() +def client(cookie_policy): + """Create a AutoRestHttpInfrastructureTestService client with test server credentials.""" + policies = [ + HeadersPolicy(), + ContentDecodePolicy(), + RedirectPolicy(), + RetryPolicy(), + cookie_policy + ] + with AutoRestHttpInfrastructureTestService(base_url="http://localhost:3000", policies=policies) as client: + yield client + + +class TestHttp(object): + + def assert_status(self, code, func, *args, **kwargs): + def return_status(pipeline_response, data, headers): + assert isinstance(pipeline_response, PipelineResponse) + return pipeline_response.http_response.status_code + kwargs['cls'] = return_status + status_code = func(*args, **kwargs) + assert status_code == code + + def assert_raises_with_message(self, msg, func, *args, **kwargs): + try: + func(*args, **kwargs) + pytest.fail() + + except HttpResponseError as err: + assert err.message == msg + + def assert_raises_with_model(self, code, model, func, *args, **kwargs): + try: + func(*args, **kwargs) + pytest.fail() + + except HttpResponseError as err: + if err.model: + assert isinstance(err.model, model) + assert err.response.status_code == code + + def assert_raises_with_status(self, code, func, *args, **kwargs): + try: + func(*args, **kwargs) + pytest.fail() + + except HttpResponseError as err: + + assert err.response.status_code == code + + def assert_raises_with_status_and_message(self, code, msg, func, *args, **kwargs): + try: + func(*args, **kwargs) + pytest.fail() + + except HttpResponseError as err: + assert err.model.message == msg + assert msg in err.message + assert msg in str(err) + assert err.response.status_code == code + + def assert_raises_with_status_and_response_contains(self, code, msg, func, *args, **kwargs): + try: + func(*args, **kwargs) + pytest.fail() + + except HttpResponseError as err: + assert err.response.status_code == code + assert msg in err.response.text() + + def test_get200_model204(self, client): + r = client.multiple_responses.get200_model204_no_model_default_error200_valid() + assert '200' == r.status_code + + self.assert_raises_with_status(201, + client.multiple_responses.get200_model204_no_model_default_error201_invalid) + + self.assert_raises_with_status(202, + client.multiple_responses.get200_model204_no_model_default_error202_none) + + assert client.multiple_responses.get200_model204_no_model_default_error204_valid() is None + + self.assert_raises_with_status_and_message(400, "client error", + client.multiple_responses.get200_model204_no_model_default_error400_valid) + + def test_get200_model201(self, client): + self.assert_status(200, client.multiple_responses.get200_model201_model_default_error200_valid) + + b_model = client.multiple_responses.get200_model201_model_default_error201_valid() + assert b_model is not None + assert b_model.status_code == "201" + assert b_model.text_status_code == "Created" + + self.assert_raises_with_status_and_message(400, "client error", + client.multiple_responses.get200_model201_model_default_error400_valid) + + def test_get200_model_a201_model_c404(self, client): + a_model = client.multiple_responses.get200_model_a201_model_c404_model_d_default_error200_valid() + assert a_model is not None + assert a_model.status_code == "200" + + c_model = client.multiple_responses.get200_model_a201_model_c404_model_d_default_error201_valid() + assert c_model is not None + assert c_model.http_code == "201" + + d_model = client.multiple_responses.get200_model_a201_model_c404_model_d_default_error404_valid() + assert d_model is not None + assert d_model.http_status_code == "404" + + self.assert_raises_with_status_and_message(400, "client error", + client.multiple_responses.get200_model_a201_model_c404_model_d_default_error400_valid) + + def test_get202_none204(self, client): + client.multiple_responses.get202_none204_none_default_error202_none() + client.multiple_responses.get202_none204_none_default_error204_none() + + self.assert_raises_with_status_and_message(400, "client error", + client.multiple_responses.get202_none204_none_default_error400_valid) + + client.multiple_responses.get202_none204_none_default_none202_invalid() + client.multiple_responses.get202_none204_none_default_none204_none() + + self.assert_raises_with_status(400, + client.multiple_responses.get202_none204_none_default_none400_none) + + self.assert_raises_with_status(400, + client.multiple_responses.get202_none204_none_default_none400_invalid) + + def test_get_default_model_a200(self, client): + self.assert_status(200, client.multiple_responses.get_default_model_a200_valid) + + assert client.multiple_responses.get_default_model_a200_none() is None + client.multiple_responses.get_default_model_a200_valid() + client.multiple_responses.get_default_model_a200_none() + + def test_get_default_model_a400(self, client): + self.assert_raises_with_model(400, MyException, + client.multiple_responses.get_default_model_a400_valid) + + self.assert_raises_with_model(400, MyException, + client.multiple_responses.get_default_model_a400_none) + + def test_get_default_none200(self, client): + client.multiple_responses.get_default_none200_invalid() + client.multiple_responses.get_default_none200_none() + + def test_get_default_none400(self, client): + self.assert_raises_with_status(400, + client.multiple_responses.get_default_none400_invalid) + + self.assert_raises_with_status(400, + client.multiple_responses.get_default_none400_none) + + def test_get200_model_a200(self, client): + assert client.multiple_responses.get200_model_a200_none() is None + + self.assert_status(200, client.multiple_responses.get200_model_a200_valid) + + assert client.multiple_responses.get200_model_a200_invalid().status_code is None + + def test_get200_model_a400(self, client): + self.assert_raises_with_status(400, + client.multiple_responses.get200_model_a400_none) + self.assert_raises_with_status(400, + client.multiple_responses.get200_model_a400_valid) + self.assert_raises_with_status(400, + client.multiple_responses.get200_model_a400_invalid) + + def test_get200_model_a202(self, client): + self.assert_raises_with_status(202, + client.multiple_responses.get200_model_a202_valid) + + def test_server_error_status_codes_501(self, client): + + self.assert_raises_with_status(requests.codes.not_implemented, + client.http_server_failure.head501) + + self.assert_raises_with_status(requests.codes.not_implemented, + client.http_server_failure.get501) + + def test_server_error_status_codes_505(self, client): + self.assert_raises_with_status(requests.codes.http_version_not_supported, + client.http_server_failure.post505) + + self.assert_raises_with_status(requests.codes.http_version_not_supported, + client.http_server_failure.delete505) + + def test_retry_status_codes_408(self, client): + client.http_retry.head408() + + def test_retry_status_codes_502(self, client): + client.http_retry.get502() + + # TODO, 4042586: Support options operations in swagger modeler + #client.http_retry.options429() + + def test_retry_status_codes_500(self, client): + client.http_retry.put500() + client.http_retry.patch500() + + def test_retry_status_codes_503(self, client): + client.http_retry.post503() + client.http_retry.delete503() + + def test_retry_status_codes_504(self, client): + client.http_retry.put504() + client.http_retry.patch504() + + def test_error_status_codes_400(self, client): + self.assert_raises_with_status(requests.codes.bad_request, + client.http_client_failure.head400) + + self.assert_raises_with_status(requests.codes.bad_request, + client.http_client_failure.get400) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.bad_request, + # client.http_client_failure.options400) + + self.assert_raises_with_status(requests.codes.bad_request, + client.http_client_failure.put400) + + self.assert_raises_with_status(requests.codes.bad_request, + client.http_client_failure.patch400) + + self.assert_raises_with_status(requests.codes.bad_request, + client.http_client_failure.post400) + + self.assert_raises_with_status(requests.codes.bad_request, + client.http_client_failure.delete400) + + def test_error_status_codes_401(self, client): + self.assert_raises_with_status(requests.codes.unauthorized, + client.http_client_failure.head401) + + def test_error_status_codes_402(self, client): + self.assert_raises_with_status(requests.codes.payment_required, + client.http_client_failure.get402) + + def test_error_status_codes_403(self, client): + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.forbidden, + # client.http_client_failure.options403) + + self.assert_raises_with_status(requests.codes.forbidden, + client.http_client_failure.get403) + + def test_error_status_codes_404(self, client): + self.assert_raises_with_status(requests.codes.not_found, + client.http_client_failure.put404) + + def test_error_status_codes_405(self, client): + self.assert_raises_with_status(requests.codes.method_not_allowed, + client.http_client_failure.patch405) + + def test_error_status_codes_406(self, client): + self.assert_raises_with_status(requests.codes.not_acceptable, + client.http_client_failure.post406) + + def test_error_status_codes_407(self, client): + self.assert_raises_with_status(requests.codes.proxy_authentication_required, + client.http_client_failure.delete407) + + def test_error_status_codes_409(self, client): + self.assert_raises_with_status(requests.codes.conflict, + client.http_client_failure.put409) + + def test_error_status_codes_410(self, client): + self.assert_raises_with_status(requests.codes.gone, + client.http_client_failure.head410) + + def test_error_status_codes_411(self, client): + self.assert_raises_with_status(requests.codes.length_required, + client.http_client_failure.get411) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.precondition_failed, + # client.http_client_failure.options412) + + self.assert_raises_with_status(requests.codes.precondition_failed, + client.http_client_failure.get412) + + self.assert_raises_with_status(requests.codes.request_entity_too_large, + client.http_client_failure.put413) + + self.assert_raises_with_status(requests.codes.request_uri_too_large, + client.http_client_failure.patch414) + + self.assert_raises_with_status(requests.codes.unsupported_media, + client.http_client_failure.post415) + + self.assert_raises_with_status(requests.codes.requested_range_not_satisfiable, + client.http_client_failure.get416) + + self.assert_raises_with_status(requests.codes.expectation_failed, + client.http_client_failure.delete417) + + self.assert_raises_with_status(429, + client.http_client_failure.head429) + + def test_redirect_to_300(self, client): + self.assert_status(200, client.http_redirects.get300) + + def test_redirect_to_301(self, client): + self.assert_status(200, client.http_redirects.head301) + self.assert_status(200, client.http_redirects.get301) + self.assert_status(requests.codes.moved_permanently, client.http_redirects.put301) + + def test_redirect_to_302(self, client): + self.assert_status(200, client.http_redirects.head302) + self.assert_status(200, client.http_redirects.get302) + self.assert_status(requests.codes.found, client.http_redirects.patch302) + + def test_redicret_to_303(self, client): + self.assert_status(200, client.http_redirects.post303) + + def test_redirect_to_307(self, client): + self.assert_status(200, client.http_redirects.head307) + self.assert_status(200, client.http_redirects.get307) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_status(200, client.http_redirects.options307) + self.assert_status(200, client.http_redirects.put307) + self.assert_status(200, client.http_redirects.post307) + self.assert_status(200, client.http_redirects.patch307) + self.assert_status(200, client.http_redirects.delete307) + + + + def test_bad_request_status_assert(self, client): + self.assert_raises_with_message("Operation returned an invalid status 'Bad Request'", + client.http_failure.get_empty_error) + + def test_no_error_model_status_assert(self, client): + self.assert_raises_with_status_and_response_contains(requests.codes.bad_request, "NoErrorModel", + client.http_failure.get_no_model_error) + + def test_success_status_codes_200(self, client): + client.http_success.head200() + assert client.http_success.get200() + client.http_success.put200() + client.http_success.post200() + client.http_success.patch200() + client.http_success.delete200() + + # TODO, 4042586: Support options operations in swagger modeler + #assert client.http_success.options200() + + def test_success_status_codes_201(self, client): + client.http_success.put201() + client.http_success.post201() + + def test_success_status_codes_202(self, client): + client.http_success.put202() + client.http_success.post202() + client.http_success.patch202() + client.http_success.delete202() + + def test_success_status_codes_204(self, client): + client.http_success.head204() + client.http_success.put204() + client.http_success.post204() + client.http_success.delete204() + client.http_success.patch204() + + def test_success_status_codes_404(self, client): + client.http_success.head404() + + def test_empty_no_content(self, client): + self.assert_raises_with_status(requests.codes.bad_request, + client.http_failure.get_no_model_empty) + + def test_models(self): + from httpinfrastructure.models import Error + + if sys.version_info >= (3,5): + from httpinfrastructure.models._models_py3 import Error as ErrorPy3 + assert Error == ErrorPy3 + else: + from httpinfrastructure.models._models import Error as ErrorPy2 + assert Error == ErrorPy2 diff --git a/test/vanilla/AcceptanceTests/test_incorrect_error_response.py b/test/vanilla/legacy/AcceptanceTests/test_incorrect_error_response.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_incorrect_error_response.py rename to test/vanilla/legacy/AcceptanceTests/test_incorrect_error_response.py diff --git a/test/vanilla/AcceptanceTests/test_integer.py b/test/vanilla/legacy/AcceptanceTests/test_integer.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_integer.py rename to test/vanilla/legacy/AcceptanceTests/test_integer.py diff --git a/test/vanilla/AcceptanceTests/test_media_types.py b/test/vanilla/legacy/AcceptanceTests/test_media_types.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_media_types.py rename to test/vanilla/legacy/AcceptanceTests/test_media_types.py diff --git a/test/vanilla/AcceptanceTests/test_model_flattening.py b/test/vanilla/legacy/AcceptanceTests/test_model_flattening.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_model_flattening.py rename to test/vanilla/legacy/AcceptanceTests/test_model_flattening.py diff --git a/test/vanilla/AcceptanceTests/test_multiple_inheritance.py b/test/vanilla/legacy/AcceptanceTests/test_multiple_inheritance.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_multiple_inheritance.py rename to test/vanilla/legacy/AcceptanceTests/test_multiple_inheritance.py diff --git a/test/vanilla/AcceptanceTests/test_no_operations.py b/test/vanilla/legacy/AcceptanceTests/test_no_operations.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_no_operations.py rename to test/vanilla/legacy/AcceptanceTests/test_no_operations.py diff --git a/test/vanilla/AcceptanceTests/test_non_string_enums.py b/test/vanilla/legacy/AcceptanceTests/test_non_string_enums.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_non_string_enums.py rename to test/vanilla/legacy/AcceptanceTests/test_non_string_enums.py diff --git a/test/vanilla/AcceptanceTests/test_number.py b/test/vanilla/legacy/AcceptanceTests/test_number.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_number.py rename to test/vanilla/legacy/AcceptanceTests/test_number.py diff --git a/test/vanilla/AcceptanceTests/test_object_type.py b/test/vanilla/legacy/AcceptanceTests/test_object_type.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_object_type.py rename to test/vanilla/legacy/AcceptanceTests/test_object_type.py diff --git a/test/vanilla/AcceptanceTests/test_required_optional.py b/test/vanilla/legacy/AcceptanceTests/test_required_optional.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_required_optional.py rename to test/vanilla/legacy/AcceptanceTests/test_required_optional.py diff --git a/test/vanilla/legacy/AcceptanceTests/test_send_request.py b/test/vanilla/legacy/AcceptanceTests/test_send_request.py new file mode 100644 index 00000000000..03ac18b1db6 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/test_send_request.py @@ -0,0 +1,223 @@ +# -------------------------------------------------------------------------- +# +# 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 io +import json + +from azure.core.pipeline.transport import HttpRequest + +from os.path import dirname, pardir, join, realpath +import pytest + +cwd = dirname(realpath(__file__)) + + +class TestSendRequest(object): + + def test_send_request_with_body_get_model_deserialize(self): + from bodycomplex import AutoRestComplexTestService + from bodycomplex.models import Siamese + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + response = client._send_request(request) + + deserialized = Siamese.deserialize(response) + assert 2 == deserialized.id + assert "Siameeee" == deserialized.name + assert -1 == deserialized.hates[1].id + assert "Tomato" == deserialized.hates[1].name + + def test_send_request_with_body_get_direct_json(self): + from bodycomplex import AutoRestComplexTestService + from bodycomplex.models import Siamese + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + response = client._send_request(request, stream=True) + + data = b''.join([chunk for chunk in response.stream_download(None)]).decode('utf-8') + json_response = json.loads(data) + assert 2 == json_response['id'] + assert "Siameeee" == json_response['name'] + assert - 1 == json_response['hates'][1]['id'] + assert "Tomato" == json_response['hates'][1]['name'] + + def test_send_request_with_body_put_json_dumps(self): + from bodycomplex import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + siamese_body = { + "id": 2, + "name": "Siameeee", + "color": "green", + "hates": + [ + { + "id": 1, + "name": "Potato", + "food": "tomato" + }, + { + "id": -1, + "name": "Tomato", + "food": "french fries" + } + ], + "breed": "persian" + } + + request = HttpRequest("PUT", "/complex/inheritance/valid", + headers={ + 'Content-Type': 'application/json' + } + ) + request.set_json_body(siamese_body) + + response = client._send_request(request) + assert response.status_code == 200 + + def test_send_request_with_body_serialize(self): + from bodycomplex import AutoRestComplexTestService + from bodycomplex.models import Siamese, Dog + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + siamese = Siamese( + id=2, + name="Siameeee", + color="green", + hates=[ + Dog( + id=1, + name="Potato", + food="tomato" + ), + Dog( + id=-1, + name="Tomato", + food="french fries" + ) + ], + breed="persian" + ) + + request = HttpRequest("PUT", "/complex/inheritance/valid", + headers={ + 'Content-Type': 'application/json' + } + ) + request.set_json_body(siamese.serialize()) + response = client._send_request(request) + assert response.status_code == 200 + + def test_send_request_get_stream(self): + from bodyfile import AutoRestSwaggerBATFileService + + client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000", connection_data_block_size=1000) + file_length = 0 + with io.BytesIO() as file_handle: + + request = HttpRequest("GET", "/files/stream/nonempty", + headers={ + 'Accept': 'image/png, application/json' + }, + ) + + response = client._send_request(request, stream=True) + assert response.status_code == 200 + + stream = response.stream_download(None) # want to make pipeline client an optional param in azure-core + + total = len(stream) + assert not stream.response.internal_response._content_consumed + + for data in stream: + assert 0 < len(data) <= stream.block_size + file_length += len(data) + print("Downloading... {}%".format(int(file_length*100/total))) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + def test_send_request_put_stream(self): + from bodyformdata import AutoRestSwaggerBATFormDataService + + client = AutoRestSwaggerBATFormDataService( + base_url="http://localhost:3000", + ) + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = HttpRequest("PUT", '/formdata/stream/uploadfile', + headers={ + 'Content-Type': 'application/octet-stream' + }, + data=stream_data, + ) + response = client._send_request(request) + assert response.status_code == 200 + + def test_send_request_full_url(self): + from bodycomplex import AutoRestComplexTestService + from bodycomplex.models import Siamese + + client = AutoRestComplexTestService(base_url="http://fakeUrl") + + request = HttpRequest("GET", "http://localhost:3000/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + response = client._send_request(request) + + deserialized = Siamese.deserialize(response) + assert 2 == deserialized.id + assert "Siameeee" == deserialized.name + assert -1 == deserialized.hates[1].id + assert "Tomato" == deserialized.hates[1].name diff --git a/test/vanilla/AcceptanceTests/test_string_tests.py b/test/vanilla/legacy/AcceptanceTests/test_string_tests.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_string_tests.py rename to test/vanilla/legacy/AcceptanceTests/test_string_tests.py diff --git a/test/vanilla/AcceptanceTests/test_time.py b/test/vanilla/legacy/AcceptanceTests/test_time.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_time.py rename to test/vanilla/legacy/AcceptanceTests/test_time.py diff --git a/test/vanilla/AcceptanceTests/test_tracing.py b/test/vanilla/legacy/AcceptanceTests/test_tracing.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_tracing.py rename to test/vanilla/legacy/AcceptanceTests/test_tracing.py diff --git a/test/vanilla/AcceptanceTests/test_url.py b/test/vanilla/legacy/AcceptanceTests/test_url.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_url.py rename to test/vanilla/legacy/AcceptanceTests/test_url.py diff --git a/test/vanilla/AcceptanceTests/test_validation.py b/test/vanilla/legacy/AcceptanceTests/test_validation.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_validation.py rename to test/vanilla/legacy/AcceptanceTests/test_validation.py diff --git a/test/vanilla/AcceptanceTests/test_xml.py b/test/vanilla/legacy/AcceptanceTests/test_xml.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_xml.py rename to test/vanilla/legacy/AcceptanceTests/test_xml.py diff --git a/test/vanilla/AcceptanceTests/test_xms_error.py b/test/vanilla/legacy/AcceptanceTests/test_xms_error.py similarity index 100% rename from test/vanilla/AcceptanceTests/test_xms_error.py rename to test/vanilla/legacy/AcceptanceTests/test_xms_error.py diff --git a/test/vanilla/legacy/AcceptanceTests/test_zzz.py b/test/vanilla/legacy/AcceptanceTests/test_zzz.py new file mode 100644 index 00000000000..461c6aa86c8 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/test_zzz.py @@ -0,0 +1,92 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +import datetime +import os +import platform +import warnings + +from report import AutoRestReportService + + +class TestAcceptance(object): + + def test_ensure_coverage(self): + client = AutoRestReportService(base_url="http://localhost:3000") + report = client.get_report(platform.python_version()) + optional_report = client.get_optional_report(platform.python_version()) + + # Add tests that wont be supported due to the nature of Python here + not_supported = {} + + # Please add missing features or failing tests here + missing_features_or_bugs = { + 'ConstantsInBody': 1, # https://github.com/Azure/autorest.modelerfour/issues/83 + } + for name in report: + if name[:3].lower() == 'llc': + missing_features_or_bugs[name] = 1 # no LLC tests for legacy + + print("Coverage:") + self._print_report(report, not_supported, missing_features_or_bugs) + + missing_features_or_bugs = { + "putDateTimeMaxLocalNegativeOffset": 1, # Python doesn't support year 1000 + "putDateTimeMinLocalPositiveOffset": 1, # Python doesn't support BC time + '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: + missing_features_or_bugs[name] = 1; # https://github.com/Azure/azure-sdk-for-python/pull/9322 + if "Multiapi" in name: + # multiapi 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) + + + def _print_report(self, report, not_supported=None, missing_features_or_bugs=None): + if not_supported: + report.update(not_supported) + for s in not_supported.keys(): + print("IGNORING {0}".format(s)) + + if missing_features_or_bugs: + report.update(missing_features_or_bugs) + for s in missing_features_or_bugs.keys(): + print("PENDING {0}".format(s)) + + failed = [k for k, v in report.items() if v == 0] + for s in failed: + print("FAILED TO EXECUTE {0}".format(s)) + + total_tests = len(report) + warnings.warn ("The test coverage is {0}/{1}.".format(total_tests - len(failed), total_tests)) + + assert 0 == len(failed) diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_additional_properties_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_additional_properties_client.py new file mode 100644 index 00000000000..24d178bfd72 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_additional_properties_client.py @@ -0,0 +1,96 @@ +# 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 AdditionalPropertiesClientConfiguration +from .operations import PetsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AdditionalPropertiesClient(object): + """Test Infrastructure for AutoRest. + + :ivar pets: PetsOperations operations + :vartype pets: additionalproperties.operations.PetsOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AdditionalPropertiesClientConfiguration(**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.pets = PetsOperations(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. + + We have helper methods to create requests specific to this service in `additionalproperties.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from additionalproperties._rest import pets + >>> request = pets.build_create_ap_true_request(json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AdditionalPropertiesClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_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/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/__init__.py new file mode 100644 index 00000000000..65128f19617 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/__init__.py @@ -0,0 +1,31 @@ +# 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_create_ap_true_request + from ._request_builders_py3 import build_create_cat_ap_true_request + from ._request_builders_py3 import build_create_ap_object_request + from ._request_builders_py3 import build_create_ap_string_request + from ._request_builders_py3 import build_create_ap_in_properties_request + from ._request_builders_py3 import build_create_ap_in_properties_with_ap_string_request +except (SyntaxError, ImportError): + from ._request_builders import build_create_ap_true_request # type: ignore + from ._request_builders import build_create_cat_ap_true_request # type: ignore + from ._request_builders import build_create_ap_object_request # type: ignore + from ._request_builders import build_create_ap_string_request # type: ignore + from ._request_builders import build_create_ap_in_properties_request # type: ignore + from ._request_builders import build_create_ap_in_properties_with_ap_string_request # type: ignore + +__all__ = [ + "build_create_ap_true_request", + "build_create_cat_ap_true_request", + "build_create_ap_object_request", + "build_create_ap_string_request", + "build_create_ap_in_properties_request", + "build_create_ap_in_properties_with_ap_string_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/_request_builders.py new file mode 100644 index 00000000000..a6de3603336 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/_request_builders.py @@ -0,0 +1,264 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_create_ap_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/true') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_cat_ap_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a CatAPTrue which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/true-subclass') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/type/object') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/type/string') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_in_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/in/properties') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_in_properties_with_ap_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/in/properties/with/additionalProperties/string') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/_request_builders_py3.py new file mode 100644 index 00000000000..6285206f90c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_rest/pets/_request_builders_py3.py @@ -0,0 +1,213 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_create_ap_true_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/true") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_cat_ap_true_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a CatAPTrue which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/true-subclass") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_object_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/type/object") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_string_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/type/string") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_in_properties_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/in/properties") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_in_properties_with_ap_string_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/in/properties/with/additionalProperties/string") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_additional_properties_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_additional_properties_client.py new file mode 100644 index 00000000000..14211466f62 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_additional_properties_client.py @@ -0,0 +1,78 @@ +# 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 AdditionalPropertiesClientConfiguration +from .operations import PetsOperations + + +class AdditionalPropertiesClient: + """Test Infrastructure for AutoRest. + + :ivar pets: PetsOperations operations + :vartype pets: additionalproperties.aio.operations.PetsOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AdditionalPropertiesClientConfiguration(**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.pets = PetsOperations(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. + + We have helper methods to create requests specific to this service in `additionalproperties.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from additionalproperties._rest import pets + >>> request = pets.build_create_ap_true_request(json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AdditionalPropertiesClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py new file mode 100644 index 00000000000..e60f49538c1 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/aio/operations/_pets_operations.py @@ -0,0 +1,319 @@ +# 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 ... import models as _models +from ..._rest import pets as rest_pets + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PetsOperations: + """PetsOperations 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: ~additionalproperties.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 create_ap_true(self, create_parameters: "_models.PetAPTrue", **kwargs: Any) -> "_models.PetAPTrue": + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPTrue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPTrue, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPTrue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPTrue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPTrue") + + request = rest_pets.build_create_ap_true_request( + content_type=content_type, + json=json, + template_url=self.create_ap_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPTrue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_true.metadata = {"url": "/additionalProperties/true"} # type: ignore + + @distributed_trace_async + async def create_cat_ap_true(self, create_parameters: "_models.CatAPTrue", **kwargs: Any) -> "_models.CatAPTrue": + """Create a CatAPTrue which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.CatAPTrue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CatAPTrue, or the result of cls(response) + :rtype: ~additionalproperties.models.CatAPTrue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.CatAPTrue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "CatAPTrue") + + request = rest_pets.build_create_cat_ap_true_request( + content_type=content_type, + json=json, + template_url=self.create_cat_ap_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("CatAPTrue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_cat_ap_true.metadata = {"url": "/additionalProperties/true-subclass"} # type: ignore + + @distributed_trace_async + async def create_ap_object(self, create_parameters: "_models.PetAPObject", **kwargs: Any) -> "_models.PetAPObject": + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPObject, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPObject"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPObject") + + request = rest_pets.build_create_ap_object_request( + content_type=content_type, + json=json, + template_url=self.create_ap_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPObject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_object.metadata = {"url": "/additionalProperties/type/object"} # type: ignore + + @distributed_trace_async + async def create_ap_string(self, create_parameters: "_models.PetAPString", **kwargs: Any) -> "_models.PetAPString": + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPString + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPString, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPString + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPString"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPString") + + request = rest_pets.build_create_ap_string_request( + content_type=content_type, + json=json, + template_url=self.create_ap_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPString", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_string.metadata = {"url": "/additionalProperties/type/string"} # type: ignore + + @distributed_trace_async + async def create_ap_in_properties( + self, create_parameters: "_models.PetAPInProperties", **kwargs: Any + ) -> "_models.PetAPInProperties": + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPInProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPInProperties, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPInProperties + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInProperties"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPInProperties") + + request = rest_pets.build_create_ap_in_properties_request( + content_type=content_type, + json=json, + template_url=self.create_ap_in_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPInProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_in_properties.metadata = {"url": "/additionalProperties/in/properties"} # type: ignore + + @distributed_trace_async + async def create_ap_in_properties_with_ap_string( + self, create_parameters: "_models.PetAPInPropertiesWithAPString", **kwargs: Any + ) -> "_models.PetAPInPropertiesWithAPString": + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPInPropertiesWithAPString + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPInPropertiesWithAPString, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPInPropertiesWithAPString + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInPropertiesWithAPString"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPInPropertiesWithAPString") + + request = rest_pets.build_create_ap_in_properties_with_ap_string_request( + content_type=content_type, + json=json, + template_url=self.create_ap_in_properties_with_ap_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPInPropertiesWithAPString", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_in_properties_with_ap_string.metadata = {"url": "/additionalProperties/in/properties/with/additionalProperties/string"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py new file mode 100644 index 00000000000..f2f23c1d9d7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/operations/_pets_operations.py @@ -0,0 +1,337 @@ +# 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 .. import models as _models +from .._rest import pets as rest_pets + +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]] + + +class PetsOperations(object): + """PetsOperations 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: ~additionalproperties.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 create_ap_true( + self, + create_parameters, # type: "_models.PetAPTrue" + **kwargs # type: Any + ): + # type: (...) -> "_models.PetAPTrue" + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPTrue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPTrue, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPTrue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPTrue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPTrue") + + request = rest_pets.build_create_ap_true_request( + content_type=content_type, + json=json, + template_url=self.create_ap_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPTrue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_true.metadata = {"url": "/additionalProperties/true"} # type: ignore + + @distributed_trace + def create_cat_ap_true( + self, + create_parameters, # type: "_models.CatAPTrue" + **kwargs # type: Any + ): + # type: (...) -> "_models.CatAPTrue" + """Create a CatAPTrue which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.CatAPTrue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CatAPTrue, or the result of cls(response) + :rtype: ~additionalproperties.models.CatAPTrue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.CatAPTrue"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "CatAPTrue") + + request = rest_pets.build_create_cat_ap_true_request( + content_type=content_type, + json=json, + template_url=self.create_cat_ap_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("CatAPTrue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_cat_ap_true.metadata = {"url": "/additionalProperties/true-subclass"} # type: ignore + + @distributed_trace + def create_ap_object( + self, + create_parameters, # type: "_models.PetAPObject" + **kwargs # type: Any + ): + # type: (...) -> "_models.PetAPObject" + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPObject, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPObject"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPObject") + + request = rest_pets.build_create_ap_object_request( + content_type=content_type, + json=json, + template_url=self.create_ap_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPObject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_object.metadata = {"url": "/additionalProperties/type/object"} # type: ignore + + @distributed_trace + def create_ap_string( + self, + create_parameters, # type: "_models.PetAPString" + **kwargs # type: Any + ): + # type: (...) -> "_models.PetAPString" + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPString + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPString, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPString + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPString"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPString") + + request = rest_pets.build_create_ap_string_request( + content_type=content_type, + json=json, + template_url=self.create_ap_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPString", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_string.metadata = {"url": "/additionalProperties/type/string"} # type: ignore + + @distributed_trace + def create_ap_in_properties( + self, + create_parameters, # type: "_models.PetAPInProperties" + **kwargs # type: Any + ): + # type: (...) -> "_models.PetAPInProperties" + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPInProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPInProperties, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPInProperties + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInProperties"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPInProperties") + + request = rest_pets.build_create_ap_in_properties_request( + content_type=content_type, + json=json, + template_url=self.create_ap_in_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPInProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_in_properties.metadata = {"url": "/additionalProperties/in/properties"} # type: ignore + + @distributed_trace + def create_ap_in_properties_with_ap_string( + self, + create_parameters, # type: "_models.PetAPInPropertiesWithAPString" + **kwargs # type: Any + ): + # type: (...) -> "_models.PetAPInPropertiesWithAPString" + """Create a Pet which contains more properties than what is defined. + + :param create_parameters: + :type create_parameters: ~additionalproperties.models.PetAPInPropertiesWithAPString + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAPInPropertiesWithAPString, or the result of cls(response) + :rtype: ~additionalproperties.models.PetAPInPropertiesWithAPString + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAPInPropertiesWithAPString"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(create_parameters, "PetAPInPropertiesWithAPString") + + request = rest_pets.build_create_ap_in_properties_with_ap_string_request( + content_type=content_type, + json=json, + template_url=self.create_ap_in_properties_with_ap_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAPInPropertiesWithAPString", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_ap_in_properties_with_ap_string.metadata = {"url": "/additionalProperties/in/properties/with/additionalProperties/string"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/setup.py new file mode 100644 index 00000000000..dd067c7050e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/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 = "additionalpropertiesclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AdditionalPropertiesClient", + author_email="", + url="", + keywords=["Swagger", "AdditionalPropertiesClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_anything_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_anything_client.py new file mode 100644 index 00000000000..b4785951f03 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_anything_client.py @@ -0,0 +1,92 @@ +# 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 AnythingClientConfiguration +from .operations import AnythingClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AnythingClient(AnythingClientOperationsMixin): + """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AnythingClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `anything.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from anything._rest import build_get_object_request + >>> request = build_get_object_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AnythingClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/__init__.py new file mode 100644 index 00000000000..cc874f11a17 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/__init__.py @@ -0,0 +1,31 @@ +# 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_get_object_request + from ._request_builders_py3 import build_put_object_request + from ._request_builders_py3 import build_get_string_request + from ._request_builders_py3 import build_put_string_request + from ._request_builders_py3 import build_get_array_request + from ._request_builders_py3 import build_put_array_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_object_request # type: ignore + from ._request_builders import build_put_object_request # type: ignore + from ._request_builders import build_get_string_request # type: ignore + from ._request_builders import build_put_string_request # type: ignore + from ._request_builders import build_get_array_request # type: ignore + from ._request_builders import build_put_array_request # type: ignore + +__all__ = [ + "build_get_object_request", + "build_put_object_request", + "build_get_string_request", + "build_put_string_request", + "build_get_array_request", + "build_put_array_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/_request_builders.py new file mode 100644 index 00000000000..8f3c4627121 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/_request_builders.py @@ -0,0 +1,238 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/anything/object') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/anything/object') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an string as anything. Returns string 'foo'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/anything/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in 'anything' for a 200, anything else for an object + error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in 'anything' for a 200, anything else for an object + error. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/anything/string') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/anything/array') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/anything/array') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..40c3ed451e7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_rest/_request_builders_py3.py @@ -0,0 +1,185 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_object_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/anything/object") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_object_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/anything/object") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an string as anything. Returns string 'foo'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/anything/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in 'anything' for a 200, anything else for an object + error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in 'anything' for a 200, anything else for an object + error. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/anything/string") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/anything/array") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/anything/array") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py new file mode 100644 index 00000000000..1cfd5bd7312 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py @@ -0,0 +1,78 @@ +# 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 AnythingClientConfiguration +from .operations import AnythingClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AnythingClient(AnythingClientOperationsMixin): + """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AnythingClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `anything.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from anything._rest import build_get_object_request + >>> request = build_get_object_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AnythingClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py new file mode 100644 index 00000000000..e2bdb6a3983 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py @@ -0,0 +1,258 @@ +# 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 ... import _rest as rest + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AnythingClientOperationsMixin: + @distributed_trace_async + async def get_object(self, **kwargs: Any) -> Any: + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_object_request( + template_url=self.get_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace_async + async def put_object(self, input: Any, **kwargs: Any) -> None: + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + :param input: Pass in {'foo': 'bar'} for a 200, anything else for an object error. + :type input: any + :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/json") # type: Optional[str] + + json = self._serialize.body(input, "object") + + request = rest.build_put_object_request( + content_type=content_type, + json=json, + template_url=self.put_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace_async + async def get_string(self, **kwargs: Any) -> Any: + """Basic get that returns an string as anything. Returns string 'foo'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_string_request( + template_url=self.get_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace_async + async def put_string(self, input: Any, **kwargs: Any) -> None: + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + :param input: Pass in 'anything' for a 200, anything else for an object error. + :type input: any + :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/json") # type: Optional[str] + + json = self._serialize.body(input, "object") + + request = rest.build_put_string_request( + content_type=content_type, + json=json, + template_url=self.put_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace_async + async def get_array(self, **kwargs: Any) -> Any: + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_array_request( + template_url=self.get_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array.metadata = {"url": "/anything/array"} # type: ignore + + @distributed_trace_async + async def put_array(self, input: Any, **kwargs: Any) -> None: + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + :param input: Pass in ['foo', 'bar'] for a 200, anything else for an object error. + :type input: any + :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/json") # type: Optional[str] + + json = self._serialize.body(input, "object") + + request = rest.build_put_array_request( + content_type=content_type, + json=json, + template_url=self.put_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_array.metadata = {"url": "/anything/array"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py new file mode 100644 index 00000000000..e128595d8ae --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py @@ -0,0 +1,274 @@ +# 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 .. import _rest as rest + +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]] + + +class AnythingClientOperationsMixin(object): + @distributed_trace + def get_object( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_object_request( + template_url=self.get_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace + def put_object( + self, + input, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + :param input: Pass in {'foo': 'bar'} for a 200, anything else for an object error. + :type input: any + :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/json") # type: Optional[str] + + json = self._serialize.body(input, "object") + + request = rest.build_put_object_request( + content_type=content_type, + json=json, + template_url=self.put_object.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace + def get_string( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an string as anything. Returns string 'foo'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_string_request( + template_url=self.get_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace + def put_string( + self, + input, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + :param input: Pass in 'anything' for a 200, anything else for an object error. + :type input: any + :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/json") # type: Optional[str] + + json = self._serialize.body(input, "object") + + request = rest.build_put_string_request( + content_type=content_type, + json=json, + template_url=self.put_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace + def get_array( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_array_request( + template_url=self.get_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array.metadata = {"url": "/anything/array"} # type: ignore + + @distributed_trace + def put_array( + self, + input, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + :param input: Pass in ['foo', 'bar'] for a 200, anything else for an object error. + :type input: any + :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/json") # type: Optional[str] + + json = self._serialize.body(input, "object") + + request = rest.build_put_array_request( + content_type=content_type, + json=json, + template_url=self.put_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_array.metadata = {"url": "/anything/array"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Anything/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/setup.py new file mode 100644 index 00000000000..e194649ced4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Anything/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 = "anythingclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AnythingClient", + author_email="", + url="", + keywords=["Swagger", "AnythingClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_auto_rest_swagger_bat_array_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_auto_rest_swagger_bat_array_service.py new file mode 100644 index 00000000000..e650ef4f021 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_auto_rest_swagger_bat_array_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATArrayServiceConfiguration +from .operations import ArrayOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATArrayService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar array: ArrayOperations operations + :vartype array: bodyarray.operations.ArrayOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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.array = ArrayOperations(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. + + We have helper methods to create requests specific to this service in `bodyarray.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyarray._rest import array + >>> request = array.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATArrayService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_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/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/__init__.py new file mode 100644 index 00000000000..a715b62d9ae --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/__init__.py @@ -0,0 +1,220 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_boolean_tfft_request + from ._request_builders_py3 import build_put_boolean_tfft_request + from ._request_builders_py3 import build_get_boolean_invalid_null_request + from ._request_builders_py3 import build_get_boolean_invalid_string_request + from ._request_builders_py3 import build_get_integer_valid_request + from ._request_builders_py3 import build_put_integer_valid_request + from ._request_builders_py3 import build_get_int_invalid_null_request + from ._request_builders_py3 import build_get_int_invalid_string_request + from ._request_builders_py3 import build_get_long_valid_request + from ._request_builders_py3 import build_put_long_valid_request + from ._request_builders_py3 import build_get_long_invalid_null_request + from ._request_builders_py3 import build_get_long_invalid_string_request + from ._request_builders_py3 import build_get_float_valid_request + from ._request_builders_py3 import build_put_float_valid_request + from ._request_builders_py3 import build_get_float_invalid_null_request + from ._request_builders_py3 import build_get_float_invalid_string_request + from ._request_builders_py3 import build_get_double_valid_request + from ._request_builders_py3 import build_put_double_valid_request + from ._request_builders_py3 import build_get_double_invalid_null_request + from ._request_builders_py3 import build_get_double_invalid_string_request + from ._request_builders_py3 import build_get_string_valid_request + from ._request_builders_py3 import build_put_string_valid_request + from ._request_builders_py3 import build_get_enum_valid_request + from ._request_builders_py3 import build_put_enum_valid_request + from ._request_builders_py3 import build_get_string_enum_valid_request + from ._request_builders_py3 import build_put_string_enum_valid_request + from ._request_builders_py3 import build_get_string_with_null_request + from ._request_builders_py3 import build_get_string_with_invalid_request + from ._request_builders_py3 import build_get_uuid_valid_request + from ._request_builders_py3 import build_put_uuid_valid_request + from ._request_builders_py3 import build_get_uuid_invalid_chars_request + from ._request_builders_py3 import build_get_date_valid_request + from ._request_builders_py3 import build_put_date_valid_request + from ._request_builders_py3 import build_get_date_invalid_null_request + from ._request_builders_py3 import build_get_date_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_valid_request + from ._request_builders_py3 import build_put_date_time_valid_request + from ._request_builders_py3 import build_get_date_time_invalid_null_request + from ._request_builders_py3 import build_get_date_time_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_put_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_get_duration_valid_request + from ._request_builders_py3 import build_put_duration_valid_request + from ._request_builders_py3 import build_get_byte_valid_request + from ._request_builders_py3 import build_put_byte_valid_request + from ._request_builders_py3 import build_get_byte_invalid_null_request + from ._request_builders_py3 import build_get_base64_url_request + from ._request_builders_py3 import build_get_complex_null_request + from ._request_builders_py3 import build_get_complex_empty_request + from ._request_builders_py3 import build_get_complex_item_null_request + from ._request_builders_py3 import build_get_complex_item_empty_request + from ._request_builders_py3 import build_get_complex_valid_request + from ._request_builders_py3 import build_put_complex_valid_request + from ._request_builders_py3 import build_get_array_null_request + from ._request_builders_py3 import build_get_array_empty_request + from ._request_builders_py3 import build_get_array_item_null_request + from ._request_builders_py3 import build_get_array_item_empty_request + from ._request_builders_py3 import build_get_array_valid_request + from ._request_builders_py3 import build_put_array_valid_request + from ._request_builders_py3 import build_get_dictionary_null_request + from ._request_builders_py3 import build_get_dictionary_empty_request + from ._request_builders_py3 import build_get_dictionary_item_null_request + from ._request_builders_py3 import build_get_dictionary_item_empty_request + from ._request_builders_py3 import build_get_dictionary_valid_request + from ._request_builders_py3 import build_put_dictionary_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_boolean_tfft_request # type: ignore + from ._request_builders import build_put_boolean_tfft_request # type: ignore + from ._request_builders import build_get_boolean_invalid_null_request # type: ignore + from ._request_builders import build_get_boolean_invalid_string_request # type: ignore + from ._request_builders import build_get_integer_valid_request # type: ignore + from ._request_builders import build_put_integer_valid_request # type: ignore + from ._request_builders import build_get_int_invalid_null_request # type: ignore + from ._request_builders import build_get_int_invalid_string_request # type: ignore + from ._request_builders import build_get_long_valid_request # type: ignore + from ._request_builders import build_put_long_valid_request # type: ignore + from ._request_builders import build_get_long_invalid_null_request # type: ignore + from ._request_builders import build_get_long_invalid_string_request # type: ignore + from ._request_builders import build_get_float_valid_request # type: ignore + from ._request_builders import build_put_float_valid_request # type: ignore + from ._request_builders import build_get_float_invalid_null_request # type: ignore + from ._request_builders import build_get_float_invalid_string_request # type: ignore + from ._request_builders import build_get_double_valid_request # type: ignore + from ._request_builders import build_put_double_valid_request # type: ignore + from ._request_builders import build_get_double_invalid_null_request # type: ignore + from ._request_builders import build_get_double_invalid_string_request # type: ignore + from ._request_builders import build_get_string_valid_request # type: ignore + from ._request_builders import build_put_string_valid_request # type: ignore + from ._request_builders import build_get_enum_valid_request # type: ignore + from ._request_builders import build_put_enum_valid_request # type: ignore + from ._request_builders import build_get_string_enum_valid_request # type: ignore + from ._request_builders import build_put_string_enum_valid_request # type: ignore + from ._request_builders import build_get_string_with_null_request # type: ignore + from ._request_builders import build_get_string_with_invalid_request # type: ignore + from ._request_builders import build_get_uuid_valid_request # type: ignore + from ._request_builders import build_put_uuid_valid_request # type: ignore + from ._request_builders import build_get_uuid_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_valid_request # type: ignore + from ._request_builders import build_put_date_valid_request # type: ignore + from ._request_builders import build_get_date_invalid_null_request # type: ignore + from ._request_builders import build_get_date_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_valid_request # type: ignore + from ._request_builders import build_put_date_time_valid_request # type: ignore + from ._request_builders import build_get_date_time_invalid_null_request # type: ignore + from ._request_builders import build_get_date_time_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_get_duration_valid_request # type: ignore + from ._request_builders import build_put_duration_valid_request # type: ignore + from ._request_builders import build_get_byte_valid_request # type: ignore + from ._request_builders import build_put_byte_valid_request # type: ignore + from ._request_builders import build_get_byte_invalid_null_request # type: ignore + from ._request_builders import build_get_base64_url_request # type: ignore + from ._request_builders import build_get_complex_null_request # type: ignore + from ._request_builders import build_get_complex_empty_request # type: ignore + from ._request_builders import build_get_complex_item_null_request # type: ignore + from ._request_builders import build_get_complex_item_empty_request # type: ignore + from ._request_builders import build_get_complex_valid_request # type: ignore + from ._request_builders import build_put_complex_valid_request # type: ignore + from ._request_builders import build_get_array_null_request # type: ignore + from ._request_builders import build_get_array_empty_request # type: ignore + from ._request_builders import build_get_array_item_null_request # type: ignore + from ._request_builders import build_get_array_item_empty_request # type: ignore + from ._request_builders import build_get_array_valid_request # type: ignore + from ._request_builders import build_put_array_valid_request # type: ignore + from ._request_builders import build_get_dictionary_null_request # type: ignore + from ._request_builders import build_get_dictionary_empty_request # type: ignore + from ._request_builders import build_get_dictionary_item_null_request # type: ignore + from ._request_builders import build_get_dictionary_item_empty_request # type: ignore + from ._request_builders import build_get_dictionary_valid_request # type: ignore + from ._request_builders import build_put_dictionary_valid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_boolean_tfft_request", + "build_put_boolean_tfft_request", + "build_get_boolean_invalid_null_request", + "build_get_boolean_invalid_string_request", + "build_get_integer_valid_request", + "build_put_integer_valid_request", + "build_get_int_invalid_null_request", + "build_get_int_invalid_string_request", + "build_get_long_valid_request", + "build_put_long_valid_request", + "build_get_long_invalid_null_request", + "build_get_long_invalid_string_request", + "build_get_float_valid_request", + "build_put_float_valid_request", + "build_get_float_invalid_null_request", + "build_get_float_invalid_string_request", + "build_get_double_valid_request", + "build_put_double_valid_request", + "build_get_double_invalid_null_request", + "build_get_double_invalid_string_request", + "build_get_string_valid_request", + "build_put_string_valid_request", + "build_get_enum_valid_request", + "build_put_enum_valid_request", + "build_get_string_enum_valid_request", + "build_put_string_enum_valid_request", + "build_get_string_with_null_request", + "build_get_string_with_invalid_request", + "build_get_uuid_valid_request", + "build_put_uuid_valid_request", + "build_get_uuid_invalid_chars_request", + "build_get_date_valid_request", + "build_put_date_valid_request", + "build_get_date_invalid_null_request", + "build_get_date_invalid_chars_request", + "build_get_date_time_valid_request", + "build_put_date_time_valid_request", + "build_get_date_time_invalid_null_request", + "build_get_date_time_invalid_chars_request", + "build_get_date_time_rfc1123_valid_request", + "build_put_date_time_rfc1123_valid_request", + "build_get_duration_valid_request", + "build_put_duration_valid_request", + "build_get_byte_valid_request", + "build_put_byte_valid_request", + "build_get_byte_invalid_null_request", + "build_get_base64_url_request", + "build_get_complex_null_request", + "build_get_complex_empty_request", + "build_get_complex_item_null_request", + "build_get_complex_item_empty_request", + "build_get_complex_valid_request", + "build_put_complex_valid_request", + "build_get_array_null_request", + "build_get_array_empty_request", + "build_get_array_item_null_request", + "build_get_array_item_empty_request", + "build_get_array_valid_request", + "build_put_array_valid_request", + "build_get_dictionary_null_request", + "build_get_dictionary_empty_request", + "build_get_dictionary_item_null_request", + "build_get_dictionary_item_empty_request", + "build_get_dictionary_valid_request", + "build_put_dictionary_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/_request_builders.py new file mode 100644 index 00000000000..8b40ed98145 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/_request_builders.py @@ -0,0 +1,2355 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null array value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid array [1, 2, 3. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty array value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/tfft') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/tfft') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, null, false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/true.null.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, 'boolean', false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/true.boolean.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/enum/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/enum/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string-enum/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string-enum/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo', null, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo.null.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo', 123, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo.123.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uuid_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_uuid_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uuid_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2012-01-01', null, '1776-07-04']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2011-03-22', 'date']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2000-12-01t00:00:01z', null]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time-rfc1123/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time-rfc1123/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/duration/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/duration/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/base64url/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty array of complex type []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/_request_builders_py3.py new file mode 100644 index 00000000000..2bba9fd4de8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_rest/array/_request_builders_py3.py @@ -0,0 +1,1798 @@ +# 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 datetime +from typing import Any, Dict, List, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null array value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid array [1, 2, 3. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty array value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_tfft_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/tfft") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_boolean_tfft_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/tfft") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, null, false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/true.null.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, 'boolean', false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/true.boolean.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_integer_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_integer_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_int_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get long array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get long array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_valid_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_valid_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_valid_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_enum_valid_request(**kwargs: Any) -> HttpRequest: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/enum/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_enum_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/enum/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_enum_valid_request(**kwargs: Any) -> HttpRequest: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string-enum/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_enum_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string-enum/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_with_null_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo', null, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo.null.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_with_invalid_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo', 123, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo.123.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_uuid_valid_request(**kwargs: Any) -> HttpRequest: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_uuid_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_uuid_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2012-01-01', null, '1776-07-04']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2011-03-22', 'date']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2000-12-01t00:00:01z', null]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_rfc1123_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time-rfc1123/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time-rfc1123/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_valid_request(**kwargs: Any) -> HttpRequest: + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/duration/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/duration/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_valid_request(**kwargs: Any) -> HttpRequest: + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_request(**kwargs: Any) -> HttpRequest: + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/base64url/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_null_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty array of complex type []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_null_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_valid_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_null_request(**kwargs: Any) -> HttpRequest: + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_empty_request(**kwargs: Any) -> HttpRequest: + """Get an empty array []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_auto_rest_swagger_bat_array_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_auto_rest_swagger_bat_array_service.py new file mode 100644 index 00000000000..2238fce5da0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_auto_rest_swagger_bat_array_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATArrayServiceConfiguration +from .operations import ArrayOperations + + +class AutoRestSwaggerBATArrayService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar array: ArrayOperations operations + :vartype array: bodyarray.aio.operations.ArrayOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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.array = ArrayOperations(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. + + We have helper methods to create requests specific to this service in `bodyarray.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyarray._rest import array + >>> request = array.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATArrayService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py new file mode 100644 index 00000000000..630829c34b4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/aio/operations/_array_operations.py @@ -0,0 +1,2676 @@ +# 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 datetime +import functools +from typing import Any, Callable, Dict, Generic, List, 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 ..._rest import array as rest_array + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ArrayOperations: + """ArrayOperations 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: ~bodyarray.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 get_null(self, **kwargs: Any) -> List[int]: + """Get null array value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/array/null"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> List[int]: + """Get invalid array [1, 2, 3. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/array/invalid"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> List[int]: + """Get empty array value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace_async + async def put_empty(self, array_body: List[str], **kwargs: Any) -> None: + """Set array value empty []. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace_async + async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: + """Get boolean array value [true, false, false, true]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_tfft_request( + template_url=self.get_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace_async + async def put_boolean_tfft(self, array_body: List[bool], **kwargs: Any) -> None: + """Set array value empty [true, false, false, true]. + + :param array_body: + :type array_body: list[bool] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bool]") + + request = rest_array.build_put_boolean_tfft_request( + content_type=content_type, + json=json, + template_url=self.put_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace_async + async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: + """Get boolean array value [true, null, false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_null_request( + template_url=self.get_boolean_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore + + @distributed_trace_async + async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: + """Get boolean array value [true, 'boolean', false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_string_request( + template_url=self.get_boolean_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore + + @distributed_trace_async + async def get_integer_valid(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_integer_valid_request( + template_url=self.get_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def put_integer_valid(self, array_body: List[int], **kwargs: Any) -> None: + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[int] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[int]") + + request = rest_array.build_put_integer_valid_request( + content_type=content_type, + json=json, + template_url=self.put_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_null_request( + template_url=self.get_int_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore + + @distributed_trace_async + async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_string_request( + template_url=self.get_int_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore + + @distributed_trace_async + async def get_long_valid(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_valid_request( + template_url=self.get_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def put_long_valid(self, array_body: List[int], **kwargs: Any) -> None: + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[long] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[long]") + + request = rest_array.build_put_long_valid_request( + content_type=content_type, + json=json, + template_url=self.put_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: + """Get long array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_null_request( + template_url=self.get_long_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore + + @distributed_trace_async + async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: + """Get long array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_string_request( + template_url=self.get_long_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore + + @distributed_trace_async + async def get_float_valid(self, **kwargs: Any) -> List[float]: + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_valid_request( + template_url=self.get_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def put_float_valid(self, array_body: List[float], **kwargs: Any) -> None: + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_float_valid_request( + content_type=content_type, + json=json, + template_url=self.put_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_null_request( + template_url=self.get_float_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_string_request( + template_url=self.get_float_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore + + @distributed_trace_async + async def get_double_valid(self, **kwargs: Any) -> List[float]: + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_valid_request( + template_url=self.get_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def put_double_valid(self, array_body: List[float], **kwargs: Any) -> None: + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_double_valid_request( + content_type=content_type, + json=json, + template_url=self.put_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_null_request( + template_url=self.get_double_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_string_request( + template_url=self.get_double_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore + + @distributed_trace_async + async def get_string_valid(self, **kwargs: Any) -> List[str]: + """Get string array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_valid_request( + template_url=self.get_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_string_valid(self, array_body: List[str], **kwargs: Any) -> None: + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.FooEnum"]]: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of FooEnum, or the result of cls(response) + :rtype: list[str or ~bodyarray.models.FooEnum] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_enum_valid_request( + template_url=self.get_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_enum_valid(self, array_body: List[Union[str, "_models.FooEnum"]], **kwargs: Any) -> None: + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~bodyarray.models.FooEnum] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.Enum0"]]: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Enum0, or the result of cls(response) + :rtype: list[str or ~bodyarray.models.Enum0] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_enum_valid_request( + template_url=self.get_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_string_enum_valid(self, array_body: List[Union[str, "_models.Enum1"]], **kwargs: Any) -> None: + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~bodyarray.models.Enum1] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_string_with_null(self, **kwargs: Any) -> List[str]: + """Get string array value ['foo', null, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_null_request( + template_url=self.get_string_with_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore + + @distributed_trace_async + async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: + """Get string array value ['foo', 123, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_invalid_request( + template_url=self.get_string_with_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore + + @distributed_trace_async + async def get_uuid_valid(self, **kwargs: Any) -> List[str]: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_valid_request( + template_url=self.get_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace_async + async def put_uuid_valid(self, array_body: List[str], **kwargs: Any) -> None: + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_uuid_valid_request( + content_type=content_type, + json=json, + template_url=self.put_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace_async + async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_invalid_chars_request( + template_url=self.get_uuid_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_valid_request( + template_url=self.get_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace_async + async def put_date_valid(self, array_body: List[datetime.date], **kwargs: Any) -> None: + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :param array_body: + :type array_body: list[~datetime.date] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[date]") + + request = rest_array.build_put_date_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace_async + async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: + """Get date array value ['2012-01-01', null, '1776-07-04']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_null_request( + template_url=self.get_date_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: + """Get date array value ['2011-03-22', 'date']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_chars_request( + template_url=self.get_date_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_valid_request( + template_url=self.get_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace_async + async def put_date_time_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[iso-8601]") + + request = rest_array.build_put_date_time_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace_async + async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date array value ['2000-12-01t00:00:01z', null]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_null_request( + template_url=self.get_date_time_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_chars_request( + template_url=self.get_date_time_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_rfc1123_valid_request( + template_url=self.get_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[rfc-1123]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace_async + async def put_date_time_rfc1123_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[rfc-1123]") + + request = rest_array.build_put_date_time_rfc1123_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace_async + async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of timedelta, or the result of cls(response) + :rtype: list[~datetime.timedelta] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_duration_valid_request( + template_url=self.get_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[duration]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace_async + async def put_duration_valid(self, array_body: List[datetime.timedelta], **kwargs: Any) -> None: + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :param array_body: + :type array_body: list[~datetime.timedelta] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[duration]") + + request = rest_array.build_put_duration_valid_request( + content_type=content_type, + json=json, + template_url=self.put_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace_async + async def get_byte_valid(self, **kwargs: Any) -> List[bytearray]: + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_valid_request( + template_url=self.get_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace_async + async def put_byte_valid(self, array_body: List[bytearray], **kwargs: Any) -> None: + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + :param array_body: + :type array_body: list[bytearray] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bytearray]") + + request = rest_array.build_put_byte_valid_request( + content_type=content_type, + json=json, + template_url=self.put_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace_async + async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytearray]: + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_invalid_null_request( + template_url=self.get_byte_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_base64_url(self, **kwargs: Any) -> List[bytes]: + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytes, or the result of cls(response) + :rtype: list[bytes] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_base64_url_request( + template_url=self.get_base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[base64]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore + + @distributed_trace_async + async def get_complex_null(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_null_request( + template_url=self.get_complex_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore + + @distributed_trace_async + async def get_complex_empty(self, **kwargs: Any) -> List["_models.Product"]: + """Get empty array of complex type []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_empty_request( + template_url=self.get_complex_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore + + @distributed_trace_async + async def get_complex_item_null(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_null_request( + template_url=self.get_complex_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore + + @distributed_trace_async + async def get_complex_item_empty(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_empty_request( + template_url=self.get_complex_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore + + @distributed_trace_async + async def get_complex_valid(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_valid_request( + template_url=self.get_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace_async + async def put_complex_valid(self, array_body: List["_models.Product"], **kwargs: Any) -> None: + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + :param array_body: + :type array_body: list[~bodyarray.models.Product] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[Product]") + + request = rest_array.build_put_complex_valid_request( + content_type=content_type, + json=json, + template_url=self.put_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace_async + async def get_array_null(self, **kwargs: Any) -> List[List[str]]: + """Get a null array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_null_request( + template_url=self.get_array_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_null.metadata = {"url": "/array/array/null"} # type: ignore + + @distributed_trace_async + async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: + """Get an empty array []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_empty_request( + template_url=self.get_array_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore + + @distributed_trace_async + async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_null_request( + template_url=self.get_array_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore + + @distributed_trace_async + async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_empty_request( + template_url=self.get_array_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore + + @distributed_trace_async + async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_valid_request( + template_url=self.get_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace_async + async def put_array_valid(self, array_body: List[List[str]], **kwargs: Any) -> None: + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :param array_body: + :type array_body: list[list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[[str]]") + + request = rest_array.build_put_array_valid_request( + content_type=content_type, + json=json, + template_url=self.put_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace_async + async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries with value null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_null_request( + template_url=self.get_dictionary_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore + + @distributed_trace_async + async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_empty_request( + template_url=self.get_dictionary_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore + + @distributed_trace_async + async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_null_request( + template_url=self.get_dictionary_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore + + @distributed_trace_async + async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_empty_request( + template_url=self.get_dictionary_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore + + @distributed_trace_async + async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_valid_request( + template_url=self.get_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore + + @distributed_trace_async + async def put_dictionary_valid(self, array_body: List[Dict[str, str]], **kwargs: Any) -> None: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :param array_body: + :type array_body: list[dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[{str}]") + + request = rest_array.build_put_dictionary_valid_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/_auto_rest_swagger_bat_array_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/_auto_rest_swagger_bat_array_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/_auto_rest_swagger_bat_array_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/_auto_rest_swagger_bat_array_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArray/bodyarray/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py new file mode 100644 index 00000000000..78f810206dd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/operations/_array_operations.py @@ -0,0 +1,2785 @@ +# 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 datetime +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 .. import models as _models +from .._rest import array as rest_array + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class ArrayOperations(object): + """ArrayOperations 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: ~bodyarray.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get null array value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/array/null"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get invalid array [1, 2, 3. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/array/invalid"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get empty array value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace + def put_empty( + self, + array_body, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty []. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace + def get_boolean_tfft( + self, **kwargs # type: Any + ): + # type: (...) -> List[bool] + """Get boolean array value [true, false, false, true]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_tfft_request( + template_url=self.get_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace + def put_boolean_tfft( + self, + array_body, # type: List[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty [true, false, false, true]. + + :param array_body: + :type array_body: list[bool] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bool]") + + request = rest_array.build_put_boolean_tfft_request( + content_type=content_type, + json=json, + template_url=self.put_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace + def get_boolean_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[bool] + """Get boolean array value [true, null, false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_null_request( + template_url=self.get_boolean_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore + + @distributed_trace + def get_boolean_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[bool] + """Get boolean array value [true, 'boolean', false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_string_request( + template_url=self.get_boolean_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore + + @distributed_trace + def get_integer_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_integer_valid_request( + template_url=self.get_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace + def put_integer_valid( + self, + array_body, # type: List[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[int] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[int]") + + request = rest_array.build_put_integer_valid_request( + content_type=content_type, + json=json, + template_url=self.put_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace + def get_int_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_null_request( + template_url=self.get_int_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore + + @distributed_trace + def get_int_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_string_request( + template_url=self.get_int_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore + + @distributed_trace + def get_long_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_valid_request( + template_url=self.get_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace + def put_long_valid( + self, + array_body, # type: List[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[long] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[long]") + + request = rest_array.build_put_long_valid_request( + content_type=content_type, + json=json, + template_url=self.put_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace + def get_long_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get long array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_null_request( + template_url=self.get_long_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore + + @distributed_trace + def get_long_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get long array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_string_request( + template_url=self.get_long_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore + + @distributed_trace + def get_float_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_valid_request( + template_url=self.get_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def put_float_valid( + self, + array_body, # type: List[float] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_float_valid_request( + content_type=content_type, + json=json, + template_url=self.put_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def get_float_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_null_request( + template_url=self.get_float_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore + + @distributed_trace + def get_float_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_string_request( + template_url=self.get_float_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore + + @distributed_trace + def get_double_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_valid_request( + template_url=self.get_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def put_double_valid( + self, + array_body, # type: List[float] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_double_valid_request( + content_type=content_type, + json=json, + template_url=self.put_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def get_double_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_null_request( + template_url=self.get_double_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore + + @distributed_trace + def get_double_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_string_request( + template_url=self.get_double_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore + + @distributed_trace + def get_string_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get string array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_valid_request( + template_url=self.get_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_string_valid( + self, + array_body, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_enum_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[Union[str, "_models.FooEnum"]] + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of FooEnum, or the result of cls(response) + :rtype: list[str or ~bodyarray.models.FooEnum] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_enum_valid_request( + template_url=self.get_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_enum_valid( + self, + array_body, # type: List[Union[str, "_models.FooEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~bodyarray.models.FooEnum] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_string_enum_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[Union[str, "_models.Enum0"]] + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Enum0, or the result of cls(response) + :rtype: list[str or ~bodyarray.models.Enum0] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_enum_valid_request( + template_url=self.get_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_string_enum_valid( + self, + array_body, # type: List[Union[str, "_models.Enum1"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~bodyarray.models.Enum1] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_string_with_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get string array value ['foo', null, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_null_request( + template_url=self.get_string_with_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore + + @distributed_trace + def get_string_with_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get string array value ['foo', 123, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_invalid_request( + template_url=self.get_string_with_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore + + @distributed_trace + def get_uuid_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_valid_request( + template_url=self.get_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace + def put_uuid_valid( + self, + array_body, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_uuid_valid_request( + content_type=content_type, + json=json, + template_url=self.put_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace + def get_uuid_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_invalid_chars_request( + template_url=self.get_uuid_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore + + @distributed_trace + def get_date_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.date] + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_valid_request( + template_url=self.get_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace + def put_date_valid( + self, + array_body, # type: List[datetime.date] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :param array_body: + :type array_body: list[~datetime.date] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[date]") + + request = rest_array.build_put_date_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace + def get_date_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.date] + """Get date array value ['2012-01-01', null, '1776-07-04']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_null_request( + template_url=self.get_date_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore + + @distributed_trace + def get_date_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.date] + """Get date array value ['2011-03-22', 'date']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_chars_request( + template_url=self.get_date_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore + + @distributed_trace + def get_date_time_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_valid_request( + template_url=self.get_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace + def put_date_time_valid( + self, + array_body, # type: List[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[iso-8601]") + + request = rest_array.build_put_date_time_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace + def get_date_time_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date array value ['2000-12-01t00:00:01z', null]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_null_request( + template_url=self.get_date_time_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore + + @distributed_trace + def get_date_time_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_chars_request( + template_url=self.get_date_time_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore + + @distributed_trace + def get_date_time_rfc1123_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_rfc1123_valid_request( + template_url=self.get_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[rfc-1123]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace + def put_date_time_rfc1123_valid( + self, + array_body, # type: List[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[rfc-1123]") + + request = rest_array.build_put_date_time_rfc1123_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace + def get_duration_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.timedelta] + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of timedelta, or the result of cls(response) + :rtype: list[~datetime.timedelta] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_duration_valid_request( + template_url=self.get_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[duration]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace + def put_duration_valid( + self, + array_body, # type: List[datetime.timedelta] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :param array_body: + :type array_body: list[~datetime.timedelta] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[duration]") + + request = rest_array.build_put_duration_valid_request( + content_type=content_type, + json=json, + template_url=self.put_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace + def get_byte_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[bytearray] + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_valid_request( + template_url=self.get_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace + def put_byte_valid( + self, + array_body, # type: List[bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + :param array_body: + :type array_body: list[bytearray] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bytearray]") + + request = rest_array.build_put_byte_valid_request( + content_type=content_type, + json=json, + template_url=self.put_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace + def get_byte_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[bytearray] + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_invalid_null_request( + template_url=self.get_byte_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore + + @distributed_trace + def get_base64_url( + self, **kwargs # type: Any + ): + # type: (...) -> List[bytes] + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytes, or the result of cls(response) + :rtype: list[bytes] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_base64_url_request( + template_url=self.get_base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[base64]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore + + @distributed_trace + def get_complex_null( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_null_request( + template_url=self.get_complex_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore + + @distributed_trace + def get_complex_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get empty array of complex type []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_empty_request( + template_url=self.get_complex_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore + + @distributed_trace + def get_complex_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_null_request( + template_url=self.get_complex_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore + + @distributed_trace + def get_complex_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_empty_request( + template_url=self.get_complex_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore + + @distributed_trace + def get_complex_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~bodyarray.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_valid_request( + template_url=self.get_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace + def put_complex_valid( + self, + array_body, # type: List["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + :param array_body: + :type array_body: list[~bodyarray.models.Product] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[Product]") + + request = rest_array.build_put_complex_valid_request( + content_type=content_type, + json=json, + template_url=self.put_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace + def get_array_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get a null array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_null_request( + template_url=self.get_array_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_null.metadata = {"url": "/array/array/null"} # type: ignore + + @distributed_trace + def get_array_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an empty array []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_empty_request( + template_url=self.get_array_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore + + @distributed_trace + def get_array_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_null_request( + template_url=self.get_array_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore + + @distributed_trace + def get_array_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_empty_request( + template_url=self.get_array_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore + + @distributed_trace + def get_array_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_valid_request( + template_url=self.get_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace + def put_array_valid( + self, + array_body, # type: List[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :param array_body: + :type array_body: list[list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[[str]]") + + request = rest_array.build_put_array_valid_request( + content_type=content_type, + json=json, + template_url=self.put_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace + def get_dictionary_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries with value null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_null_request( + template_url=self.get_dictionary_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore + + @distributed_trace + def get_dictionary_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_empty_request( + template_url=self.get_dictionary_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore + + @distributed_trace + def get_dictionary_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_null_request( + template_url=self.get_dictionary_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore + + @distributed_trace + def get_dictionary_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_empty_request( + template_url=self.get_dictionary_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore + + @distributed_trace + def get_dictionary_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_valid_request( + template_url=self.get_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore + + @distributed_trace + def put_dictionary_valid( + self, + array_body, # type: List[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :param array_body: + :type array_body: list[dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[{str}]") + + request = rest_array.build_put_dictionary_valid_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/setup.py new file mode 100644 index 00000000000..91869cd4bbe --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/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 = "autorestswaggerbatarrayservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATArrayService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATArrayService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/setup.py new file mode 100644 index 00000000000..91869cd4bbe --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/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 = "autorestswaggerbatarrayservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATArrayService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATArrayService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_auto_rest_swagger_bat_array_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_auto_rest_swagger_bat_array_service.py new file mode 100644 index 00000000000..399b48bfeee --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_auto_rest_swagger_bat_array_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATArrayServiceConfiguration +from .operations import ArrayOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATArrayService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar array: ArrayOperations operations + :vartype array: vanilla.body.array.operations.ArrayOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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.array = ArrayOperations(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. + + We have helper methods to create requests specific to this service in `vanilla.body.array.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from vanilla.body.array._rest import array + >>> request = array.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATArrayService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_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/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/__init__.py new file mode 100644 index 00000000000..a715b62d9ae --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/__init__.py @@ -0,0 +1,220 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_boolean_tfft_request + from ._request_builders_py3 import build_put_boolean_tfft_request + from ._request_builders_py3 import build_get_boolean_invalid_null_request + from ._request_builders_py3 import build_get_boolean_invalid_string_request + from ._request_builders_py3 import build_get_integer_valid_request + from ._request_builders_py3 import build_put_integer_valid_request + from ._request_builders_py3 import build_get_int_invalid_null_request + from ._request_builders_py3 import build_get_int_invalid_string_request + from ._request_builders_py3 import build_get_long_valid_request + from ._request_builders_py3 import build_put_long_valid_request + from ._request_builders_py3 import build_get_long_invalid_null_request + from ._request_builders_py3 import build_get_long_invalid_string_request + from ._request_builders_py3 import build_get_float_valid_request + from ._request_builders_py3 import build_put_float_valid_request + from ._request_builders_py3 import build_get_float_invalid_null_request + from ._request_builders_py3 import build_get_float_invalid_string_request + from ._request_builders_py3 import build_get_double_valid_request + from ._request_builders_py3 import build_put_double_valid_request + from ._request_builders_py3 import build_get_double_invalid_null_request + from ._request_builders_py3 import build_get_double_invalid_string_request + from ._request_builders_py3 import build_get_string_valid_request + from ._request_builders_py3 import build_put_string_valid_request + from ._request_builders_py3 import build_get_enum_valid_request + from ._request_builders_py3 import build_put_enum_valid_request + from ._request_builders_py3 import build_get_string_enum_valid_request + from ._request_builders_py3 import build_put_string_enum_valid_request + from ._request_builders_py3 import build_get_string_with_null_request + from ._request_builders_py3 import build_get_string_with_invalid_request + from ._request_builders_py3 import build_get_uuid_valid_request + from ._request_builders_py3 import build_put_uuid_valid_request + from ._request_builders_py3 import build_get_uuid_invalid_chars_request + from ._request_builders_py3 import build_get_date_valid_request + from ._request_builders_py3 import build_put_date_valid_request + from ._request_builders_py3 import build_get_date_invalid_null_request + from ._request_builders_py3 import build_get_date_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_valid_request + from ._request_builders_py3 import build_put_date_time_valid_request + from ._request_builders_py3 import build_get_date_time_invalid_null_request + from ._request_builders_py3 import build_get_date_time_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_put_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_get_duration_valid_request + from ._request_builders_py3 import build_put_duration_valid_request + from ._request_builders_py3 import build_get_byte_valid_request + from ._request_builders_py3 import build_put_byte_valid_request + from ._request_builders_py3 import build_get_byte_invalid_null_request + from ._request_builders_py3 import build_get_base64_url_request + from ._request_builders_py3 import build_get_complex_null_request + from ._request_builders_py3 import build_get_complex_empty_request + from ._request_builders_py3 import build_get_complex_item_null_request + from ._request_builders_py3 import build_get_complex_item_empty_request + from ._request_builders_py3 import build_get_complex_valid_request + from ._request_builders_py3 import build_put_complex_valid_request + from ._request_builders_py3 import build_get_array_null_request + from ._request_builders_py3 import build_get_array_empty_request + from ._request_builders_py3 import build_get_array_item_null_request + from ._request_builders_py3 import build_get_array_item_empty_request + from ._request_builders_py3 import build_get_array_valid_request + from ._request_builders_py3 import build_put_array_valid_request + from ._request_builders_py3 import build_get_dictionary_null_request + from ._request_builders_py3 import build_get_dictionary_empty_request + from ._request_builders_py3 import build_get_dictionary_item_null_request + from ._request_builders_py3 import build_get_dictionary_item_empty_request + from ._request_builders_py3 import build_get_dictionary_valid_request + from ._request_builders_py3 import build_put_dictionary_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_boolean_tfft_request # type: ignore + from ._request_builders import build_put_boolean_tfft_request # type: ignore + from ._request_builders import build_get_boolean_invalid_null_request # type: ignore + from ._request_builders import build_get_boolean_invalid_string_request # type: ignore + from ._request_builders import build_get_integer_valid_request # type: ignore + from ._request_builders import build_put_integer_valid_request # type: ignore + from ._request_builders import build_get_int_invalid_null_request # type: ignore + from ._request_builders import build_get_int_invalid_string_request # type: ignore + from ._request_builders import build_get_long_valid_request # type: ignore + from ._request_builders import build_put_long_valid_request # type: ignore + from ._request_builders import build_get_long_invalid_null_request # type: ignore + from ._request_builders import build_get_long_invalid_string_request # type: ignore + from ._request_builders import build_get_float_valid_request # type: ignore + from ._request_builders import build_put_float_valid_request # type: ignore + from ._request_builders import build_get_float_invalid_null_request # type: ignore + from ._request_builders import build_get_float_invalid_string_request # type: ignore + from ._request_builders import build_get_double_valid_request # type: ignore + from ._request_builders import build_put_double_valid_request # type: ignore + from ._request_builders import build_get_double_invalid_null_request # type: ignore + from ._request_builders import build_get_double_invalid_string_request # type: ignore + from ._request_builders import build_get_string_valid_request # type: ignore + from ._request_builders import build_put_string_valid_request # type: ignore + from ._request_builders import build_get_enum_valid_request # type: ignore + from ._request_builders import build_put_enum_valid_request # type: ignore + from ._request_builders import build_get_string_enum_valid_request # type: ignore + from ._request_builders import build_put_string_enum_valid_request # type: ignore + from ._request_builders import build_get_string_with_null_request # type: ignore + from ._request_builders import build_get_string_with_invalid_request # type: ignore + from ._request_builders import build_get_uuid_valid_request # type: ignore + from ._request_builders import build_put_uuid_valid_request # type: ignore + from ._request_builders import build_get_uuid_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_valid_request # type: ignore + from ._request_builders import build_put_date_valid_request # type: ignore + from ._request_builders import build_get_date_invalid_null_request # type: ignore + from ._request_builders import build_get_date_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_valid_request # type: ignore + from ._request_builders import build_put_date_time_valid_request # type: ignore + from ._request_builders import build_get_date_time_invalid_null_request # type: ignore + from ._request_builders import build_get_date_time_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_get_duration_valid_request # type: ignore + from ._request_builders import build_put_duration_valid_request # type: ignore + from ._request_builders import build_get_byte_valid_request # type: ignore + from ._request_builders import build_put_byte_valid_request # type: ignore + from ._request_builders import build_get_byte_invalid_null_request # type: ignore + from ._request_builders import build_get_base64_url_request # type: ignore + from ._request_builders import build_get_complex_null_request # type: ignore + from ._request_builders import build_get_complex_empty_request # type: ignore + from ._request_builders import build_get_complex_item_null_request # type: ignore + from ._request_builders import build_get_complex_item_empty_request # type: ignore + from ._request_builders import build_get_complex_valid_request # type: ignore + from ._request_builders import build_put_complex_valid_request # type: ignore + from ._request_builders import build_get_array_null_request # type: ignore + from ._request_builders import build_get_array_empty_request # type: ignore + from ._request_builders import build_get_array_item_null_request # type: ignore + from ._request_builders import build_get_array_item_empty_request # type: ignore + from ._request_builders import build_get_array_valid_request # type: ignore + from ._request_builders import build_put_array_valid_request # type: ignore + from ._request_builders import build_get_dictionary_null_request # type: ignore + from ._request_builders import build_get_dictionary_empty_request # type: ignore + from ._request_builders import build_get_dictionary_item_null_request # type: ignore + from ._request_builders import build_get_dictionary_item_empty_request # type: ignore + from ._request_builders import build_get_dictionary_valid_request # type: ignore + from ._request_builders import build_put_dictionary_valid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_boolean_tfft_request", + "build_put_boolean_tfft_request", + "build_get_boolean_invalid_null_request", + "build_get_boolean_invalid_string_request", + "build_get_integer_valid_request", + "build_put_integer_valid_request", + "build_get_int_invalid_null_request", + "build_get_int_invalid_string_request", + "build_get_long_valid_request", + "build_put_long_valid_request", + "build_get_long_invalid_null_request", + "build_get_long_invalid_string_request", + "build_get_float_valid_request", + "build_put_float_valid_request", + "build_get_float_invalid_null_request", + "build_get_float_invalid_string_request", + "build_get_double_valid_request", + "build_put_double_valid_request", + "build_get_double_invalid_null_request", + "build_get_double_invalid_string_request", + "build_get_string_valid_request", + "build_put_string_valid_request", + "build_get_enum_valid_request", + "build_put_enum_valid_request", + "build_get_string_enum_valid_request", + "build_put_string_enum_valid_request", + "build_get_string_with_null_request", + "build_get_string_with_invalid_request", + "build_get_uuid_valid_request", + "build_put_uuid_valid_request", + "build_get_uuid_invalid_chars_request", + "build_get_date_valid_request", + "build_put_date_valid_request", + "build_get_date_invalid_null_request", + "build_get_date_invalid_chars_request", + "build_get_date_time_valid_request", + "build_put_date_time_valid_request", + "build_get_date_time_invalid_null_request", + "build_get_date_time_invalid_chars_request", + "build_get_date_time_rfc1123_valid_request", + "build_put_date_time_rfc1123_valid_request", + "build_get_duration_valid_request", + "build_put_duration_valid_request", + "build_get_byte_valid_request", + "build_put_byte_valid_request", + "build_get_byte_invalid_null_request", + "build_get_base64_url_request", + "build_get_complex_null_request", + "build_get_complex_empty_request", + "build_get_complex_item_null_request", + "build_get_complex_item_empty_request", + "build_get_complex_valid_request", + "build_put_complex_valid_request", + "build_get_array_null_request", + "build_get_array_empty_request", + "build_get_array_item_null_request", + "build_get_array_item_empty_request", + "build_get_array_valid_request", + "build_put_array_valid_request", + "build_get_dictionary_null_request", + "build_get_dictionary_empty_request", + "build_get_dictionary_item_null_request", + "build_get_dictionary_item_empty_request", + "build_get_dictionary_valid_request", + "build_put_dictionary_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/_request_builders.py new file mode 100644 index 00000000000..8b40ed98145 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/_request_builders.py @@ -0,0 +1,2355 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null array value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid array [1, 2, 3. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty array value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/tfft') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/tfft') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, null, false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/true.null.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, 'boolean', false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/true.boolean.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/enum/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/enum/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string-enum/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string-enum/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo', null, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo.null.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo', 123, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo.123.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uuid_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_uuid_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uuid_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2012-01-01', null, '1776-07-04']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2011-03-22', 'date']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2000-12-01t00:00:01z', null]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time-rfc1123/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time-rfc1123/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/duration/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/duration/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/base64url/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty array of complex type []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/_request_builders_py3.py new file mode 100644 index 00000000000..2bba9fd4de8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_rest/array/_request_builders_py3.py @@ -0,0 +1,1798 @@ +# 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 datetime +from typing import Any, Dict, List, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null array value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid array [1, 2, 3. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty array value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_tfft_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/tfft") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_boolean_tfft_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/tfft") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, null, false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/true.null.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, 'boolean', false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/true.boolean.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_integer_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_integer_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_int_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get long array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get long array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_valid_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_valid_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_valid_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_enum_valid_request(**kwargs: Any) -> HttpRequest: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/enum/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_enum_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/enum/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_enum_valid_request(**kwargs: Any) -> HttpRequest: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string-enum/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_enum_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string-enum/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_with_null_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo', null, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo.null.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_with_invalid_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo', 123, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo.123.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_uuid_valid_request(**kwargs: Any) -> HttpRequest: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_uuid_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_uuid_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2012-01-01', null, '1776-07-04']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2011-03-22', 'date']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2000-12-01t00:00:01z', null]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_rfc1123_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time-rfc1123/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time-rfc1123/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_valid_request(**kwargs: Any) -> HttpRequest: + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/duration/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/duration/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_valid_request(**kwargs: Any) -> HttpRequest: + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_request(**kwargs: Any) -> HttpRequest: + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/base64url/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_null_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty array of complex type []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_null_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_valid_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_null_request(**kwargs: Any) -> HttpRequest: + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_empty_request(**kwargs: Any) -> HttpRequest: + """Get an empty array []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_auto_rest_swagger_bat_array_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_auto_rest_swagger_bat_array_service.py new file mode 100644 index 00000000000..a0d1952d819 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_auto_rest_swagger_bat_array_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATArrayServiceConfiguration +from .operations import ArrayOperations + + +class AutoRestSwaggerBATArrayService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar array: ArrayOperations operations + :vartype array: vanilla.body.array.aio.operations.ArrayOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATArrayServiceConfiguration(**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.array = ArrayOperations(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. + + We have helper methods to create requests specific to this service in `vanilla.body.array.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from vanilla.body.array._rest import array + >>> request = array.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATArrayService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py new file mode 100644 index 00000000000..4aacd91b31a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/aio/operations/_array_operations.py @@ -0,0 +1,2676 @@ +# 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 datetime +import functools +from typing import Any, Callable, Dict, Generic, List, 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 ..._rest import array as rest_array + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ArrayOperations: + """ArrayOperations 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: ~vanilla.body.array.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 get_null(self, **kwargs: Any) -> List[int]: + """Get null array value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/array/null"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> List[int]: + """Get invalid array [1, 2, 3. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/array/invalid"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> List[int]: + """Get empty array value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace_async + async def put_empty(self, array_body: List[str], **kwargs: Any) -> None: + """Set array value empty []. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace_async + async def get_boolean_tfft(self, **kwargs: Any) -> List[bool]: + """Get boolean array value [true, false, false, true]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_tfft_request( + template_url=self.get_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace_async + async def put_boolean_tfft(self, array_body: List[bool], **kwargs: Any) -> None: + """Set array value empty [true, false, false, true]. + + :param array_body: + :type array_body: list[bool] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bool]") + + request = rest_array.build_put_boolean_tfft_request( + content_type=content_type, + json=json, + template_url=self.put_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace_async + async def get_boolean_invalid_null(self, **kwargs: Any) -> List[bool]: + """Get boolean array value [true, null, false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_null_request( + template_url=self.get_boolean_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore + + @distributed_trace_async + async def get_boolean_invalid_string(self, **kwargs: Any) -> List[bool]: + """Get boolean array value [true, 'boolean', false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_string_request( + template_url=self.get_boolean_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore + + @distributed_trace_async + async def get_integer_valid(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_integer_valid_request( + template_url=self.get_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def put_integer_valid(self, array_body: List[int], **kwargs: Any) -> None: + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[int] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[int]") + + request = rest_array.build_put_integer_valid_request( + content_type=content_type, + json=json, + template_url=self.put_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def get_int_invalid_null(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_null_request( + template_url=self.get_int_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore + + @distributed_trace_async + async def get_int_invalid_string(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_string_request( + template_url=self.get_int_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore + + @distributed_trace_async + async def get_long_valid(self, **kwargs: Any) -> List[int]: + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_valid_request( + template_url=self.get_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def put_long_valid(self, array_body: List[int], **kwargs: Any) -> None: + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[long] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[long]") + + request = rest_array.build_put_long_valid_request( + content_type=content_type, + json=json, + template_url=self.put_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def get_long_invalid_null(self, **kwargs: Any) -> List[int]: + """Get long array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_null_request( + template_url=self.get_long_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore + + @distributed_trace_async + async def get_long_invalid_string(self, **kwargs: Any) -> List[int]: + """Get long array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_string_request( + template_url=self.get_long_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore + + @distributed_trace_async + async def get_float_valid(self, **kwargs: Any) -> List[float]: + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_valid_request( + template_url=self.get_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def put_float_valid(self, array_body: List[float], **kwargs: Any) -> None: + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_float_valid_request( + content_type=content_type, + json=json, + template_url=self.put_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_float_invalid_null(self, **kwargs: Any) -> List[float]: + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_null_request( + template_url=self.get_float_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_float_invalid_string(self, **kwargs: Any) -> List[float]: + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_string_request( + template_url=self.get_float_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore + + @distributed_trace_async + async def get_double_valid(self, **kwargs: Any) -> List[float]: + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_valid_request( + template_url=self.get_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def put_double_valid(self, array_body: List[float], **kwargs: Any) -> None: + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_double_valid_request( + content_type=content_type, + json=json, + template_url=self.put_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_double_invalid_null(self, **kwargs: Any) -> List[float]: + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_null_request( + template_url=self.get_double_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_double_invalid_string(self, **kwargs: Any) -> List[float]: + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_string_request( + template_url=self.get_double_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore + + @distributed_trace_async + async def get_string_valid(self, **kwargs: Any) -> List[str]: + """Get string array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_valid_request( + template_url=self.get_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_string_valid(self, array_body: List[str], **kwargs: Any) -> None: + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.FooEnum"]]: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of FooEnum, or the result of cls(response) + :rtype: list[str or ~vanilla.body.array.models.FooEnum] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_enum_valid_request( + template_url=self.get_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_enum_valid(self, array_body: List[Union[str, "_models.FooEnum"]], **kwargs: Any) -> None: + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~vanilla.body.array.models.FooEnum] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_string_enum_valid(self, **kwargs: Any) -> List[Union[str, "_models.Enum0"]]: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Enum0, or the result of cls(response) + :rtype: list[str or ~vanilla.body.array.models.Enum0] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_enum_valid_request( + template_url=self.get_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_string_enum_valid(self, array_body: List[Union[str, "_models.Enum1"]], **kwargs: Any) -> None: + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~vanilla.body.array.models.Enum1] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_string_with_null(self, **kwargs: Any) -> List[str]: + """Get string array value ['foo', null, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_null_request( + template_url=self.get_string_with_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore + + @distributed_trace_async + async def get_string_with_invalid(self, **kwargs: Any) -> List[str]: + """Get string array value ['foo', 123, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_invalid_request( + template_url=self.get_string_with_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore + + @distributed_trace_async + async def get_uuid_valid(self, **kwargs: Any) -> List[str]: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_valid_request( + template_url=self.get_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace_async + async def put_uuid_valid(self, array_body: List[str], **kwargs: Any) -> None: + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_uuid_valid_request( + content_type=content_type, + json=json, + template_url=self.put_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace_async + async def get_uuid_invalid_chars(self, **kwargs: Any) -> List[str]: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_invalid_chars_request( + template_url=self.get_uuid_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_valid(self, **kwargs: Any) -> List[datetime.date]: + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_valid_request( + template_url=self.get_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace_async + async def put_date_valid(self, array_body: List[datetime.date], **kwargs: Any) -> None: + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :param array_body: + :type array_body: list[~datetime.date] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[date]") + + request = rest_array.build_put_date_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace_async + async def get_date_invalid_null(self, **kwargs: Any) -> List[datetime.date]: + """Get date array value ['2012-01-01', null, '1776-07-04']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_null_request( + template_url=self.get_date_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_date_invalid_chars(self, **kwargs: Any) -> List[datetime.date]: + """Get date array value ['2011-03-22', 'date']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_chars_request( + template_url=self.get_date_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_time_valid(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_valid_request( + template_url=self.get_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace_async + async def put_date_time_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[iso-8601]") + + request = rest_array.build_put_date_time_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace_async + async def get_date_time_invalid_null(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date array value ['2000-12-01t00:00:01z', null]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_null_request( + template_url=self.get_date_time_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_date_time_invalid_chars(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_chars_request( + template_url=self.get_date_time_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> List[datetime.datetime]: + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_rfc1123_valid_request( + template_url=self.get_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[rfc-1123]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace_async + async def put_date_time_rfc1123_valid(self, array_body: List[datetime.datetime], **kwargs: Any) -> None: + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[rfc-1123]") + + request = rest_array.build_put_date_time_rfc1123_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace_async + async def get_duration_valid(self, **kwargs: Any) -> List[datetime.timedelta]: + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of timedelta, or the result of cls(response) + :rtype: list[~datetime.timedelta] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_duration_valid_request( + template_url=self.get_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[duration]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace_async + async def put_duration_valid(self, array_body: List[datetime.timedelta], **kwargs: Any) -> None: + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :param array_body: + :type array_body: list[~datetime.timedelta] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[duration]") + + request = rest_array.build_put_duration_valid_request( + content_type=content_type, + json=json, + template_url=self.put_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace_async + async def get_byte_valid(self, **kwargs: Any) -> List[bytearray]: + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_valid_request( + template_url=self.get_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace_async + async def put_byte_valid(self, array_body: List[bytearray], **kwargs: Any) -> None: + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + :param array_body: + :type array_body: list[bytearray] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bytearray]") + + request = rest_array.build_put_byte_valid_request( + content_type=content_type, + json=json, + template_url=self.put_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace_async + async def get_byte_invalid_null(self, **kwargs: Any) -> List[bytearray]: + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_invalid_null_request( + template_url=self.get_byte_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_base64_url(self, **kwargs: Any) -> List[bytes]: + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytes, or the result of cls(response) + :rtype: list[bytes] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_base64_url_request( + template_url=self.get_base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[base64]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore + + @distributed_trace_async + async def get_complex_null(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_null_request( + template_url=self.get_complex_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore + + @distributed_trace_async + async def get_complex_empty(self, **kwargs: Any) -> List["_models.Product"]: + """Get empty array of complex type []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_empty_request( + template_url=self.get_complex_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore + + @distributed_trace_async + async def get_complex_item_null(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_null_request( + template_url=self.get_complex_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore + + @distributed_trace_async + async def get_complex_item_empty(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_empty_request( + template_url=self.get_complex_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore + + @distributed_trace_async + async def get_complex_valid(self, **kwargs: Any) -> List["_models.Product"]: + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_valid_request( + template_url=self.get_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace_async + async def put_complex_valid(self, array_body: List["_models.Product"], **kwargs: Any) -> None: + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + :param array_body: + :type array_body: list[~vanilla.body.array.models.Product] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[Product]") + + request = rest_array.build_put_complex_valid_request( + content_type=content_type, + json=json, + template_url=self.put_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace_async + async def get_array_null(self, **kwargs: Any) -> List[List[str]]: + """Get a null array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_null_request( + template_url=self.get_array_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_null.metadata = {"url": "/array/array/null"} # type: ignore + + @distributed_trace_async + async def get_array_empty(self, **kwargs: Any) -> List[List[str]]: + """Get an empty array []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_empty_request( + template_url=self.get_array_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore + + @distributed_trace_async + async def get_array_item_null(self, **kwargs: Any) -> List[List[str]]: + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_null_request( + template_url=self.get_array_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore + + @distributed_trace_async + async def get_array_item_empty(self, **kwargs: Any) -> List[List[str]]: + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_empty_request( + template_url=self.get_array_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore + + @distributed_trace_async + async def get_array_valid(self, **kwargs: Any) -> List[List[str]]: + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_valid_request( + template_url=self.get_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace_async + async def put_array_valid(self, array_body: List[List[str]], **kwargs: Any) -> None: + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :param array_body: + :type array_body: list[list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[[str]]") + + request = rest_array.build_put_array_valid_request( + content_type=content_type, + json=json, + template_url=self.put_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace_async + async def get_dictionary_null(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries with value null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_null_request( + template_url=self.get_dictionary_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore + + @distributed_trace_async + async def get_dictionary_empty(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_empty_request( + template_url=self.get_dictionary_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore + + @distributed_trace_async + async def get_dictionary_item_null(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_null_request( + template_url=self.get_dictionary_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore + + @distributed_trace_async + async def get_dictionary_item_empty(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_empty_request( + template_url=self.get_dictionary_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore + + @distributed_trace_async + async def get_dictionary_valid(self, **kwargs: Any) -> List[Dict[str, str]]: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_valid_request( + template_url=self.get_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore + + @distributed_trace_async + async def put_dictionary_valid(self, array_body: List[Dict[str, str]], **kwargs: Any) -> None: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :param array_body: + :type array_body: list[dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[{str}]") + + request = rest_array.build_put_dictionary_valid_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_auto_rest_swagger_bat_array_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_auto_rest_swagger_bat_array_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_auto_rest_swagger_bat_array_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_auto_rest_swagger_bat_array_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py new file mode 100644 index 00000000000..79e1d4bf334 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/operations/_array_operations.py @@ -0,0 +1,2785 @@ +# 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 datetime +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 .. import models as _models +from .._rest import array as rest_array + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class ArrayOperations(object): + """ArrayOperations 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: ~vanilla.body.array.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get null array value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/array/null"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get invalid array [1, 2, 3. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/array/invalid"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get empty array value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace + def put_empty( + self, + array_body, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty []. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/array/empty"} # type: ignore + + @distributed_trace + def get_boolean_tfft( + self, **kwargs # type: Any + ): + # type: (...) -> List[bool] + """Get boolean array value [true, false, false, true]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_tfft_request( + template_url=self.get_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace + def put_boolean_tfft( + self, + array_body, # type: List[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty [true, false, false, true]. + + :param array_body: + :type array_body: list[bool] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bool]") + + request = rest_array.build_put_boolean_tfft_request( + content_type=content_type, + json=json, + template_url=self.put_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_boolean_tfft.metadata = {"url": "/array/prim/boolean/tfft"} # type: ignore + + @distributed_trace + def get_boolean_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[bool] + """Get boolean array value [true, null, false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_null_request( + template_url=self.get_boolean_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_null.metadata = {"url": "/array/prim/boolean/true.null.false"} # type: ignore + + @distributed_trace + def get_boolean_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[bool] + """Get boolean array value [true, 'boolean', false]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bool, or the result of cls(response) + :rtype: list[bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_boolean_invalid_string_request( + template_url=self.get_boolean_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bool]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_string.metadata = {"url": "/array/prim/boolean/true.boolean.false"} # type: ignore + + @distributed_trace + def get_integer_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_integer_valid_request( + template_url=self.get_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace + def put_integer_valid( + self, + array_body, # type: List[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[int] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[int]") + + request = rest_array.build_put_integer_valid_request( + content_type=content_type, + json=json, + template_url=self.put_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_integer_valid.metadata = {"url": "/array/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace + def get_int_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_null_request( + template_url=self.get_int_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_null.metadata = {"url": "/array/prim/integer/1.null.zero"} # type: ignore + + @distributed_trace + def get_int_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of int, or the result of cls(response) + :rtype: list[int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_int_invalid_string_request( + template_url=self.get_int_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[int]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_string.metadata = {"url": "/array/prim/integer/1.integer.0"} # type: ignore + + @distributed_trace + def get_long_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get integer array value [1, -1, 3, 300]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_valid_request( + template_url=self.get_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace + def put_long_valid( + self, + array_body, # type: List[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value empty [1, -1, 3, 300]. + + :param array_body: + :type array_body: list[long] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[long]") + + request = rest_array.build_put_long_valid_request( + content_type=content_type, + json=json, + template_url=self.put_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long_valid.metadata = {"url": "/array/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace + def get_long_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get long array value [1, null, 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_null_request( + template_url=self.get_long_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_null.metadata = {"url": "/array/prim/long/1.null.zero"} # type: ignore + + @distributed_trace + def get_long_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[int] + """Get long array value [1, 'integer', 0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of long, or the result of cls(response) + :rtype: list[long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_long_invalid_string_request( + template_url=self.get_long_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[long]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_string.metadata = {"url": "/array/prim/long/1.integer.0"} # type: ignore + + @distributed_trace + def get_float_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_valid_request( + template_url=self.get_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def put_float_valid( + self, + array_body, # type: List[float] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_float_valid_request( + content_type=content_type, + json=json, + template_url=self.put_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float_valid.metadata = {"url": "/array/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def get_float_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_null_request( + template_url=self.get_float_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_null.metadata = {"url": "/array/prim/float/0.0-null-1.2e20"} # type: ignore + + @distributed_trace + def get_float_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_float_invalid_string_request( + template_url=self.get_float_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_string.metadata = {"url": "/array/prim/float/1.number.0"} # type: ignore + + @distributed_trace + def get_double_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0, -0.01, 1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_valid_request( + template_url=self.get_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def put_double_valid( + self, + array_body, # type: List[float] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value [0, -0.01, 1.2e20]. + + :param array_body: + :type array_body: list[float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[float]") + + request = rest_array.build_put_double_valid_request( + content_type=content_type, + json=json, + template_url=self.put_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double_valid.metadata = {"url": "/array/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def get_double_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get float array value [0.0, null, -1.2e20]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_null_request( + template_url=self.get_double_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_null.metadata = {"url": "/array/prim/double/0.0-null-1.2e20"} # type: ignore + + @distributed_trace + def get_double_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> List[float] + """Get boolean array value [1.0, 'number', 0.0]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of float, or the result of cls(response) + :rtype: list[float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_double_invalid_string_request( + template_url=self.get_double_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[float]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_string.metadata = {"url": "/array/prim/double/1.number.0"} # type: ignore + + @distributed_trace + def get_string_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get string array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_valid_request( + template_url=self.get_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_string_valid( + self, + array_body, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_valid.metadata = {"url": "/array/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_enum_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[Union[str, "_models.FooEnum"]] + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of FooEnum, or the result of cls(response) + :rtype: list[str or ~vanilla.body.array.models.FooEnum] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.FooEnum"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_enum_valid_request( + template_url=self.get_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_enum_valid( + self, + array_body, # type: List[Union[str, "_models.FooEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~vanilla.body.array.models.FooEnum] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_enum_valid.metadata = {"url": "/array/prim/enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_string_enum_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[Union[str, "_models.Enum0"]] + """Get enum array value ['foo1', 'foo2', 'foo3']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Enum0, or the result of cls(response) + :rtype: list[str or ~vanilla.body.array.models.Enum0] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Union[str, "_models.Enum0"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_enum_valid_request( + template_url=self.get_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_string_enum_valid( + self, + array_body, # type: List[Union[str, "_models.Enum1"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['foo1', 'foo2', 'foo3']. + + :param array_body: + :type array_body: list[str or ~vanilla.body.array.models.Enum1] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_string_enum_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_enum_valid.metadata = {"url": "/array/prim/string-enum/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_string_with_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get string array value ['foo', null, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_null_request( + template_url=self.get_string_with_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_null.metadata = {"url": "/array/prim/string/foo.null.foo2"} # type: ignore + + @distributed_trace + def get_string_with_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get string array value ['foo', 123, 'foo2']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_string_with_invalid_request( + template_url=self.get_string_with_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_invalid.metadata = {"url": "/array/prim/string/foo.123.foo2"} # type: ignore + + @distributed_trace + def get_uuid_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_valid_request( + template_url=self.get_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace + def put_uuid_valid( + self, + array_body, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + :param array_body: + :type array_body: list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[str]") + + request = rest_array.build_put_uuid_valid_request( + content_type=content_type, + json=json, + template_url=self.put_uuid_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_uuid_valid.metadata = {"url": "/array/prim/uuid/valid"} # type: ignore + + @distributed_trace + def get_uuid_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> List[str] + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_uuid_invalid_chars_request( + template_url=self.get_uuid_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uuid_invalid_chars.metadata = {"url": "/array/prim/uuid/invalidchars"} # type: ignore + + @distributed_trace + def get_date_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.date] + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_valid_request( + template_url=self.get_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace + def put_date_valid( + self, + array_body, # type: List[datetime.date] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + :param array_body: + :type array_body: list[~datetime.date] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[date]") + + request = rest_array.build_put_date_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_valid.metadata = {"url": "/array/prim/date/valid"} # type: ignore + + @distributed_trace + def get_date_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.date] + """Get date array value ['2012-01-01', null, '1776-07-04']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_null_request( + template_url=self.get_date_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_null.metadata = {"url": "/array/prim/date/invalidnull"} # type: ignore + + @distributed_trace + def get_date_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.date] + """Get date array value ['2011-03-22', 'date']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of date, or the result of cls(response) + :rtype: list[~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_invalid_chars_request( + template_url=self.get_date_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[date]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_chars.metadata = {"url": "/array/prim/date/invalidchars"} # type: ignore + + @distributed_trace + def get_date_time_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_valid_request( + template_url=self.get_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace + def put_date_time_valid( + self, + array_body, # type: List[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[iso-8601]") + + request = rest_array.build_put_date_time_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_valid.metadata = {"url": "/array/prim/date-time/valid"} # type: ignore + + @distributed_trace + def get_date_time_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date array value ['2000-12-01t00:00:01z', null]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_null_request( + template_url=self.get_date_time_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_null.metadata = {"url": "/array/prim/date-time/invalidnull"} # type: ignore + + @distributed_trace + def get_date_time_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_invalid_chars_request( + template_url=self.get_date_time_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[iso-8601]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_chars.metadata = {"url": "/array/prim/date-time/invalidchars"} # type: ignore + + @distributed_trace + def get_date_time_rfc1123_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.datetime] + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of datetime, or the result of cls(response) + :rtype: list[~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_date_time_rfc1123_valid_request( + template_url=self.get_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[rfc-1123]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace + def put_date_time_rfc1123_valid( + self, + array_body, # type: List[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + :param array_body: + :type array_body: list[~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[rfc-1123]") + + request = rest_array.build_put_date_time_rfc1123_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123_valid.metadata = {"url": "/array/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace + def get_duration_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[datetime.timedelta] + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of timedelta, or the result of cls(response) + :rtype: list[~datetime.timedelta] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_duration_valid_request( + template_url=self.get_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[duration]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace + def put_duration_valid( + self, + array_body, # type: List[datetime.timedelta] + **kwargs # type: Any + ): + # type: (...) -> None + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + :param array_body: + :type array_body: list[~datetime.timedelta] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[duration]") + + request = rest_array.build_put_duration_valid_request( + content_type=content_type, + json=json, + template_url=self.put_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration_valid.metadata = {"url": "/array/prim/duration/valid"} # type: ignore + + @distributed_trace + def get_byte_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[bytearray] + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_valid_request( + template_url=self.get_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace + def put_byte_valid( + self, + array_body, # type: List[bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + :param array_body: + :type array_body: list[bytearray] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[bytearray]") + + request = rest_array.build_put_byte_valid_request( + content_type=content_type, + json=json, + template_url=self.put_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte_valid.metadata = {"url": "/array/prim/byte/valid"} # type: ignore + + @distributed_trace + def get_byte_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[bytearray] + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytearray, or the result of cls(response) + :rtype: list[bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_byte_invalid_null_request( + template_url=self.get_byte_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[bytearray]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_invalid_null.metadata = {"url": "/array/prim/byte/invalidnull"} # type: ignore + + @distributed_trace + def get_base64_url( + self, **kwargs # type: Any + ): + # type: (...) -> List[bytes] + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of bytes, or the result of cls(response) + :rtype: list[bytes] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_base64_url_request( + template_url=self.get_base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[base64]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url.metadata = {"url": "/array/prim/base64url/valid"} # type: ignore + + @distributed_trace + def get_complex_null( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_null_request( + template_url=self.get_complex_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_null.metadata = {"url": "/array/complex/null"} # type: ignore + + @distributed_trace + def get_complex_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get empty array of complex type []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_empty_request( + template_url=self.get_complex_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_empty.metadata = {"url": "/array/complex/empty"} # type: ignore + + @distributed_trace + def get_complex_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_null_request( + template_url=self.get_complex_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_null.metadata = {"url": "/array/complex/itemnull"} # type: ignore + + @distributed_trace + def get_complex_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_item_empty_request( + template_url=self.get_complex_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_empty.metadata = {"url": "/array/complex/itemempty"} # type: ignore + + @distributed_trace + def get_complex_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Product"] + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Product, or the result of cls(response) + :rtype: list[~vanilla.body.array.models.Product] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Product"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_complex_valid_request( + template_url=self.get_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[Product]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace + def put_complex_valid( + self, + array_body, # type: List["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + :param array_body: + :type array_body: list[~vanilla.body.array.models.Product] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[Product]") + + request = rest_array.build_put_complex_valid_request( + content_type=content_type, + json=json, + template_url=self.put_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_valid.metadata = {"url": "/array/complex/valid"} # type: ignore + + @distributed_trace + def get_array_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get a null array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_null_request( + template_url=self.get_array_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_null.metadata = {"url": "/array/array/null"} # type: ignore + + @distributed_trace + def get_array_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an empty array []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_empty_request( + template_url=self.get_array_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_empty.metadata = {"url": "/array/array/empty"} # type: ignore + + @distributed_trace + def get_array_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_null_request( + template_url=self.get_array_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_null.metadata = {"url": "/array/array/itemnull"} # type: ignore + + @distributed_trace + def get_array_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_item_empty_request( + template_url=self.get_array_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_empty.metadata = {"url": "/array/array/itemempty"} # type: ignore + + @distributed_trace + def get_array_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[List[str]] + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of list of str, or the result of cls(response) + :rtype: list[list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_array_valid_request( + template_url=self.get_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[[str]]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace + def put_array_valid( + self, + array_body, # type: List[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + :param array_body: + :type array_body: list[list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[[str]]") + + request = rest_array.build_put_array_valid_request( + content_type=content_type, + json=json, + template_url=self.put_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array_valid.metadata = {"url": "/array/array/valid"} # type: ignore + + @distributed_trace + def get_dictionary_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries with value null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_null_request( + template_url=self.get_dictionary_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_null.metadata = {"url": "/array/dictionary/null"} # type: ignore + + @distributed_trace + def get_dictionary_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value []. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_empty_request( + template_url=self.get_dictionary_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_empty.metadata = {"url": "/array/dictionary/empty"} # type: ignore + + @distributed_trace + def get_dictionary_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_null_request( + template_url=self.get_dictionary_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_null.metadata = {"url": "/array/dictionary/itemnull"} # type: ignore + + @distributed_trace + def get_dictionary_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_item_empty_request( + template_url=self.get_dictionary_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_empty.metadata = {"url": "/array/dictionary/itemempty"} # type: ignore + + @distributed_trace + def get_dictionary_valid( + self, **kwargs # type: Any + ): + # type: (...) -> List[Dict[str, str]] + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of dict mapping str to str, or the result of cls(response) + :rtype: list[dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List[Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_dictionary_valid_request( + template_url=self.get_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[{str}]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore + + @distributed_trace + def put_dictionary_valid( + self, + array_body, # type: List[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + :param array_body: + :type array_body: list[dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "[{str}]") + + request = rest_array.build_put_dictionary_valid_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary_valid.metadata = {"url": "/array/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/py.typed diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_auto_rest_bool_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_auto_rest_bool_test_service.py new file mode 100644 index 00000000000..9ee9116f023 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_auto_rest_bool_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestBoolTestServiceConfiguration +from .operations import BoolOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestBoolTestService(object): + """Test Infrastructure for AutoRest. + + :ivar bool: BoolOperations operations + :vartype bool: bodyboolean.operations.BoolOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestBoolTestServiceConfiguration(**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.bool = BoolOperations(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. + + We have helper methods to create requests specific to this service in `bodyboolean.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyboolean._rest import bool + >>> request = bool.build_get_true_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestBoolTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_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/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/__init__.py new file mode 100644 index 00000000000..a4fff07ee74 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/__init__.py @@ -0,0 +1,31 @@ +# 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_get_true_request + from ._request_builders_py3 import build_put_true_request + from ._request_builders_py3 import build_get_false_request + from ._request_builders_py3 import build_put_false_request + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_true_request # type: ignore + from ._request_builders import build_put_true_request # type: ignore + from ._request_builders import build_get_false_request # type: ignore + from ._request_builders import build_put_false_request # type: ignore + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_true_request", + "build_put_true_request", + "build_get_false_request", + "build_put_false_request", + "build_get_null_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/_request_builders.py new file mode 100644 index 00000000000..b7e710aa6ad --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/_request_builders.py @@ -0,0 +1,224 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/true') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set Boolean value true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/true') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get false Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set Boolean value false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/false') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/_request_builders_py3.py new file mode 100644 index 00000000000..6cbf9f46169 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_rest/bool/_request_builders_py3.py @@ -0,0 +1,171 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_true_request(**kwargs: Any) -> HttpRequest: + """Get true Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/true") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_true_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set Boolean value true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/true") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_false_request(**kwargs: Any) -> HttpRequest: + """Get false Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_false_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set Boolean value false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/false") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_auto_rest_bool_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_auto_rest_bool_test_service.py new file mode 100644 index 00000000000..6213460c06b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_auto_rest_bool_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestBoolTestServiceConfiguration +from .operations import BoolOperations + + +class AutoRestBoolTestService: + """Test Infrastructure for AutoRest. + + :ivar bool: BoolOperations operations + :vartype bool: bodyboolean.aio.operations.BoolOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestBoolTestServiceConfiguration(**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.bool = BoolOperations(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. + + We have helper methods to create requests specific to this service in `bodyboolean.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyboolean._rest import bool + >>> request = bool.build_get_true_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestBoolTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py new file mode 100644 index 00000000000..0d0e1a15476 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py @@ -0,0 +1,277 @@ +# 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 ... import models as _models +from ..._rest import bool as rest_bool + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BoolOperations: + """BoolOperations 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: ~bodyboolean.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 get_true(self, **kwargs: Any) -> bool: + """Get true Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_true_request( + template_url=self.get_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_true.metadata = {"url": "/bool/true"} # type: ignore + + @distributed_trace_async + async def put_true(self, **kwargs: Any) -> None: + """Set Boolean value true. + + :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/json") # type: Optional[str] + + bool_body = True + json = self._serialize.body(bool_body, "bool") + + request = rest_bool.build_put_true_request( + content_type=content_type, + json=json, + template_url=self.put_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_true.metadata = {"url": "/bool/true"} # type: ignore + + @distributed_trace_async + async def get_false(self, **kwargs: Any) -> bool: + """Get false Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_false_request( + template_url=self.get_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_false.metadata = {"url": "/bool/false"} # type: ignore + + @distributed_trace_async + async def put_false(self, **kwargs: Any) -> None: + """Set Boolean value false. + + :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/json") # type: Optional[str] + + bool_body = False + json = self._serialize.body(bool_body, "bool") + + request = rest_bool.build_put_false_request( + content_type=content_type, + json=json, + template_url=self.put_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_false.metadata = {"url": "/bool/false"} # type: ignore + + @distributed_trace_async + async def get_null(self, **kwargs: Any) -> Optional[bool]: + """Get null Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool or None, or the result of cls(response) + :rtype: bool or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/bool/null"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> bool: + """Get invalid Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/bool/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py new file mode 100644 index 00000000000..aecf277d2f6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py @@ -0,0 +1,287 @@ +# 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 .. import models as _models +from .._rest import bool as rest_bool + +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]] + + +class BoolOperations(object): + """BoolOperations 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: ~bodyboolean.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 get_true( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get true Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_true_request( + template_url=self.get_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_true.metadata = {"url": "/bool/true"} # type: ignore + + @distributed_trace + def put_true( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Set Boolean value true. + + :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/json") # type: Optional[str] + + bool_body = True + json = self._serialize.body(bool_body, "bool") + + request = rest_bool.build_put_true_request( + content_type=content_type, + json=json, + template_url=self.put_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_true.metadata = {"url": "/bool/true"} # type: ignore + + @distributed_trace + def get_false( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get false Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_false_request( + template_url=self.get_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_false.metadata = {"url": "/bool/false"} # type: ignore + + @distributed_trace + def put_false( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Set Boolean value false. + + :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/json") # type: Optional[str] + + bool_body = False + json = self._serialize.body(bool_body, "bool") + + request = rest_bool.build_put_false_request( + content_type=content_type, + json=json, + template_url=self.put_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_false.metadata = {"url": "/bool/false"} # type: ignore + + @distributed_trace + def get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[bool] + """Get null Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool or None, or the result of cls(response) + :rtype: bool or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/bool/null"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get invalid Boolean value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_bool.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/bool/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/setup.py new file mode 100644 index 00000000000..4710c12d52d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/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 = "autorestbooltestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestBoolTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestBoolTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_auto_rest_swagger_bat_byte_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_auto_rest_swagger_bat_byte_service.py new file mode 100644 index 00000000000..357ec5263e4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_auto_rest_swagger_bat_byte_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATByteServiceConfiguration +from .operations import ByteOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATByteService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar byte: ByteOperations operations + :vartype byte: bodybyte.operations.ByteOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATByteServiceConfiguration(**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.byte = ByteOperations(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. + + We have helper methods to create requests specific to this service in `bodybyte.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybyte._rest import byte + >>> request = byte.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATByteService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_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/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/__init__.py new file mode 100644 index 00000000000..9fdaa4a2115 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/__init__.py @@ -0,0 +1,28 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_get_non_ascii_request + from ._request_builders_py3 import build_put_non_ascii_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_get_non_ascii_request # type: ignore + from ._request_builders import build_put_non_ascii_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_empty_request", + "build_get_non_ascii_request", + "build_put_non_ascii_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/_request_builders.py new file mode 100644 index 00000000000..d7eaad29e28 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/_request_builders.py @@ -0,0 +1,185 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null byte value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty byte value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_non_ascii_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/nonAscii') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_ascii_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/nonAscii') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid byte value ':::SWAGGER::::'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/_request_builders_py3.py new file mode 100644 index 00000000000..f5841d3b6b0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_rest/byte/_request_builders_py3.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. +# -------------------------------------------------------------------------- +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null byte value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty byte value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_non_ascii_request(**kwargs: Any) -> HttpRequest: + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/nonAscii") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_non_ascii_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/nonAscii") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid byte value ':::SWAGGER::::'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_auto_rest_swagger_bat_byte_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_auto_rest_swagger_bat_byte_service.py new file mode 100644 index 00000000000..eebffa70739 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_auto_rest_swagger_bat_byte_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATByteServiceConfiguration +from .operations import ByteOperations + + +class AutoRestSwaggerBATByteService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar byte: ByteOperations operations + :vartype byte: bodybyte.aio.operations.ByteOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATByteServiceConfiguration(**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.byte = ByteOperations(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. + + We have helper methods to create requests specific to this service in `bodybyte.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybyte._rest import byte + >>> request = byte.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATByteService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py new file mode 100644 index 00000000000..97c178d0fcf --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/aio/operations/_byte_operations.py @@ -0,0 +1,239 @@ +# 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 ... import models as _models +from ..._rest import byte as rest_byte + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ByteOperations: + """ByteOperations 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: ~bodybyte.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 get_null(self, **kwargs: Any) -> bytearray: + """Get null byte value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/byte/null"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> bytearray: + """Get empty byte value ''. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/byte/empty"} # type: ignore + + @distributed_trace_async + async def get_non_ascii(self, **kwargs: Any) -> bytearray: + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_non_ascii_request( + template_url=self.get_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace_async + async def put_non_ascii(self, byte_body: bytearray, **kwargs: Any) -> None: + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + :type byte_body: bytearray + :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/json") # type: Optional[str] + + json = self._serialize.body(byte_body, "bytearray") + + request = rest_byte.build_put_non_ascii_request( + content_type=content_type, + json=json, + template_url=self.put_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> bytearray: + """Get invalid byte value ':::SWAGGER::::'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByte/bodybyte/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py new file mode 100644 index 00000000000..c7a2cdbac15 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/operations/_byte_operations.py @@ -0,0 +1,250 @@ +# 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 .. import models as _models +from .._rest import byte as rest_byte + +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]] + + +class ByteOperations(object): + """ByteOperations 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: ~bodybyte.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get null byte value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/byte/null"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get empty byte value ''. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/byte/empty"} # type: ignore + + @distributed_trace + def get_non_ascii( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_non_ascii_request( + template_url=self.get_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace + def put_non_ascii( + self, + byte_body, # type: bytearray + **kwargs # type: Any + ): + # type: (...) -> None + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + :type byte_body: bytearray + :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/json") # type: Optional[str] + + json = self._serialize.body(byte_body, "bytearray") + + request = rest_byte.build_put_non_ascii_request( + content_type=content_type, + json=json, + template_url=self.put_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get invalid byte value ':::SWAGGER::::'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/setup.py new file mode 100644 index 00000000000..7d370392696 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/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 = "autorestswaggerbatbyteservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATByteService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATByteService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_class_name.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_class_name.py new file mode 100644 index 00000000000..a5510fb4074 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_class_name.py @@ -0,0 +1,96 @@ +# 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 ClassNameConfiguration +from .operations import ByteOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class ClassName(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar byte: ByteOperations operations + :vartype byte: bodybytewithpackagename.operations.ByteOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = ClassNameConfiguration(**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.byte = ByteOperations(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. + + We have helper methods to create requests specific to this service in `bodybytewithpackagename.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybytewithpackagename._rest import byte + >>> request = byte.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> ClassName + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_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/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/__init__.py new file mode 100644 index 00000000000..9fdaa4a2115 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/__init__.py @@ -0,0 +1,28 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_get_non_ascii_request + from ._request_builders_py3 import build_put_non_ascii_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_get_non_ascii_request # type: ignore + from ._request_builders import build_put_non_ascii_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_empty_request", + "build_get_non_ascii_request", + "build_put_non_ascii_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/_request_builders.py new file mode 100644 index 00000000000..d7eaad29e28 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/_request_builders.py @@ -0,0 +1,185 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null byte value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty byte value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_non_ascii_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/nonAscii') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_ascii_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/nonAscii') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid byte value ':::SWAGGER::::'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/_request_builders_py3.py new file mode 100644 index 00000000000..f5841d3b6b0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_rest/byte/_request_builders_py3.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. +# -------------------------------------------------------------------------- +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null byte value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty byte value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_non_ascii_request(**kwargs: Any) -> HttpRequest: + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/nonAscii") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_non_ascii_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/nonAscii") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid byte value ':::SWAGGER::::'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_class_name.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_class_name.py new file mode 100644 index 00000000000..200dc28baba --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_class_name.py @@ -0,0 +1,78 @@ +# 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 ClassNameConfiguration +from .operations import ByteOperations + + +class ClassName: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar byte: ByteOperations operations + :vartype byte: bodybytewithpackagename.aio.operations.ByteOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = ClassNameConfiguration(**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.byte = ByteOperations(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. + + We have helper methods to create requests specific to this service in `bodybytewithpackagename.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybytewithpackagename._rest import byte + >>> request = byte.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "ClassName": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py new file mode 100644 index 00000000000..348149a4277 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/aio/operations/_byte_operations.py @@ -0,0 +1,239 @@ +# 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 ... import models as _models +from ..._rest import byte as rest_byte + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ByteOperations: + """ByteOperations 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: ~bodybytewithpackagename.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 get_null(self, **kwargs: Any) -> bytearray: + """Get null byte value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/byte/null"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> bytearray: + """Get empty byte value ''. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/byte/empty"} # type: ignore + + @distributed_trace_async + async def get_non_ascii(self, **kwargs: Any) -> bytearray: + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_non_ascii_request( + template_url=self.get_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace_async + async def put_non_ascii(self, byte_body: bytearray, **kwargs: Any) -> None: + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + :type byte_body: bytearray + :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/json") # type: Optional[str] + + json = self._serialize.body(byte_body, "bytearray") + + request = rest_byte.build_put_non_ascii_request( + content_type=content_type, + json=json, + template_url=self.put_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> bytearray: + """Get invalid byte value ':::SWAGGER::::'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py new file mode 100644 index 00000000000..efe6950f3fc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/operations/_byte_operations.py @@ -0,0 +1,250 @@ +# 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 .. import models as _models +from .._rest import byte as rest_byte + +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]] + + +class ByteOperations(object): + """ByteOperations 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: ~bodybytewithpackagename.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get null byte value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/byte/null"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get empty byte value ''. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/byte/empty"} # type: ignore + + @distributed_trace + def get_non_ascii( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_non_ascii_request( + template_url=self.get_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace + def put_non_ascii( + self, + byte_body, # type: bytearray + **kwargs # type: Any + ): + # type: (...) -> None + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + :param byte_body: Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + :type byte_body: bytearray + :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/json") # type: Optional[str] + + json = self._serialize.body(byte_body, "bytearray") + + request = rest_byte.build_put_non_ascii_request( + content_type=content_type, + json=json, + template_url=self.put_non_ascii.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_non_ascii.metadata = {"url": "/byte/nonAscii"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get invalid byte value ':::SWAGGER::::'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_byte.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/byte/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/setup.py new file mode 100644 index 00000000000..8d7efeb0c2c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/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 = "package-name" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="package-name", + author_email="", + url="", + keywords=["Swagger", "ClassName"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_auto_rest_complex_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_auto_rest_complex_test_service.py new file mode 100644 index 00000000000..e5035b1eb77 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_auto_rest_complex_test_service.py @@ -0,0 +1,133 @@ +# 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 AutoRestComplexTestServiceConfiguration +from .operations import ( + ArrayOperations, + BasicOperations, + DictionaryOperations, + FlattencomplexOperations, + InheritanceOperations, + PolymorphicrecursiveOperations, + PolymorphismOperations, + PrimitiveOperations, + ReadonlypropertyOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestComplexTestService(object): + """Test Infrastructure for AutoRest. + + :ivar basic: BasicOperations operations + :vartype basic: bodycomplex.operations.BasicOperations + :ivar primitive: PrimitiveOperations operations + :vartype primitive: bodycomplex.operations.PrimitiveOperations + :ivar array: ArrayOperations operations + :vartype array: bodycomplex.operations.ArrayOperations + :ivar dictionary: DictionaryOperations operations + :vartype dictionary: bodycomplex.operations.DictionaryOperations + :ivar inheritance: InheritanceOperations operations + :vartype inheritance: bodycomplex.operations.InheritanceOperations + :ivar polymorphism: PolymorphismOperations operations + :vartype polymorphism: bodycomplex.operations.PolymorphismOperations + :ivar polymorphicrecursive: PolymorphicrecursiveOperations operations + :vartype polymorphicrecursive: bodycomplex.operations.PolymorphicrecursiveOperations + :ivar readonlyproperty: ReadonlypropertyOperations operations + :vartype readonlyproperty: bodycomplex.operations.ReadonlypropertyOperations + :ivar flattencomplex: FlattencomplexOperations operations + :vartype flattencomplex: bodycomplex.operations.FlattencomplexOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestComplexTestServiceConfiguration(**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.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) + self.primitive = PrimitiveOperations(self._client, self._config, self._serialize, self._deserialize) + self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) + self.dictionary = DictionaryOperations(self._client, self._config, self._serialize, self._deserialize) + self.inheritance = InheritanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.polymorphism = PolymorphismOperations(self._client, self._config, self._serialize, self._deserialize) + self.polymorphicrecursive = PolymorphicrecursiveOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.readonlyproperty = ReadonlypropertyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flattencomplex = FlattencomplexOperations(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. + + We have helper methods to create requests specific to this service in `bodycomplex.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodycomplex._rest import basic + >>> request = basic.build_get_valid_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestComplexTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_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/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/__init__.py new file mode 100644 index 00000000000..11147632432 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/__init__.py @@ -0,0 +1,28 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_not_provided_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_not_provided_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/_request_builders.py new file mode 100644 index 00000000000..9a7ac494e3d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/_request_builders.py @@ -0,0 +1,196 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty array. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty array. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with array property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/notprovided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/_request_builders_py3.py new file mode 100644 index 00000000000..a213bcedb71 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/array/_request_builders_py3.py @@ -0,0 +1,151 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty array. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty array. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get complex types with array property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/notprovided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/__init__.py new file mode 100644 index 00000000000..2ea66984c02 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/__init__.py @@ -0,0 +1,31 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_not_provided_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_invalid_request", + "build_get_empty_request", + "build_get_null_request", + "build_get_not_provided_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/_request_builders.py new file mode 100644 index 00000000000..1ffb572a076 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/_request_builders.py @@ -0,0 +1,221 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Please put {id: 2, name: 'abc', color: 'Magenta'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put {id: 2, name: 'abc', color: 'Magenta'}. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put {id: 2, name: 'abc', color: 'Magenta'}. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-29" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type that is invalid for the local strong type. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type that is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type whose properties are null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type while the server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/notprovided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/_request_builders_py3.py new file mode 100644 index 00000000000..6f0fc7751b2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/basic/_request_builders_py3.py @@ -0,0 +1,169 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Please put {id: 2, name: 'abc', color: 'Magenta'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put {id: 2, name: 'abc', color: 'Magenta'}. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put {id: 2, name: 'abc', color: 'Magenta'}. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2016-02-29" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type that is invalid for the local strong type. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type that is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type whose properties are null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type while the server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/notprovided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/__init__.py new file mode 100644 index 00000000000..9d06b6a145a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/__init__.py @@ -0,0 +1,31 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_not_provided_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_null_request", + "build_get_not_provided_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/_request_builders.py new file mode 100644 index 00000000000..912e949d4e9 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/_request_builders.py @@ -0,0 +1,227 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty dictionary. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty dictionary. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property which is null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/notprovided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/_request_builders_py3.py new file mode 100644 index 00000000000..d07df075c47 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/dictionary/_request_builders_py3.py @@ -0,0 +1,174 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty dictionary. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty dictionary. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property which is null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/notprovided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/__init__.py new file mode 100644 index 00000000000..37b2d0a112d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/__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_get_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/_request_builders.py new file mode 100644 index 00000000000..d5f1e4d7dd9 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/_request_builders.py @@ -0,0 +1,50 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """get_valid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/flatten/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/_request_builders_py3.py new file mode 100644 index 00000000000..625ef98b535 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/flattencomplex/_request_builders_py3.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. +# -------------------------------------------------------------------------- +import datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """get_valid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/flatten/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/__init__.py new file mode 100644 index 00000000000..83d94e4e60b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/__init__.py @@ -0,0 +1,19 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/_request_builders.py new file mode 100644 index 00000000000..059beee6e99 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/_request_builders.py @@ -0,0 +1,95 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/inheritance/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a siamese with id=2, name="Siameee", + color=green, breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and + food="tomato", and the 2nd one named "Tomato" with id=-1 and food="french fries". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a siamese with id=2, name="Siameee", color=green, + breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and + the 2nd one named "Tomato" with id=-1 and food="french fries". + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/inheritance/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/_request_builders_py3.py new file mode 100644 index 00000000000..37bed468200 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/inheritance/_request_builders_py3.py @@ -0,0 +1,74 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/inheritance/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a siamese with id=2, name="Siameee", + color=green, breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and + food="tomato", and the 2nd one named "Tomato" with id=-1 and food="french fries". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a siamese with id=2, name="Siameee", color=green, + breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and + the 2nd one named "Tomato" with id=-1 and food="french fries". + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/inheritance/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/__init__.py new file mode 100644 index 00000000000..83d94e4e60b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/__init__.py @@ -0,0 +1,19 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/_request_builders.py new file mode 100644 index 00000000000..9158364e238 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/_request_builders.py @@ -0,0 +1,195 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphicrecursive/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphicrecursive/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/_request_builders_py3.py new file mode 100644 index 00000000000..fa3c95c7edd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphicrecursive/_request_builders_py3.py @@ -0,0 +1,174 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphicrecursive/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphicrecursive/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/__init__.py new file mode 100644 index 00000000000..3ea2d60203f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/__init__.py @@ -0,0 +1,40 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_dot_syntax_request + from ._request_builders_py3 import build_get_composed_with_discriminator_request + from ._request_builders_py3 import build_get_composed_without_discriminator_request + from ._request_builders_py3 import build_get_complicated_request + from ._request_builders_py3 import build_put_complicated_request + from ._request_builders_py3 import build_put_missing_discriminator_request + from ._request_builders_py3 import build_put_valid_missing_required_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_dot_syntax_request # type: ignore + from ._request_builders import build_get_composed_with_discriminator_request # type: ignore + from ._request_builders import build_get_composed_without_discriminator_request # type: ignore + from ._request_builders import build_get_complicated_request # type: ignore + from ._request_builders import build_put_complicated_request # type: ignore + from ._request_builders import build_put_missing_discriminator_request # type: ignore + from ._request_builders import build_put_valid_missing_required_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_dot_syntax_request", + "build_get_composed_with_discriminator_request", + "build_get_composed_without_discriminator_request", + "build_get_complicated_request", + "build_put_complicated_request", + "build_put_missing_discriminator_request", + "build_put_valid_missing_required_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/_request_builders.py new file mode 100644 index 00000000000..a8bce605566 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/_request_builders.py @@ -0,0 +1,461 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dot_syntax_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic, JSON key contains a dot. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/dotsyntax') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_composed_with_discriminator_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, with discriminator specified. Deserialization must NOT fail and use the + discriminator type specified on the wire. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/composedWithDiscriminator') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_composed_without_discriminator_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, without discriminator specified on wire. Deserialization must NOT fail and use + the explicit type of the property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/composedWithoutDiscriminator') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complicated_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/complicated') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complicated_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/complicated') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_missing_discriminator_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic, omitting the discriminator. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/missingdiscriminator') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_missing_required_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the + request should not be allowed from the client. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/missingrequired/invalid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/_request_builders_py3.py new file mode 100644 index 00000000000..34b62815f55 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/polymorphism/_request_builders_py3.py @@ -0,0 +1,384 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dot_syntax_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic, JSON key contains a dot. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/dotsyntax") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_composed_with_discriminator_request(**kwargs: Any) -> HttpRequest: + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, with discriminator specified. Deserialization must NOT fail and use the + discriminator type specified on the wire. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/composedWithDiscriminator") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_composed_without_discriminator_request(**kwargs: Any) -> HttpRequest: + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, without discriminator specified on wire. Deserialization must NOT fail and use + the explicit type of the property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/composedWithoutDiscriminator") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complicated_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/complicated") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complicated_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/complicated") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_missing_discriminator_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic, omitting the discriminator. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/missingdiscriminator") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_valid_missing_required_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the + request should not be allowed from the client. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/missingrequired/invalid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/__init__.py new file mode 100644 index 00000000000..4de6eb2c665 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/__init__.py @@ -0,0 +1,79 @@ +# 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_get_int_request + from ._request_builders_py3 import build_put_int_request + from ._request_builders_py3 import build_get_long_request + from ._request_builders_py3 import build_put_long_request + from ._request_builders_py3 import build_get_float_request + from ._request_builders_py3 import build_put_float_request + from ._request_builders_py3 import build_get_double_request + from ._request_builders_py3 import build_put_double_request + from ._request_builders_py3 import build_get_bool_request + from ._request_builders_py3 import build_put_bool_request + from ._request_builders_py3 import build_get_string_request + from ._request_builders_py3 import build_put_string_request + from ._request_builders_py3 import build_get_date_request + from ._request_builders_py3 import build_put_date_request + from ._request_builders_py3 import build_get_date_time_request + from ._request_builders_py3 import build_put_date_time_request + from ._request_builders_py3 import build_get_date_time_rfc1123_request + from ._request_builders_py3 import build_put_date_time_rfc1123_request + from ._request_builders_py3 import build_get_duration_request + from ._request_builders_py3 import build_put_duration_request + from ._request_builders_py3 import build_get_byte_request + from ._request_builders_py3 import build_put_byte_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_int_request # type: ignore + from ._request_builders import build_put_int_request # type: ignore + from ._request_builders import build_get_long_request # type: ignore + from ._request_builders import build_put_long_request # type: ignore + from ._request_builders import build_get_float_request # type: ignore + from ._request_builders import build_put_float_request # type: ignore + from ._request_builders import build_get_double_request # type: ignore + from ._request_builders import build_put_double_request # type: ignore + from ._request_builders import build_get_bool_request # type: ignore + from ._request_builders import build_put_bool_request # type: ignore + from ._request_builders import build_get_string_request # type: ignore + from ._request_builders import build_put_string_request # type: ignore + from ._request_builders import build_get_date_request # type: ignore + from ._request_builders import build_put_date_request # type: ignore + from ._request_builders import build_get_date_time_request # type: ignore + from ._request_builders import build_put_date_time_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_request # type: ignore + from ._request_builders import build_get_duration_request # type: ignore + from ._request_builders import build_put_duration_request # type: ignore + from ._request_builders import build_get_byte_request # type: ignore + from ._request_builders import build_put_byte_request # type: ignore + +__all__ = [ + "build_get_int_request", + "build_put_int_request", + "build_get_long_request", + "build_put_long_request", + "build_get_float_request", + "build_put_float_request", + "build_get_double_request", + "build_put_double_request", + "build_get_bool_request", + "build_put_bool_request", + "build_get_string_request", + "build_put_string_request", + "build_get_date_request", + "build_put_date_request", + "build_get_date_time_request", + "build_put_date_time_request", + "build_get_date_time_rfc1123_request", + "build_put_date_time_rfc1123_request", + "build_get_duration_request", + "build_put_duration_request", + "build_get_byte_request", + "build_put_byte_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/_request_builders.py new file mode 100644 index 00000000000..bc70d2e0d8a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/_request_builders.py @@ -0,0 +1,819 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_int_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/integer') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_int_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put -1 and 2. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put -1 and 2. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/integer') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1099511627775 and -999511627788. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1099511627775 and -999511627788. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/long') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1.05 and -0.003. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1.05 and -0.003. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/float') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/double') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/double') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put true and false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put true and false. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/bool') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'goodrequest', '', and null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'goodrequest', '', and null. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/string') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01' and '2016-02-29'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01' and '2016-02-29'. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/date') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetime') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetimerfc1123') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 + May 2015 11:38:00 GMT'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May + 2015 11:38:00 GMT'. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetimerfc1123') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/duration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'P123DT22H14M12.011S'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'P123DT22H14M12.011S'. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/duration') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/byte') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 + F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 F8 + F7 F6). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/byte') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/_request_builders_py3.py new file mode 100644 index 00000000000..427a08a8a01 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/primitive/_request_builders_py3.py @@ -0,0 +1,638 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_int_request(**kwargs: Any) -> HttpRequest: + """Get complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/integer") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_int_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put -1 and 2. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put -1 and 2. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/integer") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_request(**kwargs: Any) -> HttpRequest: + """Get complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1099511627775 and -999511627788. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1099511627775 and -999511627788. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/long") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_request(**kwargs: Any) -> HttpRequest: + """Get complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1.05 and -0.003. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1.05 and -0.003. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/float") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_request(**kwargs: Any) -> HttpRequest: + """Get complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/double") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/double") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_bool_request(**kwargs: Any) -> HttpRequest: + """Get complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_bool_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put true and false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put true and false. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/bool") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_request(**kwargs: Any) -> HttpRequest: + """Get complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'goodrequest', '', and null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'goodrequest', '', and null. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/string") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_request(**kwargs: Any) -> HttpRequest: + """Get complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01' and '2016-02-29'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01' and '2016-02-29'. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/date") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_request(**kwargs: Any) -> HttpRequest: + """Get complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetime") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_rfc1123_request(**kwargs: Any) -> HttpRequest: + """Get complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetimerfc1123") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 + May 2015 11:38:00 GMT'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May + 2015 11:38:00 GMT'. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetimerfc1123") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_request(**kwargs: Any) -> HttpRequest: + """Get complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/duration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'P123DT22H14M12.011S'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'P123DT22H14M12.011S'. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/duration") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_request(**kwargs: Any) -> HttpRequest: + """Get complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/byte") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 + F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 F8 + F7 F6). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/byte") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/__init__.py new file mode 100644 index 00000000000..83d94e4e60b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/__init__.py @@ -0,0 +1,19 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/_request_builders.py new file mode 100644 index 00000000000..f1382d302e8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/_request_builders.py @@ -0,0 +1,91 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/readonlyproperty/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/readonlyproperty/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/_request_builders_py3.py new file mode 100644 index 00000000000..2707848310d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_rest/readonlyproperty/_request_builders_py3.py @@ -0,0 +1,70 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/readonlyproperty/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/readonlyproperty/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_auto_rest_complex_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_auto_rest_complex_test_service.py new file mode 100644 index 00000000000..20b0c3a1359 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_auto_rest_complex_test_service.py @@ -0,0 +1,115 @@ +# 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 AutoRestComplexTestServiceConfiguration +from .operations import ( + ArrayOperations, + BasicOperations, + DictionaryOperations, + FlattencomplexOperations, + InheritanceOperations, + PolymorphicrecursiveOperations, + PolymorphismOperations, + PrimitiveOperations, + ReadonlypropertyOperations, +) + + +class AutoRestComplexTestService: + """Test Infrastructure for AutoRest. + + :ivar basic: BasicOperations operations + :vartype basic: bodycomplex.aio.operations.BasicOperations + :ivar primitive: PrimitiveOperations operations + :vartype primitive: bodycomplex.aio.operations.PrimitiveOperations + :ivar array: ArrayOperations operations + :vartype array: bodycomplex.aio.operations.ArrayOperations + :ivar dictionary: DictionaryOperations operations + :vartype dictionary: bodycomplex.aio.operations.DictionaryOperations + :ivar inheritance: InheritanceOperations operations + :vartype inheritance: bodycomplex.aio.operations.InheritanceOperations + :ivar polymorphism: PolymorphismOperations operations + :vartype polymorphism: bodycomplex.aio.operations.PolymorphismOperations + :ivar polymorphicrecursive: PolymorphicrecursiveOperations operations + :vartype polymorphicrecursive: bodycomplex.aio.operations.PolymorphicrecursiveOperations + :ivar readonlyproperty: ReadonlypropertyOperations operations + :vartype readonlyproperty: bodycomplex.aio.operations.ReadonlypropertyOperations + :ivar flattencomplex: FlattencomplexOperations operations + :vartype flattencomplex: bodycomplex.aio.operations.FlattencomplexOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestComplexTestServiceConfiguration(**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.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) + self.primitive = PrimitiveOperations(self._client, self._config, self._serialize, self._deserialize) + self.array = ArrayOperations(self._client, self._config, self._serialize, self._deserialize) + self.dictionary = DictionaryOperations(self._client, self._config, self._serialize, self._deserialize) + self.inheritance = InheritanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.polymorphism = PolymorphismOperations(self._client, self._config, self._serialize, self._deserialize) + self.polymorphicrecursive = PolymorphicrecursiveOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.readonlyproperty = ReadonlypropertyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flattencomplex = FlattencomplexOperations(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. + + We have helper methods to create requests specific to this service in `bodycomplex.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodycomplex._rest import basic + >>> request = basic.build_get_valid_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestComplexTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py new file mode 100644 index 00000000000..f70f302c280 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_array_operations.py @@ -0,0 +1,244 @@ +# 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, List, 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 ... import models as _models +from ..._rest import array as rest_array + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ArrayOperations: + """ArrayOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.ArrayWrapper": + """Get complex types with array property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArrayWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ArrayWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ArrayWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/array/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, array: Optional[List[str]] = None, **kwargs: Any) -> None: + """Put complex types with array property. + + :param array: + :type array: list[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/json") # type: Optional[str] + + _complex_body = _models.ArrayWrapper(array=array) + json = self._serialize.body(_complex_body, "ArrayWrapper") + + request = rest_array.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/array/valid"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> "_models.ArrayWrapper": + """Get complex types with array property which is empty. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArrayWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ArrayWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ArrayWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/complex/array/empty"} # type: ignore + + @distributed_trace_async + async def put_empty(self, array: Optional[List[str]] = None, **kwargs: Any) -> None: + """Put complex types with array property which is empty. + + :param array: + :type array: list[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/json") # type: Optional[str] + + _complex_body = _models.ArrayWrapper(array=array) + json = self._serialize.body(_complex_body, "ArrayWrapper") + + request = rest_array.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/complex/array/empty"} # type: ignore + + @distributed_trace_async + async def get_not_provided(self, **kwargs: Any) -> "_models.ArrayWrapper": + """Get complex types with array property while server doesn't provide a response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArrayWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ArrayWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ArrayWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/complex/array/notprovided"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py new file mode 100644 index 00000000000..d21e7628edf --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_basic_operations.py @@ -0,0 +1,276 @@ +# 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 ... import models as _models +from ..._rest import basic as rest_basic + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BasicOperations: + """BasicOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Basic": + """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, complex_body: "_models.Basic", **kwargs: Any) -> None: + """Please put {id: 2, name: 'abc', color: 'Magenta'}. + + :param complex_body: Please put {id: 2, name: 'abc', color: 'Magenta'}. + :type complex_body: ~bodycomplex.models.Basic + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Basic") + + request = rest_basic.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> "_models.Basic": + """Get a basic complex type that is invalid for the local strong type. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/complex/basic/invalid"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> "_models.Basic": + """Get a basic complex type that is empty. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/complex/basic/empty"} # type: ignore + + @distributed_trace_async + async def get_null(self, **kwargs: Any) -> "_models.Basic": + """Get a basic complex type whose properties are null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/complex/basic/null"} # type: ignore + + @distributed_trace_async + async def get_not_provided(self, **kwargs: Any) -> "_models.Basic": + """Get a basic complex type while the server doesn't provide a response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/complex/basic/notprovided"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py new file mode 100644 index 00000000000..538690f1cb7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_dictionary_operations.py @@ -0,0 +1,281 @@ +# 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 ... import models as _models +from ..._rest import dictionary as rest_dictionary + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DictionaryOperations: + """DictionaryOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.DictionaryWrapper": + """Get complex types with dictionary property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, default_program: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """Put complex types with dictionary property. + + :param default_program: Dictionary of :code:``. + :type default_program: dict[str, 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/json") # type: Optional[str] + + _complex_body = _models.DictionaryWrapper(default_program=default_program) + json = self._serialize.body(_complex_body, "DictionaryWrapper") + + request = rest_dictionary.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> "_models.DictionaryWrapper": + """Get complex types with dictionary property which is empty. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore + + @distributed_trace_async + async def put_empty(self, default_program: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """Put complex types with dictionary property which is empty. + + :param default_program: Dictionary of :code:``. + :type default_program: dict[str, 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/json") # type: Optional[str] + + _complex_body = _models.DictionaryWrapper(default_program=default_program) + json = self._serialize.body(_complex_body, "DictionaryWrapper") + + request = rest_dictionary.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore + + @distributed_trace_async + async def get_null(self, **kwargs: Any) -> "_models.DictionaryWrapper": + """Get complex types with dictionary property which is null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/complex/dictionary/typed/null"} # type: ignore + + @distributed_trace_async + async def get_not_provided(self, **kwargs: Any) -> "_models.DictionaryWrapper": + """Get complex types with dictionary property while server doesn't provide a response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/complex/dictionary/typed/notprovided"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py new file mode 100644 index 00000000000..1453a180b8f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_flattencomplex_operations.py @@ -0,0 +1,87 @@ +# 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 ... import models as _models +from ..._rest import flattencomplex as rest_flattencomplex + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FlattencomplexOperations: + """FlattencomplexOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.MyBaseType": + """get_valid. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyBaseType, or the result of cls(response) + :rtype: ~bodycomplex.models.MyBaseType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyBaseType"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_flattencomplex.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyBaseType", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/flatten/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py new file mode 100644 index 00000000000..f4a2523cf79 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_inheritance_operations.py @@ -0,0 +1,130 @@ +# 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 ... import models as _models +from ..._rest import inheritance as rest_inheritance + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class InheritanceOperations: + """InheritanceOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Siamese": + """Get complex types that extend others. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Siamese, or the result of cls(response) + :rtype: ~bodycomplex.models.Siamese + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Siamese"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_inheritance.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Siamese", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, complex_body: "_models.Siamese", **kwargs: Any) -> None: + """Put complex types that extend others. + + :param complex_body: Please put a siamese with id=2, name="Siameee", color=green, + breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and + the 2nd one named "Tomato" with id=-1 and food="french fries". + :type complex_body: ~bodycomplex.models.Siamese + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Siamese") + + request = rest_inheritance.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py new file mode 100644 index 00000000000..a59f5febc71 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphicrecursive_operations.py @@ -0,0 +1,180 @@ +# 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 ... import models as _models +from ..._rest import polymorphicrecursive as rest_polymorphicrecursive + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PolymorphicrecursiveOperations: + """PolymorphicrecursiveOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Fish": + """Get complex types that are polymorphic and have recursive references. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Fish, or the result of cls(response) + :rtype: ~bodycomplex.models.Fish + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphicrecursive.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Fish", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, complex_body: "_models.Fish", **kwargs: Any) -> None: + """Put complex types that are polymorphic and have recursive references. + + :param complex_body: Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :type complex_body: ~bodycomplex.models.Fish + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Fish") + + request = rest_polymorphicrecursive.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py new file mode 100644 index 00000000000..2d9948a4dc6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_polymorphism_operations.py @@ -0,0 +1,465 @@ +# 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 ... import models as _models +from ..._rest import polymorphism as rest_polymorphism + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PolymorphismOperations: + """PolymorphismOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.Fish": + """Get complex types that are polymorphic. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Fish, or the result of cls(response) + :rtype: ~bodycomplex.models.Fish + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Fish", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, complex_body: "_models.Fish", **kwargs: Any) -> None: + """Put complex types that are polymorphic. + + :param complex_body: Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :type complex_body: ~bodycomplex.models.Fish + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Fish") + + request = rest_polymorphism.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore + + @distributed_trace_async + async def get_dot_syntax(self, **kwargs: Any) -> "_models.DotFish": + """Get complex types that are polymorphic, JSON key contains a dot. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DotFish, or the result of cls(response) + :rtype: ~bodycomplex.models.DotFish + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFish"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_dot_syntax_request( + template_url=self.get_dot_syntax.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DotFish", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dot_syntax.metadata = {"url": "/complex/polymorphism/dotsyntax"} # type: ignore + + @distributed_trace_async + async def get_composed_with_discriminator(self, **kwargs: Any) -> "_models.DotFishMarket": + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, with discriminator specified. Deserialization must NOT fail and use the + discriminator type specified on the wire. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DotFishMarket, or the result of cls(response) + :rtype: ~bodycomplex.models.DotFishMarket + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_composed_with_discriminator_request( + template_url=self.get_composed_with_discriminator.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DotFishMarket", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_composed_with_discriminator.metadata = {"url": "/complex/polymorphism/composedWithDiscriminator"} # type: ignore + + @distributed_trace_async + async def get_composed_without_discriminator(self, **kwargs: Any) -> "_models.DotFishMarket": + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, without discriminator specified on wire. Deserialization must NOT fail and use + the explicit type of the property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DotFishMarket, or the result of cls(response) + :rtype: ~bodycomplex.models.DotFishMarket + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_composed_without_discriminator_request( + template_url=self.get_composed_without_discriminator.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DotFishMarket", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_composed_without_discriminator.metadata = {"url": "/complex/polymorphism/composedWithoutDiscriminator"} # type: ignore + + @distributed_trace_async + async def get_complicated(self, **kwargs: Any) -> "_models.Salmon": + """Get complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Salmon, or the result of cls(response) + :rtype: ~bodycomplex.models.Salmon + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_complicated_request( + template_url=self.get_complicated.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Salmon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore + + @distributed_trace_async + async def put_complicated(self, complex_body: "_models.Salmon", **kwargs: Any) -> None: + """Put complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + :param complex_body: + :type complex_body: ~bodycomplex.models.Salmon + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Salmon") + + request = rest_polymorphism.build_put_complicated_request( + content_type=content_type, + json=json, + template_url=self.put_complicated.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore + + @distributed_trace_async + async def put_missing_discriminator(self, complex_body: "_models.Salmon", **kwargs: Any) -> "_models.Salmon": + """Put complex types that are polymorphic, omitting the discriminator. + + :param complex_body: + :type complex_body: ~bodycomplex.models.Salmon + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Salmon, or the result of cls(response) + :rtype: ~bodycomplex.models.Salmon + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Salmon") + + request = rest_polymorphism.build_put_missing_discriminator_request( + content_type=content_type, + json=json, + template_url=self.put_missing_discriminator.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Salmon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_missing_discriminator.metadata = {"url": "/complex/polymorphism/missingdiscriminator"} # type: ignore + + @distributed_trace_async + async def put_valid_missing_required(self, complex_body: "_models.Fish", **kwargs: Any) -> None: + """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the + request should not be allowed from the client. + + :param complex_body: Please attempt put a sawshark that looks like this, the client should not + allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :type complex_body: ~bodycomplex.models.Fish + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Fish") + + request = rest_polymorphism.build_put_valid_missing_required_request( + content_type=content_type, + json=json, + template_url=self.put_valid_missing_required.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid_missing_required.metadata = {"url": "/complex/polymorphism/missingrequired/invalid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py new file mode 100644 index 00000000000..2d678113481 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_primitive_operations.py @@ -0,0 +1,903 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import primitive as rest_primitive + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrimitiveOperations: + """PrimitiveOperations 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: ~bodycomplex.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 get_int(self, **kwargs: Any) -> "_models.IntWrapper": + """Get complex types with integer properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.IntWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.IntWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_int_request( + template_url=self.get_int.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("IntWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore + + @distributed_trace_async + async def put_int(self, complex_body: "_models.IntWrapper", **kwargs: Any) -> None: + """Put complex types with integer properties. + + :param complex_body: Please put -1 and 2. + :type complex_body: ~bodycomplex.models.IntWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "IntWrapper") + + request = rest_primitive.build_put_int_request( + content_type=content_type, + json=json, + template_url=self.put_int.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore + + @distributed_trace_async + async def get_long(self, **kwargs: Any) -> "_models.LongWrapper": + """Get complex types with long properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LongWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.LongWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.LongWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_long_request( + template_url=self.get_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("LongWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long.metadata = {"url": "/complex/primitive/long"} # type: ignore + + @distributed_trace_async + async def put_long(self, complex_body: "_models.LongWrapper", **kwargs: Any) -> None: + """Put complex types with long properties. + + :param complex_body: Please put 1099511627775 and -999511627788. + :type complex_body: ~bodycomplex.models.LongWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "LongWrapper") + + request = rest_primitive.build_put_long_request( + content_type=content_type, + json=json, + template_url=self.put_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long.metadata = {"url": "/complex/primitive/long"} # type: ignore + + @distributed_trace_async + async def get_float(self, **kwargs: Any) -> "_models.FloatWrapper": + """Get complex types with float properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FloatWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.FloatWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.FloatWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_float_request( + template_url=self.get_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("FloatWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float.metadata = {"url": "/complex/primitive/float"} # type: ignore + + @distributed_trace_async + async def put_float(self, complex_body: "_models.FloatWrapper", **kwargs: Any) -> None: + """Put complex types with float properties. + + :param complex_body: Please put 1.05 and -0.003. + :type complex_body: ~bodycomplex.models.FloatWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "FloatWrapper") + + request = rest_primitive.build_put_float_request( + content_type=content_type, + json=json, + template_url=self.put_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float.metadata = {"url": "/complex/primitive/float"} # type: ignore + + @distributed_trace_async + async def get_double(self, **kwargs: Any) -> "_models.DoubleWrapper": + """Get complex types with double properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DoubleWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DoubleWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DoubleWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_double_request( + template_url=self.get_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DoubleWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double.metadata = {"url": "/complex/primitive/double"} # type: ignore + + @distributed_trace_async + async def put_double(self, complex_body: "_models.DoubleWrapper", **kwargs: Any) -> None: + """Put complex types with double properties. + + :param complex_body: Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :type complex_body: ~bodycomplex.models.DoubleWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "DoubleWrapper") + + request = rest_primitive.build_put_double_request( + content_type=content_type, + json=json, + template_url=self.put_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double.metadata = {"url": "/complex/primitive/double"} # type: ignore + + @distributed_trace_async + async def get_bool(self, **kwargs: Any) -> "_models.BooleanWrapper": + """Get complex types with bool properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BooleanWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.BooleanWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.BooleanWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_bool_request( + template_url=self.get_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("BooleanWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore + + @distributed_trace_async + async def put_bool(self, complex_body: "_models.BooleanWrapper", **kwargs: Any) -> None: + """Put complex types with bool properties. + + :param complex_body: Please put true and false. + :type complex_body: ~bodycomplex.models.BooleanWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "BooleanWrapper") + + request = rest_primitive.build_put_bool_request( + content_type=content_type, + json=json, + template_url=self.put_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore + + @distributed_trace_async + async def get_string(self, **kwargs: Any) -> "_models.StringWrapper": + """Get complex types with string properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StringWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.StringWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StringWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_string_request( + template_url=self.get_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("StringWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string.metadata = {"url": "/complex/primitive/string"} # type: ignore + + @distributed_trace_async + async def put_string(self, complex_body: "_models.StringWrapper", **kwargs: Any) -> None: + """Put complex types with string properties. + + :param complex_body: Please put 'goodrequest', '', and null. + :type complex_body: ~bodycomplex.models.StringWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "StringWrapper") + + request = rest_primitive.build_put_string_request( + content_type=content_type, + json=json, + template_url=self.put_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string.metadata = {"url": "/complex/primitive/string"} # type: ignore + + @distributed_trace_async + async def get_date(self, **kwargs: Any) -> "_models.DateWrapper": + """Get complex types with date properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DateWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DateWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DateWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_date_request( + template_url=self.get_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DateWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date.metadata = {"url": "/complex/primitive/date"} # type: ignore + + @distributed_trace_async + async def put_date(self, complex_body: "_models.DateWrapper", **kwargs: Any) -> None: + """Put complex types with date properties. + + :param complex_body: Please put '0001-01-01' and '2016-02-29'. + :type complex_body: ~bodycomplex.models.DateWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "DateWrapper") + + request = rest_primitive.build_put_date_request( + content_type=content_type, + json=json, + template_url=self.put_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date.metadata = {"url": "/complex/primitive/date"} # type: ignore + + @distributed_trace_async + async def get_date_time(self, **kwargs: Any) -> "_models.DatetimeWrapper": + """Get complex types with datetime properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatetimeWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DatetimeWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DatetimeWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_date_time_request( + template_url=self.get_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DatetimeWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore + + @distributed_trace_async + async def put_date_time(self, complex_body: "_models.DatetimeWrapper", **kwargs: Any) -> None: + """Put complex types with datetime properties. + + :param complex_body: Please put '0001-01-01T12:00:00-04:00' and '2015-05-18T11:38:00-08:00'. + :type complex_body: ~bodycomplex.models.DatetimeWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "DatetimeWrapper") + + request = rest_primitive.build_put_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore + + @distributed_trace_async + async def get_date_time_rfc1123(self, **kwargs: Any) -> "_models.Datetimerfc1123Wrapper": + """Get complex types with datetimeRfc1123 properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datetimerfc1123Wrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.Datetimerfc1123Wrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Datetimerfc1123Wrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_date_time_rfc1123_request( + template_url=self.get_date_time_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Datetimerfc1123Wrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore + + @distributed_trace_async + async def put_date_time_rfc1123(self, complex_body: "_models.Datetimerfc1123Wrapper", **kwargs: Any) -> None: + """Put complex types with datetimeRfc1123 properties. + + :param complex_body: Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May 2015 11:38:00 + GMT'. + :type complex_body: ~bodycomplex.models.Datetimerfc1123Wrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Datetimerfc1123Wrapper") + + request = rest_primitive.build_put_date_time_rfc1123_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore + + @distributed_trace_async + async def get_duration(self, **kwargs: Any) -> "_models.DurationWrapper": + """Get complex types with duration properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DurationWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DurationWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DurationWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_duration_request( + template_url=self.get_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DurationWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore + + @distributed_trace_async + async def put_duration(self, field: Optional[datetime.timedelta] = None, **kwargs: Any) -> None: + """Put complex types with duration properties. + + :param field: + :type field: ~datetime.timedelta + :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/json") # type: Optional[str] + + _complex_body = _models.DurationWrapper(field=field) + json = self._serialize.body(_complex_body, "DurationWrapper") + + request = rest_primitive.build_put_duration_request( + content_type=content_type, + json=json, + template_url=self.put_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore + + @distributed_trace_async + async def get_byte(self, **kwargs: Any) -> "_models.ByteWrapper": + """Get complex types with byte properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ByteWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ByteWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ByteWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_byte_request( + template_url=self.get_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ByteWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore + + @distributed_trace_async + async def put_byte(self, field: Optional[bytearray] = None, **kwargs: Any) -> None: + """Put complex types with byte properties. + + :param field: + :type field: bytearray + :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/json") # type: Optional[str] + + _complex_body = _models.ByteWrapper(field=field) + json = self._serialize.body(_complex_body, "ByteWrapper") + + request = rest_primitive.build_put_byte_request( + content_type=content_type, + json=json, + template_url=self.put_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py new file mode 100644 index 00000000000..4edb6de9577 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/aio/operations/_readonlyproperty_operations.py @@ -0,0 +1,129 @@ +# 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 ... import models as _models +from ..._rest import readonlyproperty as rest_readonlyproperty + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ReadonlypropertyOperations: + """ReadonlypropertyOperations 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: ~bodycomplex.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 get_valid(self, **kwargs: Any) -> "_models.ReadonlyObj": + """Get complex types that have readonly properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ReadonlyObj, or the result of cls(response) + :rtype: ~bodycomplex.models.ReadonlyObj + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ReadonlyObj"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_readonlyproperty.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ReadonlyObj", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore + + @distributed_trace_async + async def put_valid(self, size: Optional[int] = None, **kwargs: Any) -> None: + """Put complex types that have readonly properties. + + :param size: + :type size: int + :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/json") # type: Optional[str] + + _complex_body = _models.ReadonlyObj(size=size) + json = self._serialize.body(_complex_body, "ReadonlyObj") + + request = rest_readonlyproperty.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_auto_rest_complex_test_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_auto_rest_complex_test_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_auto_rest_complex_test_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_auto_rest_complex_test_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py new file mode 100644 index 00000000000..bf32725bfee --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_array_operations.py @@ -0,0 +1,257 @@ +# 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 .. import models as _models +from .._rest import array as rest_array + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class ArrayOperations(object): + """ArrayOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ArrayWrapper" + """Get complex types with array property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArrayWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ArrayWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ArrayWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/array/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + array=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with array property. + + :param array: + :type array: list[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/json") # type: Optional[str] + + _complex_body = _models.ArrayWrapper(array=array) + json = self._serialize.body(_complex_body, "ArrayWrapper") + + request = rest_array.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/array/valid"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ArrayWrapper" + """Get complex types with array property which is empty. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArrayWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ArrayWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ArrayWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/complex/array/empty"} # type: ignore + + @distributed_trace + def put_empty( + self, + array=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with array property which is empty. + + :param array: + :type array: list[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/json") # type: Optional[str] + + _complex_body = _models.ArrayWrapper(array=array) + json = self._serialize.body(_complex_body, "ArrayWrapper") + + request = rest_array.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/complex/array/empty"} # type: ignore + + @distributed_trace + def get_not_provided( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ArrayWrapper" + """Get complex types with array property while server doesn't provide a response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArrayWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ArrayWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ArrayWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_array.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ArrayWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/complex/array/notprovided"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py new file mode 100644 index 00000000000..c129328c814 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_basic_operations.py @@ -0,0 +1,288 @@ +# 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 .. import models as _models +from .._rest import basic as rest_basic + +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]] + + +class BasicOperations(object): + """BasicOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Basic" + """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + complex_body, # type: "_models.Basic" + **kwargs # type: Any + ): + # type: (...) -> None + """Please put {id: 2, name: 'abc', color: 'Magenta'}. + + :param complex_body: Please put {id: 2, name: 'abc', color: 'Magenta'}. + :type complex_body: ~bodycomplex.models.Basic + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Basic") + + request = rest_basic.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/basic/valid"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Basic" + """Get a basic complex type that is invalid for the local strong type. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/complex/basic/invalid"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Basic" + """Get a basic complex type that is empty. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/complex/basic/empty"} # type: ignore + + @distributed_trace + def get_null( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Basic" + """Get a basic complex type whose properties are null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/complex/basic/null"} # type: ignore + + @distributed_trace + def get_not_provided( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Basic" + """Get a basic complex type while the server doesn't provide a response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Basic, or the result of cls(response) + :rtype: ~bodycomplex.models.Basic + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Basic"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_basic.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Basic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/complex/basic/notprovided"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py new file mode 100644 index 00000000000..a1988a58b54 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_dictionary_operations.py @@ -0,0 +1,295 @@ +# 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 .. import models as _models +from .._rest import dictionary as rest_dictionary + +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]] + + +class DictionaryOperations(object): + """DictionaryOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DictionaryWrapper" + """Get complex types with dictionary property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + default_program=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with dictionary property. + + :param default_program: Dictionary of :code:``. + :type default_program: dict[str, 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/json") # type: Optional[str] + + _complex_body = _models.DictionaryWrapper(default_program=default_program) + json = self._serialize.body(_complex_body, "DictionaryWrapper") + + request = rest_dictionary.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/dictionary/typed/valid"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DictionaryWrapper" + """Get complex types with dictionary property which is empty. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore + + @distributed_trace + def put_empty( + self, + default_program=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with dictionary property which is empty. + + :param default_program: Dictionary of :code:``. + :type default_program: dict[str, 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/json") # type: Optional[str] + + _complex_body = _models.DictionaryWrapper(default_program=default_program) + json = self._serialize.body(_complex_body, "DictionaryWrapper") + + request = rest_dictionary.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/complex/dictionary/typed/empty"} # type: ignore + + @distributed_trace + def get_null( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DictionaryWrapper" + """Get complex types with dictionary property which is null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/complex/dictionary/typed/null"} # type: ignore + + @distributed_trace + def get_not_provided( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DictionaryWrapper" + """Get complex types with dictionary property while server doesn't provide a response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DictionaryWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DictionaryWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DictionaryWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DictionaryWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/complex/dictionary/typed/notprovided"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py new file mode 100644 index 00000000000..5bffe32c96e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_flattencomplex_operations.py @@ -0,0 +1,92 @@ +# 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 .. import models as _models +from .._rest import flattencomplex as rest_flattencomplex + +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]] + + +class FlattencomplexOperations(object): + """FlattencomplexOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyBaseType" + """get_valid. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyBaseType, or the result of cls(response) + :rtype: ~bodycomplex.models.MyBaseType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyBaseType"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_flattencomplex.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyBaseType", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/flatten/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py new file mode 100644 index 00000000000..1be7eaffa6e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_inheritance_operations.py @@ -0,0 +1,138 @@ +# 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 .. import models as _models +from .._rest import inheritance as rest_inheritance + +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]] + + +class InheritanceOperations(object): + """InheritanceOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Siamese" + """Get complex types that extend others. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Siamese, or the result of cls(response) + :rtype: ~bodycomplex.models.Siamese + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Siamese"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_inheritance.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Siamese", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + complex_body, # type: "_models.Siamese" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types that extend others. + + :param complex_body: Please put a siamese with id=2, name="Siameee", color=green, + breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and + the 2nd one named "Tomato" with id=-1 and food="french fries". + :type complex_body: ~bodycomplex.models.Siamese + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Siamese") + + request = rest_inheritance.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/inheritance/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py new file mode 100644 index 00000000000..4e7eddf67a0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphicrecursive_operations.py @@ -0,0 +1,188 @@ +# 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 .. import models as _models +from .._rest import polymorphicrecursive as rest_polymorphicrecursive + +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]] + + +class PolymorphicrecursiveOperations(object): + """PolymorphicrecursiveOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Fish" + """Get complex types that are polymorphic and have recursive references. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Fish, or the result of cls(response) + :rtype: ~bodycomplex.models.Fish + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphicrecursive.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Fish", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + complex_body, # type: "_models.Fish" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types that are polymorphic and have recursive references. + + :param complex_body: Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :type complex_body: ~bodycomplex.models.Fish + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Fish") + + request = rest_polymorphicrecursive.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/polymorphicrecursive/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py new file mode 100644 index 00000000000..4c616c59931 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_polymorphism_operations.py @@ -0,0 +1,486 @@ +# 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 .. import models as _models +from .._rest import polymorphism as rest_polymorphism + +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]] + + +class PolymorphismOperations(object): + """PolymorphismOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Fish" + """Get complex types that are polymorphic. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Fish, or the result of cls(response) + :rtype: ~bodycomplex.models.Fish + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Fish"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Fish", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + complex_body, # type: "_models.Fish" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types that are polymorphic. + + :param complex_body: Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :type complex_body: ~bodycomplex.models.Fish + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Fish") + + request = rest_polymorphism.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/polymorphism/valid"} # type: ignore + + @distributed_trace + def get_dot_syntax( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DotFish" + """Get complex types that are polymorphic, JSON key contains a dot. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DotFish, or the result of cls(response) + :rtype: ~bodycomplex.models.DotFish + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFish"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_dot_syntax_request( + template_url=self.get_dot_syntax.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DotFish", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dot_syntax.metadata = {"url": "/complex/polymorphism/dotsyntax"} # type: ignore + + @distributed_trace + def get_composed_with_discriminator( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DotFishMarket" + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, with discriminator specified. Deserialization must NOT fail and use the + discriminator type specified on the wire. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DotFishMarket, or the result of cls(response) + :rtype: ~bodycomplex.models.DotFishMarket + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_composed_with_discriminator_request( + template_url=self.get_composed_with_discriminator.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DotFishMarket", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_composed_with_discriminator.metadata = {"url": "/complex/polymorphism/composedWithDiscriminator"} # type: ignore + + @distributed_trace + def get_composed_without_discriminator( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DotFishMarket" + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, without discriminator specified on wire. Deserialization must NOT fail and use + the explicit type of the property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DotFishMarket, or the result of cls(response) + :rtype: ~bodycomplex.models.DotFishMarket + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DotFishMarket"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_composed_without_discriminator_request( + template_url=self.get_composed_without_discriminator.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DotFishMarket", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_composed_without_discriminator.metadata = {"url": "/complex/polymorphism/composedWithoutDiscriminator"} # type: ignore + + @distributed_trace + def get_complicated( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Salmon" + """Get complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Salmon, or the result of cls(response) + :rtype: ~bodycomplex.models.Salmon + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_polymorphism.build_get_complicated_request( + template_url=self.get_complicated.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Salmon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore + + @distributed_trace + def put_complicated( + self, + complex_body, # type: "_models.Salmon" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + :param complex_body: + :type complex_body: ~bodycomplex.models.Salmon + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Salmon") + + request = rest_polymorphism.build_put_complicated_request( + content_type=content_type, + json=json, + template_url=self.put_complicated.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complicated.metadata = {"url": "/complex/polymorphism/complicated"} # type: ignore + + @distributed_trace + def put_missing_discriminator( + self, + complex_body, # type: "_models.Salmon" + **kwargs # type: Any + ): + # type: (...) -> "_models.Salmon" + """Put complex types that are polymorphic, omitting the discriminator. + + :param complex_body: + :type complex_body: ~bodycomplex.models.Salmon + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Salmon, or the result of cls(response) + :rtype: ~bodycomplex.models.Salmon + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Salmon"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Salmon") + + request = rest_polymorphism.build_put_missing_discriminator_request( + content_type=content_type, + json=json, + template_url=self.put_missing_discriminator.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Salmon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_missing_discriminator.metadata = {"url": "/complex/polymorphism/missingdiscriminator"} # type: ignore + + @distributed_trace + def put_valid_missing_required( + self, + complex_body, # type: "_models.Fish" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the + request should not be allowed from the client. + + :param complex_body: Please attempt put a sawshark that looks like this, the client should not + allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :type complex_body: ~bodycomplex.models.Fish + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Fish") + + request = rest_polymorphism.build_put_valid_missing_required_request( + content_type=content_type, + json=json, + template_url=self.put_valid_missing_required.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid_missing_required.metadata = {"url": "/complex/polymorphism/missingrequired/invalid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py new file mode 100644 index 00000000000..6ed8962c90d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_primitive_operations.py @@ -0,0 +1,951 @@ +# 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 datetime +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 .. import models as _models +from .._rest import primitive as rest_primitive + +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]] + + +class PrimitiveOperations(object): + """PrimitiveOperations 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: ~bodycomplex.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 get_int( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.IntWrapper" + """Get complex types with integer properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.IntWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.IntWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_int_request( + template_url=self.get_int.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("IntWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore + + @distributed_trace + def put_int( + self, + complex_body, # type: "_models.IntWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with integer properties. + + :param complex_body: Please put -1 and 2. + :type complex_body: ~bodycomplex.models.IntWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "IntWrapper") + + request = rest_primitive.build_put_int_request( + content_type=content_type, + json=json, + template_url=self.put_int.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_int.metadata = {"url": "/complex/primitive/integer"} # type: ignore + + @distributed_trace + def get_long( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.LongWrapper" + """Get complex types with long properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LongWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.LongWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.LongWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_long_request( + template_url=self.get_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("LongWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long.metadata = {"url": "/complex/primitive/long"} # type: ignore + + @distributed_trace + def put_long( + self, + complex_body, # type: "_models.LongWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with long properties. + + :param complex_body: Please put 1099511627775 and -999511627788. + :type complex_body: ~bodycomplex.models.LongWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "LongWrapper") + + request = rest_primitive.build_put_long_request( + content_type=content_type, + json=json, + template_url=self.put_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long.metadata = {"url": "/complex/primitive/long"} # type: ignore + + @distributed_trace + def get_float( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.FloatWrapper" + """Get complex types with float properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FloatWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.FloatWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.FloatWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_float_request( + template_url=self.get_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("FloatWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float.metadata = {"url": "/complex/primitive/float"} # type: ignore + + @distributed_trace + def put_float( + self, + complex_body, # type: "_models.FloatWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with float properties. + + :param complex_body: Please put 1.05 and -0.003. + :type complex_body: ~bodycomplex.models.FloatWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "FloatWrapper") + + request = rest_primitive.build_put_float_request( + content_type=content_type, + json=json, + template_url=self.put_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float.metadata = {"url": "/complex/primitive/float"} # type: ignore + + @distributed_trace + def get_double( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DoubleWrapper" + """Get complex types with double properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DoubleWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DoubleWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DoubleWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_double_request( + template_url=self.get_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DoubleWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double.metadata = {"url": "/complex/primitive/double"} # type: ignore + + @distributed_trace + def put_double( + self, + complex_body, # type: "_models.DoubleWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with double properties. + + :param complex_body: Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :type complex_body: ~bodycomplex.models.DoubleWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "DoubleWrapper") + + request = rest_primitive.build_put_double_request( + content_type=content_type, + json=json, + template_url=self.put_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double.metadata = {"url": "/complex/primitive/double"} # type: ignore + + @distributed_trace + def get_bool( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.BooleanWrapper" + """Get complex types with bool properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BooleanWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.BooleanWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.BooleanWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_bool_request( + template_url=self.get_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("BooleanWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore + + @distributed_trace + def put_bool( + self, + complex_body, # type: "_models.BooleanWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with bool properties. + + :param complex_body: Please put true and false. + :type complex_body: ~bodycomplex.models.BooleanWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "BooleanWrapper") + + request = rest_primitive.build_put_bool_request( + content_type=content_type, + json=json, + template_url=self.put_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_bool.metadata = {"url": "/complex/primitive/bool"} # type: ignore + + @distributed_trace + def get_string( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.StringWrapper" + """Get complex types with string properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StringWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.StringWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StringWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_string_request( + template_url=self.get_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("StringWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string.metadata = {"url": "/complex/primitive/string"} # type: ignore + + @distributed_trace + def put_string( + self, + complex_body, # type: "_models.StringWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with string properties. + + :param complex_body: Please put 'goodrequest', '', and null. + :type complex_body: ~bodycomplex.models.StringWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "StringWrapper") + + request = rest_primitive.build_put_string_request( + content_type=content_type, + json=json, + template_url=self.put_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string.metadata = {"url": "/complex/primitive/string"} # type: ignore + + @distributed_trace + def get_date( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DateWrapper" + """Get complex types with date properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DateWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DateWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DateWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_date_request( + template_url=self.get_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DateWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date.metadata = {"url": "/complex/primitive/date"} # type: ignore + + @distributed_trace + def put_date( + self, + complex_body, # type: "_models.DateWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with date properties. + + :param complex_body: Please put '0001-01-01' and '2016-02-29'. + :type complex_body: ~bodycomplex.models.DateWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "DateWrapper") + + request = rest_primitive.build_put_date_request( + content_type=content_type, + json=json, + template_url=self.put_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date.metadata = {"url": "/complex/primitive/date"} # type: ignore + + @distributed_trace + def get_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DatetimeWrapper" + """Get complex types with datetime properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatetimeWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DatetimeWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DatetimeWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_date_time_request( + template_url=self.get_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DatetimeWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore + + @distributed_trace + def put_date_time( + self, + complex_body, # type: "_models.DatetimeWrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with datetime properties. + + :param complex_body: Please put '0001-01-01T12:00:00-04:00' and '2015-05-18T11:38:00-08:00'. + :type complex_body: ~bodycomplex.models.DatetimeWrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "DatetimeWrapper") + + request = rest_primitive.build_put_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time.metadata = {"url": "/complex/primitive/datetime"} # type: ignore + + @distributed_trace + def get_date_time_rfc1123( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Datetimerfc1123Wrapper" + """Get complex types with datetimeRfc1123 properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datetimerfc1123Wrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.Datetimerfc1123Wrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Datetimerfc1123Wrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_date_time_rfc1123_request( + template_url=self.get_date_time_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Datetimerfc1123Wrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore + + @distributed_trace + def put_date_time_rfc1123( + self, + complex_body, # type: "_models.Datetimerfc1123Wrapper" + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with datetimeRfc1123 properties. + + :param complex_body: Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May 2015 11:38:00 + GMT'. + :type complex_body: ~bodycomplex.models.Datetimerfc1123Wrapper + :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/json") # type: Optional[str] + + json = self._serialize.body(complex_body, "Datetimerfc1123Wrapper") + + request = rest_primitive.build_put_date_time_rfc1123_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123.metadata = {"url": "/complex/primitive/datetimerfc1123"} # type: ignore + + @distributed_trace + def get_duration( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.DurationWrapper" + """Get complex types with duration properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DurationWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.DurationWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.DurationWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_duration_request( + template_url=self.get_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("DurationWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore + + @distributed_trace + def put_duration( + self, + field=None, # type: Optional[datetime.timedelta] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with duration properties. + + :param field: + :type field: ~datetime.timedelta + :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/json") # type: Optional[str] + + _complex_body = _models.DurationWrapper(field=field) + json = self._serialize.body(_complex_body, "DurationWrapper") + + request = rest_primitive.build_put_duration_request( + content_type=content_type, + json=json, + template_url=self.put_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration.metadata = {"url": "/complex/primitive/duration"} # type: ignore + + @distributed_trace + def get_byte( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ByteWrapper" + """Get complex types with byte properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ByteWrapper, or the result of cls(response) + :rtype: ~bodycomplex.models.ByteWrapper + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ByteWrapper"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_primitive.build_get_byte_request( + template_url=self.get_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ByteWrapper", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore + + @distributed_trace + def put_byte( + self, + field=None, # type: Optional[bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types with byte properties. + + :param field: + :type field: bytearray + :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/json") # type: Optional[str] + + _complex_body = _models.ByteWrapper(field=field) + json = self._serialize.body(_complex_body, "ByteWrapper") + + request = rest_primitive.build_put_byte_request( + content_type=content_type, + json=json, + template_url=self.put_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte.metadata = {"url": "/complex/primitive/byte"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py new file mode 100644 index 00000000000..c0e07544a1a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/operations/_readonlyproperty_operations.py @@ -0,0 +1,137 @@ +# 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 .. import models as _models +from .._rest import readonlyproperty as rest_readonlyproperty + +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]] + + +class ReadonlypropertyOperations(object): + """ReadonlypropertyOperations 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: ~bodycomplex.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 get_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ReadonlyObj" + """Get complex types that have readonly properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ReadonlyObj, or the result of cls(response) + :rtype: ~bodycomplex.models.ReadonlyObj + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ReadonlyObj"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_readonlyproperty.build_get_valid_request( + template_url=self.get_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ReadonlyObj", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore + + @distributed_trace + def put_valid( + self, + size=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Put complex types that have readonly properties. + + :param size: + :type size: int + :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/json") # type: Optional[str] + + _complex_body = _models.ReadonlyObj(size=size) + json = self._serialize.body(_complex_body, "ReadonlyObj") + + request = rest_readonlyproperty.build_put_valid_request( + content_type=content_type, + json=json, + template_url=self.put_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_valid.metadata = {"url": "/complex/readonlyproperty/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/bodycomplex/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/setup.py new file mode 100644 index 00000000000..f043dc258ff --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyComplex/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 = "autorestcomplextestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestComplexTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestComplexTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_auto_rest_date_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_auto_rest_date_test_service.py new file mode 100644 index 00000000000..b9c6762c00b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_auto_rest_date_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestDateTestServiceConfiguration +from .operations import DateOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDateTestService(object): + """Test Infrastructure for AutoRest. + + :ivar date: DateOperations operations + :vartype date: bodydate.operations.DateOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTestServiceConfiguration(**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.date = DateOperations(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. + + We have helper methods to create requests specific to this service in `bodydate.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydate._rest import date + >>> request = date.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDateTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_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/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/__init__.py new file mode 100644 index 00000000000..30de141574a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_invalid_date_request + from ._request_builders_py3 import build_get_overflow_date_request + from ._request_builders_py3 import build_get_underflow_date_request + from ._request_builders_py3 import build_put_max_date_request + from ._request_builders_py3 import build_get_max_date_request + from ._request_builders_py3 import build_put_min_date_request + from ._request_builders_py3 import build_get_min_date_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_date_request # type: ignore + from ._request_builders import build_get_overflow_date_request # type: ignore + from ._request_builders import build_get_underflow_date_request # type: ignore + from ._request_builders import build_put_max_date_request # type: ignore + from ._request_builders import build_get_max_date_request # type: ignore + from ._request_builders import build_put_min_date_request # type: ignore + from ._request_builders import build_get_min_date_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_date_request", + "build_get_overflow_date_request", + "build_get_underflow_date_request", + "build_put_max_date_request", + "build_get_max_date_request", + "build_put_min_date_request", + "build_get_min_date_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/_request_builders.py new file mode 100644 index 00000000000..888141045b4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/_request_builders.py @@ -0,0 +1,287 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/invaliddate') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/overflowdate') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/underflowdate') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_max_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/max') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_max_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/max') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_min_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/min') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_min_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/min') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/_request_builders_py3.py new file mode 100644 index 00000000000..38e657cb61d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_rest/date/_request_builders_py3.py @@ -0,0 +1,218 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_date_request(**kwargs: Any) -> HttpRequest: + """Get invalid date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/invaliddate") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_date_request(**kwargs: Any) -> HttpRequest: + """Get overflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/overflowdate") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_date_request(**kwargs: Any) -> HttpRequest: + """Get underflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/underflowdate") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_max_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/max") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_max_date_request(**kwargs: Any) -> HttpRequest: + """Get max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/max") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_min_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/min") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_min_date_request(**kwargs: Any) -> HttpRequest: + """Get min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/min") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/_auto_rest_date_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/_auto_rest_date_test_service.py new file mode 100644 index 00000000000..29c1ef28f1d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/_auto_rest_date_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestDateTestServiceConfiguration +from .operations import DateOperations + + +class AutoRestDateTestService: + """Test Infrastructure for AutoRest. + + :ivar date: DateOperations operations + :vartype date: bodydate.aio.operations.DateOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTestServiceConfiguration(**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.date = DateOperations(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. + + We have helper methods to create requests specific to this service in `bodydate.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydate._rest import date + >>> request = date.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDateTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py new file mode 100644 index 00000000000..cb01ccf0fff --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py @@ -0,0 +1,354 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import date as rest_date + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DateOperations: + """DateOperations 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: ~bodydate.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 get_null(self, **kwargs: Any) -> Optional[datetime.date]: + """Get null date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date or None, or the result of cls(response) + :rtype: ~datetime.date or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/date/null"} # type: ignore + + @distributed_trace_async + async def get_invalid_date(self, **kwargs: Any) -> datetime.date: + """Get invalid date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_invalid_date_request( + template_url=self.get_invalid_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_date.metadata = {"url": "/date/invaliddate"} # type: ignore + + @distributed_trace_async + async def get_overflow_date(self, **kwargs: Any) -> datetime.date: + """Get overflow date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_overflow_date_request( + template_url=self.get_overflow_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow_date.metadata = {"url": "/date/overflowdate"} # type: ignore + + @distributed_trace_async + async def get_underflow_date(self, **kwargs: Any) -> datetime.date: + """Get underflow date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_underflow_date_request( + template_url=self.get_underflow_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow_date.metadata = {"url": "/date/underflowdate"} # type: ignore + + @distributed_trace_async + async def put_max_date(self, date_body: datetime.date, **kwargs: Any) -> None: + """Put max date value 9999-12-31. + + :param date_body: date body. + :type date_body: ~datetime.date + :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/json") # type: Optional[str] + + json = self._serialize.body(date_body, "date") + + request = rest_date.build_put_max_date_request( + content_type=content_type, + json=json, + template_url=self.put_max_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_max_date.metadata = {"url": "/date/max"} # type: ignore + + @distributed_trace_async + async def get_max_date(self, **kwargs: Any) -> datetime.date: + """Get max date value 9999-12-31. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_max_date_request( + template_url=self.get_max_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_max_date.metadata = {"url": "/date/max"} # type: ignore + + @distributed_trace_async + async def put_min_date(self, date_body: datetime.date, **kwargs: Any) -> None: + """Put min date value 0000-01-01. + + :param date_body: date body. + :type date_body: ~datetime.date + :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/json") # type: Optional[str] + + json = self._serialize.body(date_body, "date") + + request = rest_date.build_put_min_date_request( + content_type=content_type, + json=json, + template_url=self.put_min_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_min_date.metadata = {"url": "/date/min"} # type: ignore + + @distributed_trace_async + async def get_min_date(self, **kwargs: Any) -> datetime.date: + """Get min date value 0000-01-01. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_min_date_request( + template_url=self.get_min_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_min_date.metadata = {"url": "/date/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py new file mode 100644 index 00000000000..04555d8c22c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py @@ -0,0 +1,370 @@ +# 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 datetime +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 .. import models as _models +from .._rest import date as rest_date + +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]] + + +class DateOperations(object): + """DateOperations 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: ~bodydate.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[datetime.date] + """Get null date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date or None, or the result of cls(response) + :rtype: ~datetime.date or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/date/null"} # type: ignore + + @distributed_trace + def get_invalid_date( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.date + """Get invalid date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_invalid_date_request( + template_url=self.get_invalid_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_date.metadata = {"url": "/date/invaliddate"} # type: ignore + + @distributed_trace + def get_overflow_date( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.date + """Get overflow date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_overflow_date_request( + template_url=self.get_overflow_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow_date.metadata = {"url": "/date/overflowdate"} # type: ignore + + @distributed_trace + def get_underflow_date( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.date + """Get underflow date value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_underflow_date_request( + template_url=self.get_underflow_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow_date.metadata = {"url": "/date/underflowdate"} # type: ignore + + @distributed_trace + def put_max_date( + self, + date_body, # type: datetime.date + **kwargs # type: Any + ): + # type: (...) -> None + """Put max date value 9999-12-31. + + :param date_body: date body. + :type date_body: ~datetime.date + :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/json") # type: Optional[str] + + json = self._serialize.body(date_body, "date") + + request = rest_date.build_put_max_date_request( + content_type=content_type, + json=json, + template_url=self.put_max_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_max_date.metadata = {"url": "/date/max"} # type: ignore + + @distributed_trace + def get_max_date( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.date + """Get max date value 9999-12-31. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_max_date_request( + template_url=self.get_max_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_max_date.metadata = {"url": "/date/max"} # type: ignore + + @distributed_trace + def put_min_date( + self, + date_body, # type: datetime.date + **kwargs # type: Any + ): + # type: (...) -> None + """Put min date value 0000-01-01. + + :param date_body: date body. + :type date_body: ~datetime.date + :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/json") # type: Optional[str] + + json = self._serialize.body(date_body, "date") + + request = rest_date.build_put_min_date_request( + content_type=content_type, + json=json, + template_url=self.put_min_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_min_date.metadata = {"url": "/date/min"} # type: ignore + + @distributed_trace + def get_min_date( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.date + """Get min date value 0000-01-01. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: date, or the result of cls(response) + :rtype: ~datetime.date + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.date] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_date.build_get_min_date_request( + template_url=self.get_min_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("date", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_min_date.metadata = {"url": "/date/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/setup.py new file mode 100644 index 00000000000..90b3542e082 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/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 = "autorestdatetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDateTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDateTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_auto_rest_date_time_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_auto_rest_date_time_test_service.py new file mode 100644 index 00000000000..cd00b8f90c5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_auto_rest_date_time_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestDateTimeTestServiceConfiguration +from .operations import DatetimeOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDateTimeTestService(object): + """Test Infrastructure for AutoRest. + + :ivar datetime: DatetimeOperations operations + :vartype datetime: bodydatetime.operations.DatetimeOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTimeTestServiceConfiguration(**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.datetime = DatetimeOperations(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. + + We have helper methods to create requests specific to this service in `bodydatetime.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetime._rest import datetime + >>> request = datetime.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDateTimeTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_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/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/__init__.py new file mode 100644 index 00000000000..3a935a20ab7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/__init__.py @@ -0,0 +1,79 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_overflow_request + from ._request_builders_py3 import build_get_underflow_request + from ._request_builders_py3 import build_put_utc_max_date_time_request + from ._request_builders_py3 import build_put_utc_max_date_time7_digits_request + from ._request_builders_py3 import build_get_utc_lowercase_max_date_time_request + from ._request_builders_py3 import build_get_utc_uppercase_max_date_time_request + from ._request_builders_py3 import build_get_utc_uppercase_max_date_time7_digits_request + from ._request_builders_py3 import build_put_local_positive_offset_max_date_time_request + from ._request_builders_py3 import build_get_local_positive_offset_lowercase_max_date_time_request + from ._request_builders_py3 import build_get_local_positive_offset_uppercase_max_date_time_request + from ._request_builders_py3 import build_put_local_negative_offset_max_date_time_request + from ._request_builders_py3 import build_get_local_negative_offset_uppercase_max_date_time_request + from ._request_builders_py3 import build_get_local_negative_offset_lowercase_max_date_time_request + from ._request_builders_py3 import build_put_utc_min_date_time_request + from ._request_builders_py3 import build_get_utc_min_date_time_request + from ._request_builders_py3 import build_put_local_positive_offset_min_date_time_request + from ._request_builders_py3 import build_get_local_positive_offset_min_date_time_request + from ._request_builders_py3 import build_put_local_negative_offset_min_date_time_request + from ._request_builders_py3 import build_get_local_negative_offset_min_date_time_request + from ._request_builders_py3 import build_get_local_no_offset_min_date_time_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_overflow_request # type: ignore + from ._request_builders import build_get_underflow_request # type: ignore + from ._request_builders import build_put_utc_max_date_time_request # type: ignore + from ._request_builders import build_put_utc_max_date_time7_digits_request # type: ignore + from ._request_builders import build_get_utc_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_uppercase_max_date_time7_digits_request # type: ignore + from ._request_builders import build_put_local_positive_offset_max_date_time_request # type: ignore + from ._request_builders import build_get_local_positive_offset_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_get_local_positive_offset_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_put_local_negative_offset_max_date_time_request # type: ignore + from ._request_builders import build_get_local_negative_offset_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_get_local_negative_offset_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_put_utc_min_date_time_request # type: ignore + from ._request_builders import build_get_utc_min_date_time_request # type: ignore + from ._request_builders import build_put_local_positive_offset_min_date_time_request # type: ignore + from ._request_builders import build_get_local_positive_offset_min_date_time_request # type: ignore + from ._request_builders import build_put_local_negative_offset_min_date_time_request # type: ignore + from ._request_builders import build_get_local_negative_offset_min_date_time_request # type: ignore + from ._request_builders import build_get_local_no_offset_min_date_time_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_overflow_request", + "build_get_underflow_request", + "build_put_utc_max_date_time_request", + "build_put_utc_max_date_time7_digits_request", + "build_get_utc_lowercase_max_date_time_request", + "build_get_utc_uppercase_max_date_time_request", + "build_get_utc_uppercase_max_date_time7_digits_request", + "build_put_local_positive_offset_max_date_time_request", + "build_get_local_positive_offset_lowercase_max_date_time_request", + "build_get_local_positive_offset_uppercase_max_date_time_request", + "build_put_local_negative_offset_max_date_time_request", + "build_get_local_negative_offset_uppercase_max_date_time_request", + "build_get_local_negative_offset_lowercase_max_date_time_request", + "build_put_utc_min_date_time_request", + "build_get_utc_min_date_time_request", + "build_put_local_positive_offset_min_date_time_request", + "build_get_local_positive_offset_min_date_time_request", + "build_put_local_negative_offset_min_date_time_request", + "build_get_local_negative_offset_min_date_time_request", + "build_get_local_no_offset_min_date_time_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/_request_builders.py new file mode 100644 index 00000000000..304726682f9 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/_request_builders.py @@ -0,0 +1,777 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/overflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/underflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_max_date_time7_digits_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc7ms') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value 9999-12-31t23:59:59.999z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_uppercase_max_date_time7_digits_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc7ms/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_positive_offset_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localpositiveoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_positive_offset_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localpositiveoffset/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_positive_offset_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localpositiveoffset/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_negative_offset_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localnegativeoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_negative_offset_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localnegativeoffset/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_negative_offset_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localnegativeoffset/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/utc') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/utc') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_positive_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localpositiveoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_positive_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localpositiveoffset') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_negative_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localnegativeoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_negative_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localnegativeoffset') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_no_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localnooffset') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/_request_builders_py3.py new file mode 100644 index 00000000000..6eab960649e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_rest/datetime/_request_builders_py3.py @@ -0,0 +1,604 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_request(**kwargs: Any) -> HttpRequest: + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/overflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_request(**kwargs: Any) -> HttpRequest: + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/underflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_max_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_utc_max_date_time7_digits_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc7ms") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value 9999-12-31t23:59:59.999z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_utc_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_utc_uppercase_max_date_time7_digits_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc7ms/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_positive_offset_max_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localpositiveoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_positive_offset_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localpositiveoffset/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_local_positive_offset_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localpositiveoffset/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_negative_offset_max_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localnegativeoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_negative_offset_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localnegativeoffset/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_local_negative_offset_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localnegativeoffset/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_min_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/utc") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/utc") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_positive_offset_min_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localpositiveoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_positive_offset_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localpositiveoffset") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_negative_offset_min_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localnegativeoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_negative_offset_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localnegativeoffset") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_local_no_offset_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localnooffset") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_auto_rest_date_time_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_auto_rest_date_time_test_service.py new file mode 100644 index 00000000000..714b436f1af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_auto_rest_date_time_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestDateTimeTestServiceConfiguration +from .operations import DatetimeOperations + + +class AutoRestDateTimeTestService: + """Test Infrastructure for AutoRest. + + :ivar datetime: DatetimeOperations operations + :vartype datetime: bodydatetime.aio.operations.DatetimeOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTimeTestServiceConfiguration(**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.datetime = DatetimeOperations(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. + + We have helper methods to create requests specific to this service in `bodydatetime.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetime._rest import datetime + >>> request = datetime.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDateTimeTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py new file mode 100644 index 00000000000..c16451beaff --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py @@ -0,0 +1,893 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import datetime as rest_datetime + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DatetimeOperations: + """DatetimeOperations 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: ~bodydatetime.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 get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: + """Get null datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/datetime/null"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> datetime.datetime: + """Get invalid datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/datetime/invalid"} # type: ignore + + @distributed_trace_async + async def get_overflow(self, **kwargs: Any) -> datetime.datetime: + """Get overflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_overflow_request( + template_url=self.get_overflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow.metadata = {"url": "/datetime/overflow"} # type: ignore + + @distributed_trace_async + async def get_underflow(self, **kwargs: Any) -> datetime.datetime: + """Get underflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_underflow_request( + template_url=self.get_underflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow.metadata = {"url": "/datetime/underflow"} # type: ignore + + @distributed_trace_async + async def put_utc_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put max datetime value 9999-12-31T23:59:59.999Z. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_utc_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_max_date_time.metadata = {"url": "/datetime/max/utc"} # type: ignore + + @distributed_trace_async + async def put_utc_max_date_time7_digits(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_utc_max_date_time7_digits_request( + content_type=content_type, + json=json, + template_url=self.put_utc_max_date_time7_digits.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms"} # type: ignore + + @distributed_trace_async + async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value 9999-12-31t23:59:59.999z. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_lowercase_max_date_time_request( + template_url=self.get_utc_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_lowercase_max_date_time.metadata = {"url": "/datetime/max/utc/lowercase"} # type: ignore + + @distributed_trace_async + async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value 9999-12-31T23:59:59.999Z. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_uppercase_max_date_time_request( + template_url=self.get_utc_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_uppercase_max_date_time.metadata = {"url": "/datetime/max/utc/uppercase"} # type: ignore + + @distributed_trace_async + async def get_utc_uppercase_max_date_time7_digits(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_uppercase_max_date_time7_digits_request( + template_url=self.get_utc_uppercase_max_date_time7_digits.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_uppercase_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms/uppercase"} # type: ignore + + @distributed_trace_async + async def put_local_positive_offset_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_positive_offset_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_positive_offset_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_positive_offset_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset"} # type: ignore + + @distributed_trace_async + async def get_local_positive_offset_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_positive_offset_lowercase_max_date_time_request( + template_url=self.get_local_positive_offset_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_positive_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/lowercase"} # type: ignore + + @distributed_trace_async + async def get_local_positive_offset_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_positive_offset_uppercase_max_date_time_request( + template_url=self.get_local_positive_offset_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_positive_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/uppercase"} # type: ignore + + @distributed_trace_async + async def put_local_negative_offset_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_negative_offset_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_negative_offset_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_negative_offset_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset"} # type: ignore + + @distributed_trace_async + async def get_local_negative_offset_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_negative_offset_uppercase_max_date_time_request( + template_url=self.get_local_negative_offset_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_negative_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/uppercase"} # type: ignore + + @distributed_trace_async + async def get_local_negative_offset_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_negative_offset_lowercase_max_date_time_request( + template_url=self.get_local_negative_offset_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_negative_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/lowercase"} # type: ignore + + @distributed_trace_async + async def put_utc_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put min datetime value 0001-01-01T00:00:00Z. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_utc_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore + + @distributed_trace_async + async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get min datetime value 0001-01-01T00:00:00Z. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_min_date_time_request( + template_url=self.get_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore + + @distributed_trace_async + async def put_local_positive_offset_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put min datetime value 0001-01-01T00:00:00+14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_positive_offset_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_positive_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore + + @distributed_trace_async + async def get_local_positive_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get min datetime value 0001-01-01T00:00:00+14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_positive_offset_min_date_time_request( + template_url=self.get_local_positive_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore + + @distributed_trace_async + async def put_local_negative_offset_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put min datetime value 0001-01-01T00:00:00-14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_negative_offset_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_negative_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore + + @distributed_trace_async + async def get_local_negative_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get min datetime value 0001-01-01T00:00:00-14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_negative_offset_min_date_time_request( + template_url=self.get_local_negative_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore + + @distributed_trace_async + async def get_local_no_offset_min_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get min datetime value 0001-01-01T00:00:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_no_offset_min_date_time_request( + template_url=self.get_local_no_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_no_offset_min_date_time.metadata = {"url": "/datetime/min/localnooffset"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py new file mode 100644 index 00000000000..abc5abf3a0f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py @@ -0,0 +1,933 @@ +# 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 datetime +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 .. import models as _models +from .._rest import datetime as rest_datetime + +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]] + + +class DatetimeOperations(object): + """DatetimeOperations 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: ~bodydatetime.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[datetime.datetime] + """Get null datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/datetime/null"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get invalid datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/datetime/invalid"} # type: ignore + + @distributed_trace + def get_overflow( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get overflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_overflow_request( + template_url=self.get_overflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow.metadata = {"url": "/datetime/overflow"} # type: ignore + + @distributed_trace + def get_underflow( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get underflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_underflow_request( + template_url=self.get_underflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow.metadata = {"url": "/datetime/underflow"} # type: ignore + + @distributed_trace + def put_utc_max_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put max datetime value 9999-12-31T23:59:59.999Z. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_utc_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_max_date_time.metadata = {"url": "/datetime/max/utc"} # type: ignore + + @distributed_trace + def put_utc_max_date_time7_digits( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_utc_max_date_time7_digits_request( + content_type=content_type, + json=json, + template_url=self.put_utc_max_date_time7_digits.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms"} # type: ignore + + @distributed_trace + def get_utc_lowercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value 9999-12-31t23:59:59.999z. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_lowercase_max_date_time_request( + template_url=self.get_utc_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_lowercase_max_date_time.metadata = {"url": "/datetime/max/utc/lowercase"} # type: ignore + + @distributed_trace + def get_utc_uppercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value 9999-12-31T23:59:59.999Z. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_uppercase_max_date_time_request( + template_url=self.get_utc_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_uppercase_max_date_time.metadata = {"url": "/datetime/max/utc/uppercase"} # type: ignore + + @distributed_trace + def get_utc_uppercase_max_date_time7_digits( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_uppercase_max_date_time7_digits_request( + template_url=self.get_utc_uppercase_max_date_time7_digits.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_uppercase_max_date_time7_digits.metadata = {"url": "/datetime/max/utc7ms/uppercase"} # type: ignore + + @distributed_trace + def put_local_positive_offset_max_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_positive_offset_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_positive_offset_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_positive_offset_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset"} # type: ignore + + @distributed_trace + def get_local_positive_offset_lowercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_positive_offset_lowercase_max_date_time_request( + template_url=self.get_local_positive_offset_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_positive_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/lowercase"} # type: ignore + + @distributed_trace + def get_local_positive_offset_uppercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_positive_offset_uppercase_max_date_time_request( + template_url=self.get_local_positive_offset_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_positive_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localpositiveoffset/uppercase"} # type: ignore + + @distributed_trace + def put_local_negative_offset_max_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_negative_offset_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_negative_offset_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_negative_offset_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset"} # type: ignore + + @distributed_trace + def get_local_negative_offset_uppercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_negative_offset_uppercase_max_date_time_request( + template_url=self.get_local_negative_offset_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_negative_offset_uppercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/uppercase"} # type: ignore + + @distributed_trace + def get_local_negative_offset_lowercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_negative_offset_lowercase_max_date_time_request( + template_url=self.get_local_negative_offset_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_negative_offset_lowercase_max_date_time.metadata = {"url": "/datetime/max/localnegativeoffset/lowercase"} # type: ignore + + @distributed_trace + def put_utc_min_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put min datetime value 0001-01-01T00:00:00Z. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_utc_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore + + @distributed_trace + def get_utc_min_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get min datetime value 0001-01-01T00:00:00Z. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_utc_min_date_time_request( + template_url=self.get_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_min_date_time.metadata = {"url": "/datetime/min/utc"} # type: ignore + + @distributed_trace + def put_local_positive_offset_min_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put min datetime value 0001-01-01T00:00:00+14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_positive_offset_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_positive_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore + + @distributed_trace + def get_local_positive_offset_min_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get min datetime value 0001-01-01T00:00:00+14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_positive_offset_min_date_time_request( + template_url=self.get_local_positive_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_positive_offset_min_date_time.metadata = {"url": "/datetime/min/localpositiveoffset"} # type: ignore + + @distributed_trace + def put_local_negative_offset_min_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put min datetime value 0001-01-01T00:00:00-14:00. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "iso-8601") + + request = rest_datetime.build_put_local_negative_offset_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_local_negative_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore + + @distributed_trace + def get_local_negative_offset_min_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get min datetime value 0001-01-01T00:00:00-14:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_negative_offset_min_date_time_request( + template_url=self.get_local_negative_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_negative_offset_min_date_time.metadata = {"url": "/datetime/min/localnegativeoffset"} # type: ignore + + @distributed_trace + def get_local_no_offset_min_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get min datetime value 0001-01-01T00:00:00. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetime.build_get_local_no_offset_min_date_time_request( + template_url=self.get_local_no_offset_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("iso-8601", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_local_no_offset_min_date_time.metadata = {"url": "/datetime/min/localnooffset"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/setup.py new file mode 100644 index 00000000000..b0967348287 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/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 = "autorestdatetimetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDateTimeTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDateTimeTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_auto_rest_rfc1123_date_time_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_auto_rest_rfc1123_date_time_test_service.py new file mode 100644 index 00000000000..5e89f38e634 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_auto_rest_rfc1123_date_time_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestRFC1123DateTimeTestServiceConfiguration +from .operations import Datetimerfc1123Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestRFC1123DateTimeTestService(object): + """Test Infrastructure for AutoRest. + + :ivar datetimerfc1123: Datetimerfc1123Operations operations + :vartype datetimerfc1123: bodydatetimerfc1123.operations.Datetimerfc1123Operations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRFC1123DateTimeTestServiceConfiguration(**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.datetimerfc1123 = Datetimerfc1123Operations(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. + + We have helper methods to create requests specific to this service in `bodydatetimerfc1123.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetimerfc1123._rest import datetimerfc1123 + >>> request = datetimerfc1123.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestRFC1123DateTimeTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_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/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/__init__.py new file mode 100644 index 00000000000..63f5895326f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/__init__.py @@ -0,0 +1,40 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_overflow_request + from ._request_builders_py3 import build_get_underflow_request + from ._request_builders_py3 import build_put_utc_max_date_time_request + from ._request_builders_py3 import build_get_utc_lowercase_max_date_time_request + from ._request_builders_py3 import build_get_utc_uppercase_max_date_time_request + from ._request_builders_py3 import build_put_utc_min_date_time_request + from ._request_builders_py3 import build_get_utc_min_date_time_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_overflow_request # type: ignore + from ._request_builders import build_get_underflow_request # type: ignore + from ._request_builders import build_put_utc_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_put_utc_min_date_time_request # type: ignore + from ._request_builders import build_get_utc_min_date_time_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_overflow_request", + "build_get_underflow_request", + "build_put_utc_max_date_time_request", + "build_get_utc_lowercase_max_date_time_request", + "build_get_utc_uppercase_max_date_time_request", + "build_put_utc_min_date_time_request", + "build_get_utc_min_date_time_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/_request_builders.py new file mode 100644 index 00000000000..d613b196a42 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/_request_builders.py @@ -0,0 +1,318 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/overflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/underflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/max') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/max/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/max/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/min') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/min') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/_request_builders_py3.py new file mode 100644 index 00000000000..886bd519c35 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_rest/datetimerfc1123/_request_builders_py3.py @@ -0,0 +1,241 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_request(**kwargs: Any) -> HttpRequest: + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/overflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_request(**kwargs: Any) -> HttpRequest: + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/underflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_max_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/max") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/max/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_utc_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/max/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_min_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/min") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/min") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_auto_rest_rfc1123_date_time_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_auto_rest_rfc1123_date_time_test_service.py new file mode 100644 index 00000000000..3c07a3fb06f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_auto_rest_rfc1123_date_time_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestRFC1123DateTimeTestServiceConfiguration +from .operations import Datetimerfc1123Operations + + +class AutoRestRFC1123DateTimeTestService: + """Test Infrastructure for AutoRest. + + :ivar datetimerfc1123: Datetimerfc1123Operations operations + :vartype datetimerfc1123: bodydatetimerfc1123.aio.operations.Datetimerfc1123Operations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRFC1123DateTimeTestServiceConfiguration(**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.datetimerfc1123 = Datetimerfc1123Operations(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. + + We have helper methods to create requests specific to this service in `bodydatetimerfc1123.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetimerfc1123._rest import datetimerfc1123 + >>> request = datetimerfc1123.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestRFC1123DateTimeTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py new file mode 100644 index 00000000000..052e21195f7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py @@ -0,0 +1,391 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import datetimerfc1123 as rest_datetimerfc1123 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Datetimerfc1123Operations: + """Datetimerfc1123Operations 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: ~bodydatetimerfc1123.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 get_null(self, **kwargs: Any) -> Optional[datetime.datetime]: + """Get null datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/datetimerfc1123/null"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> datetime.datetime: + """Get invalid datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/datetimerfc1123/invalid"} # type: ignore + + @distributed_trace_async + async def get_overflow(self, **kwargs: Any) -> datetime.datetime: + """Get overflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_overflow_request( + template_url=self.get_overflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow.metadata = {"url": "/datetimerfc1123/overflow"} # type: ignore + + @distributed_trace_async + async def get_underflow(self, **kwargs: Any) -> datetime.datetime: + """Get underflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_underflow_request( + template_url=self.get_underflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow.metadata = {"url": "/datetimerfc1123/underflow"} # type: ignore + + @distributed_trace_async + async def put_utc_max_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "rfc-1123") + + request = rest_datetimerfc1123.build_put_utc_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_max_date_time.metadata = {"url": "/datetimerfc1123/max"} # type: ignore + + @distributed_trace_async + async def get_utc_lowercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_utc_lowercase_max_date_time_request( + template_url=self.get_utc_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_lowercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/lowercase"} # type: ignore + + @distributed_trace_async + async def get_utc_uppercase_max_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_utc_uppercase_max_date_time_request( + template_url=self.get_utc_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_uppercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/uppercase"} # type: ignore + + @distributed_trace_async + async def put_utc_min_date_time(self, datetime_body: datetime.datetime, **kwargs: Any) -> None: + """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "rfc-1123") + + request = rest_datetimerfc1123.build_put_utc_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore + + @distributed_trace_async + async def get_utc_min_date_time(self, **kwargs: Any) -> datetime.datetime: + """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_utc_min_date_time_request( + template_url=self.get_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py new file mode 100644 index 00000000000..7a60f7f01c3 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py @@ -0,0 +1,408 @@ +# 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 datetime +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 .. import models as _models +from .._rest import datetimerfc1123 as rest_datetimerfc1123 + +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]] + + +class Datetimerfc1123Operations(object): + """Datetimerfc1123Operations 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: ~bodydatetimerfc1123.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[datetime.datetime] + """Get null datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/datetimerfc1123/null"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get invalid datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/datetimerfc1123/invalid"} # type: ignore + + @distributed_trace + def get_overflow( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get overflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_overflow_request( + template_url=self.get_overflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow.metadata = {"url": "/datetimerfc1123/overflow"} # type: ignore + + @distributed_trace + def get_underflow( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get underflow datetime value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_underflow_request( + template_url=self.get_underflow.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow.metadata = {"url": "/datetimerfc1123/underflow"} # type: ignore + + @distributed_trace + def put_utc_max_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "rfc-1123") + + request = rest_datetimerfc1123.build_put_utc_max_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_max_date_time.metadata = {"url": "/datetimerfc1123/max"} # type: ignore + + @distributed_trace + def get_utc_lowercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_utc_lowercase_max_date_time_request( + template_url=self.get_utc_lowercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_lowercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/lowercase"} # type: ignore + + @distributed_trace + def get_utc_uppercase_max_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_utc_uppercase_max_date_time_request( + template_url=self.get_utc_uppercase_max_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_uppercase_max_date_time.metadata = {"url": "/datetimerfc1123/max/uppercase"} # type: ignore + + @distributed_trace + def put_utc_min_date_time( + self, + datetime_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + :param datetime_body: datetime body. + :type datetime_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(datetime_body, "rfc-1123") + + request = rest_datetimerfc1123.build_put_utc_min_date_time_request( + content_type=content_type, + json=json, + template_url=self.put_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore + + @distributed_trace + def get_utc_min_date_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_datetimerfc1123.build_get_utc_min_date_time_request( + template_url=self.get_utc_min_date_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("rfc-1123", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_utc_min_date_time.metadata = {"url": "/datetimerfc1123/min"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py new file mode 100644 index 00000000000..b8061d302f5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/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 = "autorestrfc1123datetimetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestRFC1123DateTimeTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestRFC1123DateTimeTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_auto_rest_swagger_ba_tdictionary_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_auto_rest_swagger_ba_tdictionary_service.py new file mode 100644 index 00000000000..93a4c4d8795 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_auto_rest_swagger_ba_tdictionary_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATDictionaryServiceConfiguration +from .operations import DictionaryOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATDictionaryService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar dictionary: DictionaryOperations operations + :vartype dictionary: bodydictionary.operations.DictionaryOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATDictionaryServiceConfiguration(**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.dictionary = DictionaryOperations(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. + + We have helper methods to create requests specific to this service in `bodydictionary.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydictionary._rest import dictionary + >>> request = dictionary.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATDictionaryService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_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/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/__init__.py new file mode 100644 index 00000000000..dbf5f8a21dd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/__init__.py @@ -0,0 +1,208 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_null_value_request + from ._request_builders_py3 import build_get_null_key_request + from ._request_builders_py3 import build_get_empty_string_key_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_boolean_tfft_request + from ._request_builders_py3 import build_put_boolean_tfft_request + from ._request_builders_py3 import build_get_boolean_invalid_null_request + from ._request_builders_py3 import build_get_boolean_invalid_string_request + from ._request_builders_py3 import build_get_integer_valid_request + from ._request_builders_py3 import build_put_integer_valid_request + from ._request_builders_py3 import build_get_int_invalid_null_request + from ._request_builders_py3 import build_get_int_invalid_string_request + from ._request_builders_py3 import build_get_long_valid_request + from ._request_builders_py3 import build_put_long_valid_request + from ._request_builders_py3 import build_get_long_invalid_null_request + from ._request_builders_py3 import build_get_long_invalid_string_request + from ._request_builders_py3 import build_get_float_valid_request + from ._request_builders_py3 import build_put_float_valid_request + from ._request_builders_py3 import build_get_float_invalid_null_request + from ._request_builders_py3 import build_get_float_invalid_string_request + from ._request_builders_py3 import build_get_double_valid_request + from ._request_builders_py3 import build_put_double_valid_request + from ._request_builders_py3 import build_get_double_invalid_null_request + from ._request_builders_py3 import build_get_double_invalid_string_request + from ._request_builders_py3 import build_get_string_valid_request + from ._request_builders_py3 import build_put_string_valid_request + from ._request_builders_py3 import build_get_string_with_null_request + from ._request_builders_py3 import build_get_string_with_invalid_request + from ._request_builders_py3 import build_get_date_valid_request + from ._request_builders_py3 import build_put_date_valid_request + from ._request_builders_py3 import build_get_date_invalid_null_request + from ._request_builders_py3 import build_get_date_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_valid_request + from ._request_builders_py3 import build_put_date_time_valid_request + from ._request_builders_py3 import build_get_date_time_invalid_null_request + from ._request_builders_py3 import build_get_date_time_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_put_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_get_duration_valid_request + from ._request_builders_py3 import build_put_duration_valid_request + from ._request_builders_py3 import build_get_byte_valid_request + from ._request_builders_py3 import build_put_byte_valid_request + from ._request_builders_py3 import build_get_byte_invalid_null_request + from ._request_builders_py3 import build_get_base64_url_request + from ._request_builders_py3 import build_get_complex_null_request + from ._request_builders_py3 import build_get_complex_empty_request + from ._request_builders_py3 import build_get_complex_item_null_request + from ._request_builders_py3 import build_get_complex_item_empty_request + from ._request_builders_py3 import build_get_complex_valid_request + from ._request_builders_py3 import build_put_complex_valid_request + from ._request_builders_py3 import build_get_array_null_request + from ._request_builders_py3 import build_get_array_empty_request + from ._request_builders_py3 import build_get_array_item_null_request + from ._request_builders_py3 import build_get_array_item_empty_request + from ._request_builders_py3 import build_get_array_valid_request + from ._request_builders_py3 import build_put_array_valid_request + from ._request_builders_py3 import build_get_dictionary_null_request + from ._request_builders_py3 import build_get_dictionary_empty_request + from ._request_builders_py3 import build_get_dictionary_item_null_request + from ._request_builders_py3 import build_get_dictionary_item_empty_request + from ._request_builders_py3 import build_get_dictionary_valid_request + from ._request_builders_py3 import build_put_dictionary_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_null_value_request # type: ignore + from ._request_builders import build_get_null_key_request # type: ignore + from ._request_builders import build_get_empty_string_key_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_boolean_tfft_request # type: ignore + from ._request_builders import build_put_boolean_tfft_request # type: ignore + from ._request_builders import build_get_boolean_invalid_null_request # type: ignore + from ._request_builders import build_get_boolean_invalid_string_request # type: ignore + from ._request_builders import build_get_integer_valid_request # type: ignore + from ._request_builders import build_put_integer_valid_request # type: ignore + from ._request_builders import build_get_int_invalid_null_request # type: ignore + from ._request_builders import build_get_int_invalid_string_request # type: ignore + from ._request_builders import build_get_long_valid_request # type: ignore + from ._request_builders import build_put_long_valid_request # type: ignore + from ._request_builders import build_get_long_invalid_null_request # type: ignore + from ._request_builders import build_get_long_invalid_string_request # type: ignore + from ._request_builders import build_get_float_valid_request # type: ignore + from ._request_builders import build_put_float_valid_request # type: ignore + from ._request_builders import build_get_float_invalid_null_request # type: ignore + from ._request_builders import build_get_float_invalid_string_request # type: ignore + from ._request_builders import build_get_double_valid_request # type: ignore + from ._request_builders import build_put_double_valid_request # type: ignore + from ._request_builders import build_get_double_invalid_null_request # type: ignore + from ._request_builders import build_get_double_invalid_string_request # type: ignore + from ._request_builders import build_get_string_valid_request # type: ignore + from ._request_builders import build_put_string_valid_request # type: ignore + from ._request_builders import build_get_string_with_null_request # type: ignore + from ._request_builders import build_get_string_with_invalid_request # type: ignore + from ._request_builders import build_get_date_valid_request # type: ignore + from ._request_builders import build_put_date_valid_request # type: ignore + from ._request_builders import build_get_date_invalid_null_request # type: ignore + from ._request_builders import build_get_date_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_valid_request # type: ignore + from ._request_builders import build_put_date_time_valid_request # type: ignore + from ._request_builders import build_get_date_time_invalid_null_request # type: ignore + from ._request_builders import build_get_date_time_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_get_duration_valid_request # type: ignore + from ._request_builders import build_put_duration_valid_request # type: ignore + from ._request_builders import build_get_byte_valid_request # type: ignore + from ._request_builders import build_put_byte_valid_request # type: ignore + from ._request_builders import build_get_byte_invalid_null_request # type: ignore + from ._request_builders import build_get_base64_url_request # type: ignore + from ._request_builders import build_get_complex_null_request # type: ignore + from ._request_builders import build_get_complex_empty_request # type: ignore + from ._request_builders import build_get_complex_item_null_request # type: ignore + from ._request_builders import build_get_complex_item_empty_request # type: ignore + from ._request_builders import build_get_complex_valid_request # type: ignore + from ._request_builders import build_put_complex_valid_request # type: ignore + from ._request_builders import build_get_array_null_request # type: ignore + from ._request_builders import build_get_array_empty_request # type: ignore + from ._request_builders import build_get_array_item_null_request # type: ignore + from ._request_builders import build_get_array_item_empty_request # type: ignore + from ._request_builders import build_get_array_valid_request # type: ignore + from ._request_builders import build_put_array_valid_request # type: ignore + from ._request_builders import build_get_dictionary_null_request # type: ignore + from ._request_builders import build_get_dictionary_empty_request # type: ignore + from ._request_builders import build_get_dictionary_item_null_request # type: ignore + from ._request_builders import build_get_dictionary_item_empty_request # type: ignore + from ._request_builders import build_get_dictionary_valid_request # type: ignore + from ._request_builders import build_put_dictionary_valid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_null_value_request", + "build_get_null_key_request", + "build_get_empty_string_key_request", + "build_get_invalid_request", + "build_get_boolean_tfft_request", + "build_put_boolean_tfft_request", + "build_get_boolean_invalid_null_request", + "build_get_boolean_invalid_string_request", + "build_get_integer_valid_request", + "build_put_integer_valid_request", + "build_get_int_invalid_null_request", + "build_get_int_invalid_string_request", + "build_get_long_valid_request", + "build_put_long_valid_request", + "build_get_long_invalid_null_request", + "build_get_long_invalid_string_request", + "build_get_float_valid_request", + "build_put_float_valid_request", + "build_get_float_invalid_null_request", + "build_get_float_invalid_string_request", + "build_get_double_valid_request", + "build_put_double_valid_request", + "build_get_double_invalid_null_request", + "build_get_double_invalid_string_request", + "build_get_string_valid_request", + "build_put_string_valid_request", + "build_get_string_with_null_request", + "build_get_string_with_invalid_request", + "build_get_date_valid_request", + "build_put_date_valid_request", + "build_get_date_invalid_null_request", + "build_get_date_invalid_chars_request", + "build_get_date_time_valid_request", + "build_put_date_time_valid_request", + "build_get_date_time_invalid_null_request", + "build_get_date_time_invalid_chars_request", + "build_get_date_time_rfc1123_valid_request", + "build_put_date_time_rfc1123_valid_request", + "build_get_duration_valid_request", + "build_put_duration_valid_request", + "build_get_byte_valid_request", + "build_put_byte_valid_request", + "build_get_byte_invalid_null_request", + "build_get_base64_url_request", + "build_get_complex_null_request", + "build_get_complex_empty_request", + "build_get_complex_item_null_request", + "build_get_complex_item_empty_request", + "build_get_complex_valid_request", + "build_put_complex_valid_request", + "build_get_array_null_request", + "build_get_array_empty_request", + "build_get_array_item_null_request", + "build_get_array_item_empty_request", + "build_get_array_valid_request", + "build_put_array_valid_request", + "build_get_dictionary_null_request", + "build_get_dictionary_empty_request", + "build_get_dictionary_item_null_request", + "build_get_dictionary_item_empty_request", + "build_get_dictionary_valid_request", + "build_put_dictionary_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/_request_builders.py new file mode 100644 index 00000000000..0a5d02e2be7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/_request_builders.py @@ -0,0 +1,2204 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty dictionary value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_value_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get Dictionary with null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/nullvalue') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get Dictionary with null key. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/nullkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_string_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get Dictionary with key as empty string. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/keyemptystring') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/tfft') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/tfft') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": true, "1": null, "2": false }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/true.null.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/true.boolean.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo.null.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo.123.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2011-03-22", "1": "date"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", + "2": "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": + "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan + 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time-rfc1123/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 + 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time-rfc1123/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/duration/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/duration/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each item encoded in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/byte/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/byte/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 + encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/byte/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test + string", "2": "Lorem ipsum"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/base64url/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty dictionary of complex type {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, + "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": + {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty dictionary {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/_request_builders_py3.py new file mode 100644 index 00000000000..8ae3a0edfd6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_rest/dictionary/_request_builders_py3.py @@ -0,0 +1,1679 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty dictionary value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_value_request(**kwargs: Any) -> HttpRequest: + """Get Dictionary with null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/nullvalue") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_key_request(**kwargs: Any) -> HttpRequest: + """Get Dictionary with null key. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/nullkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_string_key_request(**kwargs: Any) -> HttpRequest: + """Get Dictionary with key as empty string. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/keyemptystring") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid Dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_tfft_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/tfft") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_boolean_tfft_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/tfft") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": true, "1": null, "2": false }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/true.null.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/true.boolean.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_integer_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_integer_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_int_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get long dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_valid_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_valid_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_valid_request(**kwargs: Any) -> HttpRequest: + """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_with_null_request(**kwargs: Any) -> HttpRequest: + """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo.null.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_with_invalid_request(**kwargs: Any) -> HttpRequest: + """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo.123.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2011-03-22", "1": "date"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", + "2": "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": + "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_rfc1123_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan + 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time-rfc1123/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 + 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time-rfc1123/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_valid_request(**kwargs: Any) -> HttpRequest: + """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/duration/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/duration/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_valid_request(**kwargs: Any) -> HttpRequest: + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each item encoded in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/byte/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/byte/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 + encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/byte/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_request(**kwargs: Any) -> HttpRequest: + """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test + string", "2": "Lorem ipsum"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/base64url/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_null_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty dictionary of complex type {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_null_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_valid_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, + "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": + {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_null_request(**kwargs: Any) -> HttpRequest: + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_empty_request(**kwargs: Any) -> HttpRequest: + """Get an empty dictionary {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_null_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_empty_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_valid_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_auto_rest_swagger_ba_tdictionary_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_auto_rest_swagger_ba_tdictionary_service.py new file mode 100644 index 00000000000..379b94868dc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_auto_rest_swagger_ba_tdictionary_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATDictionaryServiceConfiguration +from .operations import DictionaryOperations + + +class AutoRestSwaggerBATDictionaryService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar dictionary: DictionaryOperations operations + :vartype dictionary: bodydictionary.aio.operations.DictionaryOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATDictionaryServiceConfiguration(**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.dictionary = DictionaryOperations(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. + + We have helper methods to create requests specific to this service in `bodydictionary.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydictionary._rest import dictionary + >>> request = dictionary.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATDictionaryService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py new file mode 100644 index 00000000000..023a9c5741b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py @@ -0,0 +1,2522 @@ +# 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 datetime +import functools +from typing import Any, Callable, Dict, Generic, List, 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 ... import models as _models +from ..._rest import dictionary as rest_dictionary + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DictionaryOperations: + """DictionaryOperations 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: ~bodydictionary.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 get_null(self, **kwargs: Any) -> Dict[str, int]: + """Get null dictionary value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/dictionary/null"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> Dict[str, int]: + """Get empty dictionary value {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/dictionary/empty"} # type: ignore + + @distributed_trace_async + async def put_empty(self, array_body: Dict[str, str], **kwargs: Any) -> None: + """Set dictionary value empty {}. + + :param array_body: + :type array_body: dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{str}") + + request = rest_dictionary.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/dictionary/empty"} # type: ignore + + @distributed_trace_async + async def get_null_value(self, **kwargs: Any) -> Dict[str, str]: + """Get Dictionary with null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_value_request( + template_url=self.get_null_value.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_value.metadata = {"url": "/dictionary/nullvalue"} # type: ignore + + @distributed_trace_async + async def get_null_key(self, **kwargs: Any) -> Dict[str, str]: + """Get Dictionary with null key. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_key_request( + template_url=self.get_null_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_key.metadata = {"url": "/dictionary/nullkey"} # type: ignore + + @distributed_trace_async + async def get_empty_string_key(self, **kwargs: Any) -> Dict[str, str]: + """Get Dictionary with key as empty string. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_empty_string_key_request( + template_url=self.get_empty_string_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_string_key.metadata = {"url": "/dictionary/keyemptystring"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> Dict[str, str]: + """Get invalid Dictionary value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/dictionary/invalid"} # type: ignore + + @distributed_trace_async + async def get_boolean_tfft(self, **kwargs: Any) -> Dict[str, bool]: + """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bool, or the result of cls(response) + :rtype: dict[str, bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_boolean_tfft_request( + template_url=self.get_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bool}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore + + @distributed_trace_async + async def put_boolean_tfft(self, array_body: Dict[str, bool], **kwargs: Any) -> None: + """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. + + :param array_body: + :type array_body: dict[str, bool] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{bool}") + + request = rest_dictionary.build_put_boolean_tfft_request( + content_type=content_type, + json=json, + template_url=self.put_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore + + @distributed_trace_async + async def get_boolean_invalid_null(self, **kwargs: Any) -> Dict[str, bool]: + """Get boolean dictionary value {"0": true, "1": null, "2": false }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bool, or the result of cls(response) + :rtype: dict[str, bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_boolean_invalid_null_request( + template_url=self.get_boolean_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bool}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_null.metadata = {"url": "/dictionary/prim/boolean/true.null.false"} # type: ignore + + @distributed_trace_async + async def get_boolean_invalid_string(self, **kwargs: Any) -> Dict[str, bool]: + """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bool, or the result of cls(response) + :rtype: dict[str, bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_boolean_invalid_string_request( + template_url=self.get_boolean_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bool}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_string.metadata = {"url": "/dictionary/prim/boolean/true.boolean.false"} # type: ignore + + @distributed_trace_async + async def get_integer_valid(self, **kwargs: Any) -> Dict[str, int]: + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_integer_valid_request( + template_url=self.get_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def put_integer_valid(self, array_body: Dict[str, int], **kwargs: Any) -> None: + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + :param array_body: + :type array_body: dict[str, int] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{int}") + + request = rest_dictionary.build_put_integer_valid_request( + content_type=content_type, + json=json, + template_url=self.put_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def get_int_invalid_null(self, **kwargs: Any) -> Dict[str, int]: + """Get integer dictionary value {"0": 1, "1": null, "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_int_invalid_null_request( + template_url=self.get_int_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_null.metadata = {"url": "/dictionary/prim/integer/1.null.zero"} # type: ignore + + @distributed_trace_async + async def get_int_invalid_string(self, **kwargs: Any) -> Dict[str, int]: + """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_int_invalid_string_request( + template_url=self.get_int_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_string.metadata = {"url": "/dictionary/prim/integer/1.integer.0"} # type: ignore + + @distributed_trace_async + async def get_long_valid(self, **kwargs: Any) -> Dict[str, int]: + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to long, or the result of cls(response) + :rtype: dict[str, long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_long_valid_request( + template_url=self.get_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{long}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def put_long_valid(self, array_body: Dict[str, int], **kwargs: Any) -> None: + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + :param array_body: + :type array_body: dict[str, long] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{long}") + + request = rest_dictionary.build_put_long_valid_request( + content_type=content_type, + json=json, + template_url=self.put_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace_async + async def get_long_invalid_null(self, **kwargs: Any) -> Dict[str, int]: + """Get long dictionary value {"0": 1, "1": null, "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to long, or the result of cls(response) + :rtype: dict[str, long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_long_invalid_null_request( + template_url=self.get_long_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{long}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_null.metadata = {"url": "/dictionary/prim/long/1.null.zero"} # type: ignore + + @distributed_trace_async + async def get_long_invalid_string(self, **kwargs: Any) -> Dict[str, int]: + """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to long, or the result of cls(response) + :rtype: dict[str, long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_long_invalid_string_request( + template_url=self.get_long_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{long}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_string.metadata = {"url": "/dictionary/prim/long/1.integer.0"} # type: ignore + + @distributed_trace_async + async def get_float_valid(self, **kwargs: Any) -> Dict[str, float]: + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_float_valid_request( + template_url=self.get_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def put_float_valid(self, array_body: Dict[str, float], **kwargs: Any) -> None: + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :param array_body: + :type array_body: dict[str, float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{float}") + + request = rest_dictionary.build_put_float_valid_request( + content_type=content_type, + json=json, + template_url=self.put_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_float_invalid_null(self, **kwargs: Any) -> Dict[str, float]: + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_float_invalid_null_request( + template_url=self.get_float_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_null.metadata = {"url": "/dictionary/prim/float/0.0-null-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_float_invalid_string(self, **kwargs: Any) -> Dict[str, float]: + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_float_invalid_string_request( + template_url=self.get_float_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_string.metadata = {"url": "/dictionary/prim/float/1.number.0"} # type: ignore + + @distributed_trace_async + async def get_double_valid(self, **kwargs: Any) -> Dict[str, float]: + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_double_valid_request( + template_url=self.get_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def put_double_valid(self, array_body: Dict[str, float], **kwargs: Any) -> None: + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :param array_body: + :type array_body: dict[str, float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{float}") + + request = rest_dictionary.build_put_double_valid_request( + content_type=content_type, + json=json, + template_url=self.put_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_double_invalid_null(self, **kwargs: Any) -> Dict[str, float]: + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_double_invalid_null_request( + template_url=self.get_double_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_null.metadata = {"url": "/dictionary/prim/double/0.0-null-1.2e20"} # type: ignore + + @distributed_trace_async + async def get_double_invalid_string(self, **kwargs: Any) -> Dict[str, float]: + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_double_invalid_string_request( + template_url=self.get_double_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_string.metadata = {"url": "/dictionary/prim/double/1.number.0"} # type: ignore + + @distributed_trace_async + async def get_string_valid(self, **kwargs: Any) -> Dict[str, str]: + """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_string_valid_request( + template_url=self.get_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def put_string_valid(self, array_body: Dict[str, str], **kwargs: Any) -> None: + """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + :param array_body: + :type array_body: dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{str}") + + request = rest_dictionary.build_put_string_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace_async + async def get_string_with_null(self, **kwargs: Any) -> Dict[str, str]: + """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_string_with_null_request( + template_url=self.get_string_with_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_null.metadata = {"url": "/dictionary/prim/string/foo.null.foo2"} # type: ignore + + @distributed_trace_async + async def get_string_with_invalid(self, **kwargs: Any) -> Dict[str, str]: + """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_string_with_invalid_request( + template_url=self.get_string_with_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_invalid.metadata = {"url": "/dictionary/prim/string/foo.123.foo2"} # type: ignore + + @distributed_trace_async + async def get_date_valid(self, **kwargs: Any) -> Dict[str, datetime.date]: + """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to date, or the result of cls(response) + :rtype: dict[str, ~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_valid_request( + template_url=self.get_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{date}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore + + @distributed_trace_async + async def put_date_valid(self, array_body: Dict[str, datetime.date], **kwargs: Any) -> None: + """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + :param array_body: + :type array_body: dict[str, ~datetime.date] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{date}") + + request = rest_dictionary.build_put_date_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore + + @distributed_trace_async + async def get_date_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.date]: + """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to date, or the result of cls(response) + :rtype: dict[str, ~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_invalid_null_request( + template_url=self.get_date_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{date}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_null.metadata = {"url": "/dictionary/prim/date/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_date_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.date]: + """Get date dictionary value {"0": "2011-03-22", "1": "date"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to date, or the result of cls(response) + :rtype: dict[str, ~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_invalid_chars_request( + template_url=self.get_date_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{date}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_chars.metadata = {"url": "/dictionary/prim/date/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_time_valid(self, **kwargs: Any) -> Dict[str, datetime.datetime]: + """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", + "2": "1492-10-12T10:15:01-08:00"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_valid_request( + template_url=self.get_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{iso-8601}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore + + @distributed_trace_async + async def put_date_time_valid(self, array_body: Dict[str, datetime.datetime], **kwargs: Any) -> None: + """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": + "1492-10-12T10:15:01-08:00"}. + + :param array_body: + :type array_body: dict[str, ~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{iso-8601}") + + request = rest_dictionary.build_put_date_time_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore + + @distributed_trace_async + async def get_date_time_invalid_null(self, **kwargs: Any) -> Dict[str, datetime.datetime]: + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_invalid_null_request( + template_url=self.get_date_time_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{iso-8601}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_null.metadata = {"url": "/dictionary/prim/date-time/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_date_time_invalid_chars(self, **kwargs: Any) -> Dict[str, datetime.datetime]: + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_invalid_chars_request( + template_url=self.get_date_time_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{iso-8601}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_chars.metadata = {"url": "/dictionary/prim/date-time/invalidchars"} # type: ignore + + @distributed_trace_async + async def get_date_time_rfc1123_valid(self, **kwargs: Any) -> Dict[str, datetime.datetime]: + """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan + 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_rfc1123_valid_request( + template_url=self.get_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{rfc-1123}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace_async + async def put_date_time_rfc1123_valid(self, array_body: Dict[str, datetime.datetime], **kwargs: Any) -> None: + """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 + 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + :param array_body: + :type array_body: dict[str, ~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{rfc-1123}") + + request = rest_dictionary.build_put_date_time_rfc1123_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace_async + async def get_duration_valid(self, **kwargs: Any) -> Dict[str, datetime.timedelta]: + """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to timedelta, or the result of cls(response) + :rtype: dict[str, ~datetime.timedelta] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_duration_valid_request( + template_url=self.get_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{duration}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore + + @distributed_trace_async + async def put_duration_valid(self, array_body: Dict[str, datetime.timedelta], **kwargs: Any) -> None: + """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + :param array_body: + :type array_body: dict[str, ~datetime.timedelta] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{duration}") + + request = rest_dictionary.build_put_duration_valid_request( + content_type=content_type, + json=json, + template_url=self.put_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore + + @distributed_trace_async + async def get_byte_valid(self, **kwargs: Any) -> Dict[str, bytearray]: + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each item encoded in base64. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bytearray, or the result of cls(response) + :rtype: dict[str, bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_byte_valid_request( + template_url=self.get_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bytearray}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore + + @distributed_trace_async + async def put_byte_valid(self, array_body: Dict[str, bytearray], **kwargs: Any) -> None: + """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each elementencoded in base 64. + + :param array_body: + :type array_body: dict[str, bytearray] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{bytearray}") + + request = rest_dictionary.build_put_byte_valid_request( + content_type=content_type, + json=json, + template_url=self.put_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore + + @distributed_trace_async + async def get_byte_invalid_null(self, **kwargs: Any) -> Dict[str, bytearray]: + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 + encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bytearray, or the result of cls(response) + :rtype: dict[str, bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_byte_invalid_null_request( + template_url=self.get_byte_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bytearray}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_invalid_null.metadata = {"url": "/dictionary/prim/byte/invalidnull"} # type: ignore + + @distributed_trace_async + async def get_base64_url(self, **kwargs: Any) -> Dict[str, bytes]: + """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test + string", "2": "Lorem ipsum"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bytes, or the result of cls(response) + :rtype: dict[str, bytes] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_base64_url_request( + template_url=self.get_base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{base64}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url.metadata = {"url": "/dictionary/prim/base64url/valid"} # type: ignore + + @distributed_trace_async + async def get_complex_null(self, **kwargs: Any) -> Optional[Dict[str, "_models.Widget"]]: + """Get dictionary of complex type null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget or None, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, "_models.Widget"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_null_request( + template_url=self.get_complex_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_null.metadata = {"url": "/dictionary/complex/null"} # type: ignore + + @distributed_trace_async + async def get_complex_empty(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: + """Get empty dictionary of complex type {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_empty_request( + template_url=self.get_complex_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_empty.metadata = {"url": "/dictionary/complex/empty"} # type: ignore + + @distributed_trace_async + async def get_complex_item_null(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: + """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, + "2": {"integer": 5, "string": "6"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_item_null_request( + template_url=self.get_complex_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_null.metadata = {"url": "/dictionary/complex/itemnull"} # type: ignore + + @distributed_trace_async + async def get_complex_item_empty(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: + """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, + "2": {"integer": 5, "string": "6"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_item_empty_request( + template_url=self.get_complex_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_empty.metadata = {"url": "/dictionary/complex/itemempty"} # type: ignore + + @distributed_trace_async + async def get_complex_valid(self, **kwargs: Any) -> Dict[str, "_models.Widget"]: + """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, + "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_valid_request( + template_url=self.get_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore + + @distributed_trace_async + async def put_complex_valid(self, array_body: Dict[str, "_models.Widget"], **kwargs: Any) -> None: + """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": + {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + :param array_body: + :type array_body: dict[str, ~bodydictionary.models.Widget] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{Widget}") + + request = rest_dictionary.build_put_complex_valid_request( + content_type=content_type, + json=json, + template_url=self.put_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore + + @distributed_trace_async + async def get_array_null(self, **kwargs: Any) -> Optional[Dict[str, List[str]]]: + """Get a null array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str or None, or the result of cls(response) + :rtype: dict[str, list[str]] or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, List[str]]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_null_request( + template_url=self.get_array_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_null.metadata = {"url": "/dictionary/array/null"} # type: ignore + + @distributed_trace_async + async def get_array_empty(self, **kwargs: Any) -> Dict[str, List[str]]: + """Get an empty dictionary {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_empty_request( + template_url=self.get_array_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_empty.metadata = {"url": "/dictionary/array/empty"} # type: ignore + + @distributed_trace_async + async def get_array_item_null(self, **kwargs: Any) -> Dict[str, List[str]]: + """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_item_null_request( + template_url=self.get_array_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_null.metadata = {"url": "/dictionary/array/itemnull"} # type: ignore + + @distributed_trace_async + async def get_array_item_empty(self, **kwargs: Any) -> Dict[str, List[str]]: + """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_item_empty_request( + template_url=self.get_array_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_empty.metadata = {"url": "/dictionary/array/itemempty"} # type: ignore + + @distributed_trace_async + async def get_array_valid(self, **kwargs: Any) -> Dict[str, List[str]]: + """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_valid_request( + template_url=self.get_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore + + @distributed_trace_async + async def put_array_valid(self, array_body: Dict[str, List[str]], **kwargs: Any) -> None: + """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + :param array_body: + :type array_body: dict[str, list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{[str]}") + + request = rest_dictionary.build_put_array_valid_request( + content_type=content_type, + json=json, + template_url=self.put_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore + + @distributed_trace_async + async def get_dictionary_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: + """Get an dictionaries of dictionaries with value null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_null_request( + template_url=self.get_dictionary_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_null.metadata = {"url": "/dictionary/dictionary/null"} # type: ignore + + @distributed_trace_async + async def get_dictionary_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: + """Get an dictionaries of dictionaries of type with value {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_empty_request( + template_url=self.get_dictionary_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_empty.metadata = {"url": "/dictionary/dictionary/empty"} # type: ignore + + @distributed_trace_async + async def get_dictionary_item_null(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_item_null_request( + template_url=self.get_dictionary_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_null.metadata = {"url": "/dictionary/dictionary/itemnull"} # type: ignore + + @distributed_trace_async + async def get_dictionary_item_empty(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_item_empty_request( + template_url=self.get_dictionary_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_empty.metadata = {"url": "/dictionary/dictionary/itemempty"} # type: ignore + + @distributed_trace_async + async def get_dictionary_valid(self, **kwargs: Any) -> Dict[str, Dict[str, str]]: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_valid_request( + template_url=self.get_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore + + @distributed_trace_async + async def put_dictionary_valid(self, array_body: Dict[str, Dict[str, str]], **kwargs: Any) -> None: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + :param array_body: + :type array_body: dict[str, dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{{str}}") + + request = rest_dictionary.build_put_dictionary_valid_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py new file mode 100644 index 00000000000..f9c87785363 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py @@ -0,0 +1,2621 @@ +# 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 datetime +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 .. import models as _models +from .._rest import dictionary as rest_dictionary + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class DictionaryOperations(object): + """DictionaryOperations 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: ~bodydictionary.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get null dictionary value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/dictionary/null"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get empty dictionary value {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/dictionary/empty"} # type: ignore + + @distributed_trace + def put_empty( + self, + array_body, # type: Dict[str, str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value empty {}. + + :param array_body: + :type array_body: dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{str}") + + request = rest_dictionary.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/dictionary/empty"} # type: ignore + + @distributed_trace + def get_null_value( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get Dictionary with null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_value_request( + template_url=self.get_null_value.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_value.metadata = {"url": "/dictionary/nullvalue"} # type: ignore + + @distributed_trace + def get_null_key( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get Dictionary with null key. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_null_key_request( + template_url=self.get_null_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_key.metadata = {"url": "/dictionary/nullkey"} # type: ignore + + @distributed_trace + def get_empty_string_key( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get Dictionary with key as empty string. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_empty_string_key_request( + template_url=self.get_empty_string_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_string_key.metadata = {"url": "/dictionary/keyemptystring"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get invalid Dictionary value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/dictionary/invalid"} # type: ignore + + @distributed_trace + def get_boolean_tfft( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, bool] + """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bool, or the result of cls(response) + :rtype: dict[str, bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_boolean_tfft_request( + template_url=self.get_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bool}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore + + @distributed_trace + def put_boolean_tfft( + self, + array_body, # type: Dict[str, bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. + + :param array_body: + :type array_body: dict[str, bool] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{bool}") + + request = rest_dictionary.build_put_boolean_tfft_request( + content_type=content_type, + json=json, + template_url=self.put_boolean_tfft.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_boolean_tfft.metadata = {"url": "/dictionary/prim/boolean/tfft"} # type: ignore + + @distributed_trace + def get_boolean_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, bool] + """Get boolean dictionary value {"0": true, "1": null, "2": false }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bool, or the result of cls(response) + :rtype: dict[str, bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_boolean_invalid_null_request( + template_url=self.get_boolean_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bool}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_null.metadata = {"url": "/dictionary/prim/boolean/true.null.false"} # type: ignore + + @distributed_trace + def get_boolean_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, bool] + """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bool, or the result of cls(response) + :rtype: dict[str, bool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bool]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_boolean_invalid_string_request( + template_url=self.get_boolean_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bool}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_boolean_invalid_string.metadata = {"url": "/dictionary/prim/boolean/true.boolean.false"} # type: ignore + + @distributed_trace + def get_integer_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_integer_valid_request( + template_url=self.get_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace + def put_integer_valid( + self, + array_body, # type: Dict[str, int] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + :param array_body: + :type array_body: dict[str, int] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{int}") + + request = rest_dictionary.build_put_integer_valid_request( + content_type=content_type, + json=json, + template_url=self.put_integer_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_integer_valid.metadata = {"url": "/dictionary/prim/integer/1.-1.3.300"} # type: ignore + + @distributed_trace + def get_int_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get integer dictionary value {"0": 1, "1": null, "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_int_invalid_null_request( + template_url=self.get_int_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_null.metadata = {"url": "/dictionary/prim/integer/1.null.zero"} # type: ignore + + @distributed_trace + def get_int_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_int_invalid_string_request( + template_url=self.get_int_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_int_invalid_string.metadata = {"url": "/dictionary/prim/integer/1.integer.0"} # type: ignore + + @distributed_trace + def get_long_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to long, or the result of cls(response) + :rtype: dict[str, long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_long_valid_request( + template_url=self.get_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{long}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace + def put_long_valid( + self, + array_body, # type: Dict[str, int] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + :param array_body: + :type array_body: dict[str, long] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{long}") + + request = rest_dictionary.build_put_long_valid_request( + content_type=content_type, + json=json, + template_url=self.put_long_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_long_valid.metadata = {"url": "/dictionary/prim/long/1.-1.3.300"} # type: ignore + + @distributed_trace + def get_long_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get long dictionary value {"0": 1, "1": null, "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to long, or the result of cls(response) + :rtype: dict[str, long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_long_invalid_null_request( + template_url=self.get_long_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{long}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_null.metadata = {"url": "/dictionary/prim/long/1.null.zero"} # type: ignore + + @distributed_trace + def get_long_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to long, or the result of cls(response) + :rtype: dict[str, long] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_long_invalid_string_request( + template_url=self.get_long_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{long}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_long_invalid_string.metadata = {"url": "/dictionary/prim/long/1.integer.0"} # type: ignore + + @distributed_trace + def get_float_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, float] + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_float_valid_request( + template_url=self.get_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def put_float_valid( + self, + array_body, # type: Dict[str, float] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :param array_body: + :type array_body: dict[str, float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{float}") + + request = rest_dictionary.build_put_float_valid_request( + content_type=content_type, + json=json, + template_url=self.put_float_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_float_valid.metadata = {"url": "/dictionary/prim/float/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def get_float_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, float] + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_float_invalid_null_request( + template_url=self.get_float_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_null.metadata = {"url": "/dictionary/prim/float/0.0-null-1.2e20"} # type: ignore + + @distributed_trace + def get_float_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, float] + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_float_invalid_string_request( + template_url=self.get_float_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_float_invalid_string.metadata = {"url": "/dictionary/prim/float/1.number.0"} # type: ignore + + @distributed_trace + def get_double_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, float] + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_double_valid_request( + template_url=self.get_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def put_double_valid( + self, + array_body, # type: Dict[str, float] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + :param array_body: + :type array_body: dict[str, float] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{float}") + + request = rest_dictionary.build_put_double_valid_request( + content_type=content_type, + json=json, + template_url=self.put_double_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_double_valid.metadata = {"url": "/dictionary/prim/double/0--0.01-1.2e20"} # type: ignore + + @distributed_trace + def get_double_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, float] + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_double_invalid_null_request( + template_url=self.get_double_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_null.metadata = {"url": "/dictionary/prim/double/0.0-null-1.2e20"} # type: ignore + + @distributed_trace + def get_double_invalid_string( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, float] + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to float, or the result of cls(response) + :rtype: dict[str, float] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_double_invalid_string_request( + template_url=self.get_double_invalid_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{float}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_double_invalid_string.metadata = {"url": "/dictionary/prim/double/1.number.0"} # type: ignore + + @distributed_trace + def get_string_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_string_valid_request( + template_url=self.get_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def put_string_valid( + self, + array_body, # type: Dict[str, str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + :param array_body: + :type array_body: dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{str}") + + request = rest_dictionary.build_put_string_valid_request( + content_type=content_type, + json=json, + template_url=self.put_string_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_string_valid.metadata = {"url": "/dictionary/prim/string/foo1.foo2.foo3"} # type: ignore + + @distributed_trace + def get_string_with_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_string_with_null_request( + template_url=self.get_string_with_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_null.metadata = {"url": "/dictionary/prim/string/foo.null.foo2"} # type: ignore + + @distributed_trace + def get_string_with_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, str] + """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to str, or the result of cls(response) + :rtype: dict[str, str] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_string_with_invalid_request( + template_url=self.get_string_with_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{str}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string_with_invalid.metadata = {"url": "/dictionary/prim/string/foo.123.foo2"} # type: ignore + + @distributed_trace + def get_date_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.date] + """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to date, or the result of cls(response) + :rtype: dict[str, ~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_valid_request( + template_url=self.get_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{date}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore + + @distributed_trace + def put_date_valid( + self, + array_body, # type: Dict[str, datetime.date] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + :param array_body: + :type array_body: dict[str, ~datetime.date] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{date}") + + request = rest_dictionary.build_put_date_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_valid.metadata = {"url": "/dictionary/prim/date/valid"} # type: ignore + + @distributed_trace + def get_date_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.date] + """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to date, or the result of cls(response) + :rtype: dict[str, ~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_invalid_null_request( + template_url=self.get_date_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{date}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_null.metadata = {"url": "/dictionary/prim/date/invalidnull"} # type: ignore + + @distributed_trace + def get_date_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.date] + """Get date dictionary value {"0": "2011-03-22", "1": "date"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to date, or the result of cls(response) + :rtype: dict[str, ~datetime.date] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.date]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_invalid_chars_request( + template_url=self.get_date_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{date}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_invalid_chars.metadata = {"url": "/dictionary/prim/date/invalidchars"} # type: ignore + + @distributed_trace + def get_date_time_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.datetime] + """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", + "2": "1492-10-12T10:15:01-08:00"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_valid_request( + template_url=self.get_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{iso-8601}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore + + @distributed_trace + def put_date_time_valid( + self, + array_body, # type: Dict[str, datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": + "1492-10-12T10:15:01-08:00"}. + + :param array_body: + :type array_body: dict[str, ~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{iso-8601}") + + request = rest_dictionary.build_put_date_time_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_valid.metadata = {"url": "/dictionary/prim/date-time/valid"} # type: ignore + + @distributed_trace + def get_date_time_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.datetime] + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_invalid_null_request( + template_url=self.get_date_time_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{iso-8601}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_null.metadata = {"url": "/dictionary/prim/date-time/invalidnull"} # type: ignore + + @distributed_trace + def get_date_time_invalid_chars( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.datetime] + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_invalid_chars_request( + template_url=self.get_date_time_invalid_chars.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{iso-8601}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_invalid_chars.metadata = {"url": "/dictionary/prim/date-time/invalidchars"} # type: ignore + + @distributed_trace + def get_date_time_rfc1123_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.datetime] + """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan + 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to datetime, or the result of cls(response) + :rtype: dict[str, ~datetime.datetime] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_date_time_rfc1123_valid_request( + template_url=self.get_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{rfc-1123}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace + def put_date_time_rfc1123_valid( + self, + array_body, # type: Dict[str, datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 + 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + :param array_body: + :type array_body: dict[str, ~datetime.datetime] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{rfc-1123}") + + request = rest_dictionary.build_put_date_time_rfc1123_valid_request( + content_type=content_type, + json=json, + template_url=self.put_date_time_rfc1123_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_date_time_rfc1123_valid.metadata = {"url": "/dictionary/prim/date-time-rfc1123/valid"} # type: ignore + + @distributed_trace + def get_duration_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, datetime.timedelta] + """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to timedelta, or the result of cls(response) + :rtype: dict[str, ~datetime.timedelta] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_duration_valid_request( + template_url=self.get_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{duration}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore + + @distributed_trace + def put_duration_valid( + self, + array_body, # type: Dict[str, datetime.timedelta] + **kwargs # type: Any + ): + # type: (...) -> None + """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + :param array_body: + :type array_body: dict[str, ~datetime.timedelta] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{duration}") + + request = rest_dictionary.build_put_duration_valid_request( + content_type=content_type, + json=json, + template_url=self.put_duration_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_duration_valid.metadata = {"url": "/dictionary/prim/duration/valid"} # type: ignore + + @distributed_trace + def get_byte_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, bytearray] + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each item encoded in base64. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bytearray, or the result of cls(response) + :rtype: dict[str, bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_byte_valid_request( + template_url=self.get_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bytearray}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore + + @distributed_trace + def put_byte_valid( + self, + array_body, # type: Dict[str, bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each elementencoded in base 64. + + :param array_body: + :type array_body: dict[str, bytearray] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{bytearray}") + + request = rest_dictionary.build_put_byte_valid_request( + content_type=content_type, + json=json, + template_url=self.put_byte_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_byte_valid.metadata = {"url": "/dictionary/prim/byte/valid"} # type: ignore + + @distributed_trace + def get_byte_invalid_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, bytearray] + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 + encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bytearray, or the result of cls(response) + :rtype: dict[str, bytearray] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytearray]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_byte_invalid_null_request( + template_url=self.get_byte_invalid_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{bytearray}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_byte_invalid_null.metadata = {"url": "/dictionary/prim/byte/invalidnull"} # type: ignore + + @distributed_trace + def get_base64_url( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, bytes] + """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test + string", "2": "Lorem ipsum"}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to bytes, or the result of cls(response) + :rtype: dict[str, bytes] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_base64_url_request( + template_url=self.get_base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{base64}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url.metadata = {"url": "/dictionary/prim/base64url/valid"} # type: ignore + + @distributed_trace + def get_complex_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[Dict[str, "_models.Widget"]] + """Get dictionary of complex type null value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget or None, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, "_models.Widget"]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_null_request( + template_url=self.get_complex_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_null.metadata = {"url": "/dictionary/complex/null"} # type: ignore + + @distributed_trace + def get_complex_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, "_models.Widget"] + """Get empty dictionary of complex type {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_empty_request( + template_url=self.get_complex_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_empty.metadata = {"url": "/dictionary/complex/empty"} # type: ignore + + @distributed_trace + def get_complex_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, "_models.Widget"] + """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, + "2": {"integer": 5, "string": "6"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_item_null_request( + template_url=self.get_complex_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_null.metadata = {"url": "/dictionary/complex/itemnull"} # type: ignore + + @distributed_trace + def get_complex_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, "_models.Widget"] + """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, + "2": {"integer": 5, "string": "6"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_item_empty_request( + template_url=self.get_complex_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_item_empty.metadata = {"url": "/dictionary/complex/itemempty"} # type: ignore + + @distributed_trace + def get_complex_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, "_models.Widget"] + """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, + "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to Widget, or the result of cls(response) + :rtype: dict[str, ~bodydictionary.models.Widget] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.Widget"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_complex_valid_request( + template_url=self.get_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{Widget}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore + + @distributed_trace + def put_complex_valid( + self, + array_body, # type: Dict[str, "_models.Widget"] + **kwargs # type: Any + ): + # type: (...) -> None + """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": + {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + :param array_body: + :type array_body: dict[str, ~bodydictionary.models.Widget] + :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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{Widget}") + + request = rest_dictionary.build_put_complex_valid_request( + content_type=content_type, + json=json, + template_url=self.put_complex_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_valid.metadata = {"url": "/dictionary/complex/valid"} # type: ignore + + @distributed_trace + def get_array_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[Dict[str, List[str]]] + """Get a null array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str or None, or the result of cls(response) + :rtype: dict[str, list[str]] or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[Dict[str, List[str]]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_null_request( + template_url=self.get_array_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_null.metadata = {"url": "/dictionary/array/null"} # type: ignore + + @distributed_trace + def get_array_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, List[str]] + """Get an empty dictionary {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_empty_request( + template_url=self.get_array_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_empty.metadata = {"url": "/dictionary/array/empty"} # type: ignore + + @distributed_trace + def get_array_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, List[str]] + """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_item_null_request( + template_url=self.get_array_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_null.metadata = {"url": "/dictionary/array/itemnull"} # type: ignore + + @distributed_trace + def get_array_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, List[str]] + """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_item_empty_request( + template_url=self.get_array_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_item_empty.metadata = {"url": "/dictionary/array/itemempty"} # type: ignore + + @distributed_trace + def get_array_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, List[str]] + """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to list of str, or the result of cls(response) + :rtype: dict[str, list[str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_array_valid_request( + template_url=self.get_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{[str]}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore + + @distributed_trace + def put_array_valid( + self, + array_body, # type: Dict[str, List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + :param array_body: + :type array_body: dict[str, list[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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{[str]}") + + request = rest_dictionary.build_put_array_valid_request( + content_type=content_type, + json=json, + template_url=self.put_array_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore + + @distributed_trace + def get_dictionary_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, Dict[str, str]] + """Get an dictionaries of dictionaries with value null. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_null_request( + template_url=self.get_dictionary_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_null.metadata = {"url": "/dictionary/dictionary/null"} # type: ignore + + @distributed_trace + def get_dictionary_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, Dict[str, str]] + """Get an dictionaries of dictionaries of type with value {}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_empty_request( + template_url=self.get_dictionary_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_empty.metadata = {"url": "/dictionary/dictionary/empty"} # type: ignore + + @distributed_trace + def get_dictionary_item_null( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, Dict[str, str]] + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_item_null_request( + template_url=self.get_dictionary_item_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_null.metadata = {"url": "/dictionary/dictionary/itemnull"} # type: ignore + + @distributed_trace + def get_dictionary_item_empty( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, Dict[str, str]] + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_item_empty_request( + template_url=self.get_dictionary_item_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_item_empty.metadata = {"url": "/dictionary/dictionary/itemempty"} # type: ignore + + @distributed_trace + def get_dictionary_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, Dict[str, str]] + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_dictionary.build_get_dictionary_valid_request( + template_url=self.get_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{{str}}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore + + @distributed_trace + def put_dictionary_valid( + self, + array_body, # type: Dict[str, Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + :param array_body: + :type array_body: dict[str, dict[str, 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/json") # type: Optional[str] + + json = self._serialize.body(array_body, "{{str}}") + + request = rest_dictionary.build_put_dictionary_valid_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/setup.py new file mode 100644 index 00000000000..2656cf02743 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/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 = "autorestswaggerbatdictionaryservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATDictionaryService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATDictionaryService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/__init__.py new file mode 100644 index 00000000000..0cac81cdcb4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/__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 ._auto_rest_duration_test_service import AutoRestDurationTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestDurationTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_auto_rest_duration_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..be77dd94ec9 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_auto_rest_duration_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestDurationTestServiceConfiguration +from .operations import DurationOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDurationTestService(object): + """Test Infrastructure for AutoRest. + + :ivar duration: DurationOperations operations + :vartype duration: bodyduration.operations.DurationOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**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.duration = DurationOperations(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. + + We have helper methods to create requests specific to this service in `bodyduration.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyduration._rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDurationTestService + 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/BodyDuration/bodyduration/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_configuration.py new file mode 100644 index 00000000000..8b18f16d3f2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_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 AutoRestDurationTestServiceConfiguration(Configuration): + """Configuration for AutoRestDurationTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestDurationTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdurationtestservice/{}".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/BodyDuration/bodyduration/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_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/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/__init__.py new file mode 100644 index 00000000000..2551fd5500f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/__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 ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_put_positive_duration_request + from ._request_builders_py3 import build_get_positive_duration_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_put_positive_duration_request # type: ignore + from ._request_builders import build_get_positive_duration_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_put_positive_duration_request", + "build_get_positive_duration_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/_request_builders.py new file mode 100644 index 00000000000..704a82ac6ff --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/_request_builders.py @@ -0,0 +1,153 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/_request_builders_py3.py new file mode 100644 index 00000000000..07c69434b2b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_rest/duration/_request_builders_py3.py @@ -0,0 +1,116 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_positive_duration_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_positive_duration_request(**kwargs: Any) -> HttpRequest: + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_version.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/__init__.py new file mode 100644 index 00000000000..7286d17b514 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/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 ._auto_rest_duration_test_service import AutoRestDurationTestService + +__all__ = ["AutoRestDurationTestService"] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..e14ce7a1895 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_auto_rest_duration_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestDurationTestServiceConfiguration +from .operations import DurationOperations + + +class AutoRestDurationTestService: + """Test Infrastructure for AutoRest. + + :ivar duration: DurationOperations operations + :vartype duration: bodyduration.aio.operations.DurationOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**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.duration = DurationOperations(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. + + We have helper methods to create requests specific to this service in `bodyduration.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyduration._rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDurationTestService": + 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/BodyDuration/bodyduration/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/_configuration.py new file mode 100644 index 00000000000..f7cece514e6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/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 AutoRestDurationTestServiceConfiguration(Configuration): + """Configuration for AutoRestDurationTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestDurationTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdurationtestservice/{}".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/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py new file mode 100644 index 00000000000..c08b5059205 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py @@ -0,0 +1,203 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import duration as rest_duration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DurationOperations: + """DurationOperations 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: ~bodyduration.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 get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]: + """Get null duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/duration/null"} # type: ignore + + @distributed_trace_async + async def put_positive_duration(self, duration_body: datetime.timedelta, **kwargs: Any) -> None: + """Put a positive duration value. + + :param duration_body: duration body. + :type duration_body: ~datetime.timedelta + :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/json") # type: Optional[str] + + json = self._serialize.body(duration_body, "duration") + + request = rest_duration.build_put_positive_duration_request( + content_type=content_type, + json=json, + template_url=self.put_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace_async + async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta: + """Get a positive duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_positive_duration_request( + template_url=self.get_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> datetime.timedelta: + """Get an invalid duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py new file mode 100644 index 00000000000..c19b4f56fe1 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py @@ -0,0 +1,213 @@ +# 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 datetime +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 .. import models as _models +from .._rest import duration as rest_duration + +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]] + + +class DurationOperations(object): + """DurationOperations 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: ~bodyduration.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[datetime.timedelta] + """Get null duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.timedelta]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/duration/null"} # type: ignore + + @distributed_trace + def put_positive_duration( + self, + duration_body, # type: datetime.timedelta + **kwargs # type: Any + ): + # type: (...) -> None + """Put a positive duration value. + + :param duration_body: duration body. + :type duration_body: ~datetime.timedelta + :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/json") # type: Optional[str] + + json = self._serialize.body(duration_body, "duration") + + request = rest_duration.build_put_positive_duration_request( + content_type=content_type, + json=json, + template_url=self.put_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace + def get_positive_duration( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.timedelta + """Get a positive duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_positive_duration_request( + template_url=self.get_positive_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_positive_duration.metadata = {"url": "/duration/positiveduration"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.timedelta + """Get an invalid duration value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: timedelta, or the result of cls(response) + :rtype: ~datetime.timedelta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.timedelta] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_duration.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("duration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/duration/invalid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/setup.py new file mode 100644 index 00000000000..5d6c5294492 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/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 = "autorestdurationtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDurationTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDurationTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_auto_rest_swagger_bat_file_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_auto_rest_swagger_bat_file_service.py new file mode 100644 index 00000000000..f2705d79d5e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_auto_rest_swagger_bat_file_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATFileServiceConfiguration +from .operations import FilesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATFileService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar files: FilesOperations operations + :vartype files: bodyfile.operations.FilesOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFileServiceConfiguration(**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.files = FilesOperations(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. + + We have helper methods to create requests specific to this service in `bodyfile.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyfile._rest import files + >>> request = files.build_get_file_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATFileService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_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/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/__init__.py new file mode 100644 index 00000000000..7ac5971aa0b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/__init__.py @@ -0,0 +1,22 @@ +# 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_get_file_request + from ._request_builders_py3 import build_get_file_large_request + from ._request_builders_py3 import build_get_empty_file_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_file_request # type: ignore + from ._request_builders import build_get_file_large_request # type: ignore + from ._request_builders import build_get_empty_file_request # type: ignore + +__all__ = [ + "build_get_file_request", + "build_get_file_large_request", + "build_get_empty_file_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/_request_builders.py new file mode 100644 index 00000000000..16c12b0af5b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/_request_builders.py @@ -0,0 +1,111 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_file_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", '/files/stream/nonempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_file_large_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a large file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", '/files/stream/verylarge') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_file_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", '/files/stream/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/_request_builders_py3.py new file mode 100644 index 00000000000..dc41b15b5da --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_rest/files/_request_builders_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 Any + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_file_request(**kwargs: Any) -> HttpRequest: + """Get file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", "/files/stream/nonempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_file_large_request(**kwargs: Any) -> HttpRequest: + """Get a large file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", "/files/stream/verylarge") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_file_request(**kwargs: Any) -> HttpRequest: + """Get empty file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", "/files/stream/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_auto_rest_swagger_bat_file_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_auto_rest_swagger_bat_file_service.py new file mode 100644 index 00000000000..b850fe7648a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_auto_rest_swagger_bat_file_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATFileServiceConfiguration +from .operations import FilesOperations + + +class AutoRestSwaggerBATFileService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar files: FilesOperations operations + :vartype files: bodyfile.aio.operations.FilesOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFileServiceConfiguration(**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.files = FilesOperations(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. + + We have helper methods to create requests specific to this service in `bodyfile.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyfile._rest import files + >>> request = files.build_get_file_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATFileService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py new file mode 100644 index 00000000000..8d13a853241 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/aio/operations/_files_operations.py @@ -0,0 +1,162 @@ +# 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, IO, 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 ... import models as _models +from ..._rest import files as rest_files + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FilesOperations: + """FilesOperations 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: ~bodyfile.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 get_file(self, **kwargs: Any) -> IO: + """Get file. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_files.build_get_file_request( + template_url=self.get_file.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=True, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_file.metadata = {"url": "/files/stream/nonempty"} # type: ignore + + @distributed_trace_async + async def get_file_large(self, **kwargs: Any) -> IO: + """Get a large file. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_files.build_get_file_large_request( + template_url=self.get_file_large.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=True, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_file_large.metadata = {"url": "/files/stream/verylarge"} # type: ignore + + @distributed_trace_async + async def get_empty_file(self, **kwargs: Any) -> IO: + """Get empty file. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_files.build_get_empty_file_request( + template_url=self.get_empty_file.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=True, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_file.metadata = {"url": "/files/stream/empty"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFile/bodyfile/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py new file mode 100644 index 00000000000..a2ebd70c5d4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/operations/_files_operations.py @@ -0,0 +1,169 @@ +# 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 .. import models as _models +from .._rest import files as rest_files + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class FilesOperations(object): + """FilesOperations 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: ~bodyfile.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 get_file( + self, **kwargs # type: Any + ): + # type: (...) -> IO + """Get file. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_files.build_get_file_request( + template_url=self.get_file.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=True, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_file.metadata = {"url": "/files/stream/nonempty"} # type: ignore + + @distributed_trace + def get_file_large( + self, **kwargs # type: Any + ): + # type: (...) -> IO + """Get a large file. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_files.build_get_file_large_request( + template_url=self.get_file_large.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=True, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_file_large.metadata = {"url": "/files/stream/verylarge"} # type: ignore + + @distributed_trace + def get_empty_file( + self, **kwargs # type: Any + ): + # type: (...) -> IO + """Get empty file. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_files.build_get_empty_file_request( + template_url=self.get_empty_file.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=True, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_file.metadata = {"url": "/files/stream/empty"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/setup.py new file mode 100644 index 00000000000..3a578b11e3f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/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 = "autorestswaggerbatfileservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATFileService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATFileService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_auto_rest_swagger_bat_form_data_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_auto_rest_swagger_bat_form_data_service.py new file mode 100644 index 00000000000..a0df3583fd5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_auto_rest_swagger_bat_form_data_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATFormDataServiceConfiguration +from .operations import FormdataOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATFormDataService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar formdata: FormdataOperations operations + :vartype formdata: bodyformdata.operations.FormdataOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFormDataServiceConfiguration(**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.formdata = FormdataOperations(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. + + We have helper methods to create requests specific to this service in `bodyformdata.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyformdata._rest import formdata + >>> request = formdata.build_upload_file_request(files=files, 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 + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATFormDataService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_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/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/__init__.py new file mode 100644 index 00000000000..f7d990f66f0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/__init__.py @@ -0,0 +1,22 @@ +# 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_upload_file_request + from ._request_builders_py3 import build_upload_file_via_body_request + from ._request_builders_py3 import build_upload_files_request +except (SyntaxError, ImportError): + from ._request_builders import build_upload_file_request # type: ignore + from ._request_builders import build_upload_file_via_body_request # type: ignore + from ._request_builders import build_upload_files_request # type: ignore + +__all__ = [ + "build_upload_file_request", + "build_upload_file_via_body_request", + "build_upload_files_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/_request_builders.py new file mode 100644 index 00000000000..abb860e3aee --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/_request_builders.py @@ -0,0 +1,144 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, IO, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_upload_file_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", '/formdata/stream/uploadfile') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_upload_file_via_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", '/formdata/stream/uploadfile') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_upload_files_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Upload multiple files. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", '/formdata/stream/uploadfiles') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/_request_builders_py3.py new file mode 100644 index 00000000000..ea4aa1c0f53 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_rest/formdata/_request_builders_py3.py @@ -0,0 +1,123 @@ +# 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, IO, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_upload_file_request( + *, files: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", "/formdata/stream/uploadfile") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, headers=header_parameters, files=files, data=data, content=content, **kwargs + ) + + +def build_upload_file_via_body_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", "/formdata/stream/uploadfile") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_upload_files_request( + *, files: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Upload multiple files. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", "/formdata/stream/uploadfiles") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, headers=header_parameters, files=files, data=data, content=content, **kwargs + ) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_auto_rest_swagger_bat_form_data_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_auto_rest_swagger_bat_form_data_service.py new file mode 100644 index 00000000000..2e53fcb2a17 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_auto_rest_swagger_bat_form_data_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATFormDataServiceConfiguration +from .operations import FormdataOperations + + +class AutoRestSwaggerBATFormDataService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar formdata: FormdataOperations operations + :vartype formdata: bodyformdata.aio.operations.FormdataOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFormDataServiceConfiguration(**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.formdata = FormdataOperations(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. + + We have helper methods to create requests specific to this service in `bodyformdata.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyformdata._rest import formdata + >>> request = formdata.build_upload_file_request(files=files, 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 + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATFormDataService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/__init__.py 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 new file mode 100644 index 00000000000..5b0a7feef8b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py @@ -0,0 +1,198 @@ +# 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, IO, List, 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 ... import models as _models +from ..._rest import formdata as rest_formdata + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FormdataOperations: + """FormdataOperations 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: ~bodyformdata.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 upload_file(self, file_content: IO, file_name: str, **kwargs: Any) -> IO: + """Upload file. + + :param file_content: File to upload. + :type file_content: IO + :param file_name: File name to upload. Name has to be spelled exactly as written here. + :type file_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + files = None + data = None + # Construct form data + files = { + "fileContent": file_content, + "fileName": file_name, + } + + request = rest_formdata.build_upload_file_request( + content_type=content_type, + files=files, + data=data, + template_url=self.upload_file.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=True, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_file.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore + + @distributed_trace_async + async def upload_file_via_body(self, file_content: IO, **kwargs: Any) -> IO: + """Upload file. + + :param file_content: File to upload. + :type file_content: IO + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/octet-stream") # type: Optional[str] + + content = file_content + + request = rest_formdata.build_upload_file_via_body_request( + content_type=content_type, + content=content, + template_url=self.upload_file_via_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=True, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_file_via_body.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore + + @distributed_trace_async + async def upload_files(self, file_content: List[IO], **kwargs: Any) -> IO: + """Upload multiple files. + + :param file_content: Files to upload. + :type file_content: list[IO] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + files = None + data = None + # Construct form data + files = { + "fileContent": file_content, + } + + request = rest_formdata.build_upload_files_request( + content_type=content_type, + files=files, + data=data, + template_url=self.upload_files.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=True, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_files.metadata = {"url": "/formdata/stream/uploadfiles"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/__init__.py 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 new file mode 100644 index 00000000000..2d7de9e49e6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py @@ -0,0 +1,212 @@ +# 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 .. import models as _models +from .._rest import formdata as rest_formdata + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class FormdataOperations(object): + """FormdataOperations 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: ~bodyformdata.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 upload_file( + self, + file_content, # type: IO + file_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> IO + """Upload file. + + :param file_content: File to upload. + :type file_content: IO + :param file_name: File name to upload. Name has to be spelled exactly as written here. + :type file_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + files = None + data = None + # Construct form data + files = { + "fileContent": file_content, + "fileName": file_name, + } + + request = rest_formdata.build_upload_file_request( + content_type=content_type, + files=files, + data=data, + template_url=self.upload_file.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=True, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_file.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore + + @distributed_trace + def upload_file_via_body( + self, + file_content, # type: IO + **kwargs # type: Any + ): + # type: (...) -> IO + """Upload file. + + :param file_content: File to upload. + :type file_content: IO + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/octet-stream") # type: Optional[str] + + content = file_content + + request = rest_formdata.build_upload_file_via_body_request( + content_type=content_type, + content=content, + template_url=self.upload_file_via_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=True, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_file_via_body.metadata = {"url": "/formdata/stream/uploadfile"} # type: ignore + + @distributed_trace + def upload_files( + self, + file_content, # type: List[IO] + **kwargs # type: Any + ): + # type: (...) -> IO + """Upload multiple files. + + :param file_content: Files to upload. + :type file_content: list[IO] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[IO] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + files = None + data = None + # Construct form data + files = { + "fileContent": file_content, + } + + request = rest_formdata.build_upload_files_request( + content_type=content_type, + files=files, + data=data, + template_url=self.upload_files.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=True, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_files.metadata = {"url": "/formdata/stream/uploadfiles"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/setup.py new file mode 100644 index 00000000000..9174ce8304d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/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 = "autorestswaggerbatformdataservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATFormDataService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATFormDataService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_auto_rest_integer_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_auto_rest_integer_test_service.py new file mode 100644 index 00000000000..c932089f51f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_auto_rest_integer_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestIntegerTestServiceConfiguration +from .operations import IntOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestIntegerTestService(object): + """Test Infrastructure for AutoRest. + + :ivar int: IntOperations operations + :vartype int: bodyinteger.operations.IntOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestIntegerTestServiceConfiguration(**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.int = IntOperations(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. + + We have helper methods to create requests specific to this service in `bodyinteger.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyinteger._rest import int + >>> request = int.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestIntegerTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_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/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/__init__.py new file mode 100644 index 00000000000..9ef9986b288 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/__init__.py @@ -0,0 +1,55 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_overflow_int32_request + from ._request_builders_py3 import build_get_underflow_int32_request + from ._request_builders_py3 import build_get_overflow_int64_request + from ._request_builders_py3 import build_get_underflow_int64_request + from ._request_builders_py3 import build_put_max32_request + from ._request_builders_py3 import build_put_max64_request + from ._request_builders_py3 import build_put_min32_request + from ._request_builders_py3 import build_put_min64_request + from ._request_builders_py3 import build_get_unix_time_request + from ._request_builders_py3 import build_put_unix_time_date_request + from ._request_builders_py3 import build_get_invalid_unix_time_request + from ._request_builders_py3 import build_get_null_unix_time_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_overflow_int32_request # type: ignore + from ._request_builders import build_get_underflow_int32_request # type: ignore + from ._request_builders import build_get_overflow_int64_request # type: ignore + from ._request_builders import build_get_underflow_int64_request # type: ignore + from ._request_builders import build_put_max32_request # type: ignore + from ._request_builders import build_put_max64_request # type: ignore + from ._request_builders import build_put_min32_request # type: ignore + from ._request_builders import build_put_min64_request # type: ignore + from ._request_builders import build_get_unix_time_request # type: ignore + from ._request_builders import build_put_unix_time_date_request # type: ignore + from ._request_builders import build_get_invalid_unix_time_request # type: ignore + from ._request_builders import build_get_null_unix_time_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_overflow_int32_request", + "build_get_underflow_int32_request", + "build_get_overflow_int64_request", + "build_get_underflow_int64_request", + "build_put_max32_request", + "build_put_max64_request", + "build_put_min32_request", + "build_put_min64_request", + "build_get_unix_time_request", + "build_put_unix_time_date_request", + "build_get_invalid_unix_time_request", + "build_get_null_unix_time_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/_request_builders.py new file mode 100644 index 00000000000..c71b399e614 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/_request_builders.py @@ -0,0 +1,503 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_int32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/overflowint32') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_int32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/underflowint32') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_int64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/overflowint64') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_int64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/underflowint64') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_max32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/max/32') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_max64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/max/64') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_min32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/min/32') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_min64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/min/64') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_unix_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get datetime encoded as Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/unixtime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_unix_time_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put datetime encoded as Unix time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/unixtime') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_unix_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/invalidunixtime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_unix_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/nullunixtime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/_request_builders_py3.py new file mode 100644 index 00000000000..54d46c69c7a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_rest/int/_request_builders_py3.py @@ -0,0 +1,386 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_int32_request(**kwargs: Any) -> HttpRequest: + """Get overflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/overflowint32") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_int32_request(**kwargs: Any) -> HttpRequest: + """Get underflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/underflowint32") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_int64_request(**kwargs: Any) -> HttpRequest: + """Get overflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/overflowint64") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_int64_request(**kwargs: Any) -> HttpRequest: + """Get underflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/underflowint64") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_max32_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/max/32") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_max64_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/max/64") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_min32_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/min/32") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_min64_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/min/64") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_unix_time_request(**kwargs: Any) -> HttpRequest: + """Get datetime encoded as Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/unixtime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_unix_time_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put datetime encoded as Unix time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/unixtime") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_invalid_unix_time_request(**kwargs: Any) -> HttpRequest: + """Get invalid Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/invalidunixtime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_unix_time_request(**kwargs: Any) -> HttpRequest: + """Get null Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/nullunixtime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_auto_rest_integer_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_auto_rest_integer_test_service.py new file mode 100644 index 00000000000..417cf0ef783 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_auto_rest_integer_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestIntegerTestServiceConfiguration +from .operations import IntOperations + + +class AutoRestIntegerTestService: + """Test Infrastructure for AutoRest. + + :ivar int: IntOperations operations + :vartype int: bodyinteger.aio.operations.IntOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestIntegerTestServiceConfiguration(**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.int = IntOperations(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. + + We have helper methods to create requests specific to this service in `bodyinteger.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyinteger._rest import int + >>> request = int.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestIntegerTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py new file mode 100644 index 00000000000..0db05b5816d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py @@ -0,0 +1,585 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import int as rest_int + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IntOperations: + """IntOperations 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: ~bodyinteger.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 get_null(self, **kwargs: Any) -> Optional[int]: + """Get null Int value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int or None, or the result of cls(response) + :rtype: int or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/int/null"} # type: ignore + + @distributed_trace_async + async def get_invalid(self, **kwargs: Any) -> int: + """Get invalid Int value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int, or the result of cls(response) + :rtype: int + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/int/invalid"} # type: ignore + + @distributed_trace_async + async def get_overflow_int32(self, **kwargs: Any) -> int: + """Get overflow Int32 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int, or the result of cls(response) + :rtype: int + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_overflow_int32_request( + template_url=self.get_overflow_int32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow_int32.metadata = {"url": "/int/overflowint32"} # type: ignore + + @distributed_trace_async + async def get_underflow_int32(self, **kwargs: Any) -> int: + """Get underflow Int32 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int, or the result of cls(response) + :rtype: int + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_underflow_int32_request( + template_url=self.get_underflow_int32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow_int32.metadata = {"url": "/int/underflowint32"} # type: ignore + + @distributed_trace_async + async def get_overflow_int64(self, **kwargs: Any) -> int: + """Get overflow Int64 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: long, or the result of cls(response) + :rtype: long + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_overflow_int64_request( + template_url=self.get_overflow_int64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("long", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow_int64.metadata = {"url": "/int/overflowint64"} # type: ignore + + @distributed_trace_async + async def get_underflow_int64(self, **kwargs: Any) -> int: + """Get underflow Int64 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: long, or the result of cls(response) + :rtype: long + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_underflow_int64_request( + template_url=self.get_underflow_int64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("long", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow_int64.metadata = {"url": "/int/underflowint64"} # type: ignore + + @distributed_trace_async + async def put_max32(self, int_body: int, **kwargs: Any) -> None: + """Put max int32 value. + + :param int_body: int body. + :type int_body: int + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "int") + + request = rest_int.build_put_max32_request( + content_type=content_type, + json=json, + template_url=self.put_max32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_max32.metadata = {"url": "/int/max/32"} # type: ignore + + @distributed_trace_async + async def put_max64(self, int_body: int, **kwargs: Any) -> None: + """Put max int64 value. + + :param int_body: int body. + :type int_body: long + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "long") + + request = rest_int.build_put_max64_request( + content_type=content_type, + json=json, + template_url=self.put_max64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_max64.metadata = {"url": "/int/max/64"} # type: ignore + + @distributed_trace_async + async def put_min32(self, int_body: int, **kwargs: Any) -> None: + """Put min int32 value. + + :param int_body: int body. + :type int_body: int + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "int") + + request = rest_int.build_put_min32_request( + content_type=content_type, + json=json, + template_url=self.put_min32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_min32.metadata = {"url": "/int/min/32"} # type: ignore + + @distributed_trace_async + async def put_min64(self, int_body: int, **kwargs: Any) -> None: + """Put min int64 value. + + :param int_body: int body. + :type int_body: long + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "long") + + request = rest_int.build_put_min64_request( + content_type=content_type, + json=json, + template_url=self.put_min64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_min64.metadata = {"url": "/int/min/64"} # type: ignore + + @distributed_trace_async + async def get_unix_time(self, **kwargs: Any) -> datetime.datetime: + """Get datetime encoded as Unix time value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_unix_time_request( + template_url=self.get_unix_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("unix-time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_unix_time.metadata = {"url": "/int/unixtime"} # type: ignore + + @distributed_trace_async + async def put_unix_time_date(self, int_body: datetime.datetime, **kwargs: Any) -> None: + """Put datetime encoded as Unix time. + + :param int_body: int body. + :type int_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "unix-time") + + request = rest_int.build_put_unix_time_date_request( + content_type=content_type, + json=json, + template_url=self.put_unix_time_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_unix_time_date.metadata = {"url": "/int/unixtime"} # type: ignore + + @distributed_trace_async + async def get_invalid_unix_time(self, **kwargs: Any) -> datetime.datetime: + """Get invalid Unix time value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_invalid_unix_time_request( + template_url=self.get_invalid_unix_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("unix-time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_unix_time.metadata = {"url": "/int/invalidunixtime"} # type: ignore + + @distributed_trace_async + async def get_null_unix_time(self, **kwargs: Any) -> Optional[datetime.datetime]: + """Get null Unix time value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_null_unix_time_request( + template_url=self.get_null_unix_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("unix-time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_unix_time.metadata = {"url": "/int/nullunixtime"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py new file mode 100644 index 00000000000..8be9123773f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py @@ -0,0 +1,613 @@ +# 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 datetime +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 .. import models as _models +from .._rest import int as rest_int + +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]] + + +class IntOperations(object): + """IntOperations 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: ~bodyinteger.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[int] + """Get null Int value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int or None, or the result of cls(response) + :rtype: int or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/int/null"} # type: ignore + + @distributed_trace + def get_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> int + """Get invalid Int value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int, or the result of cls(response) + :rtype: int + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_invalid_request( + template_url=self.get_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid.metadata = {"url": "/int/invalid"} # type: ignore + + @distributed_trace + def get_overflow_int32( + self, **kwargs # type: Any + ): + # type: (...) -> int + """Get overflow Int32 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int, or the result of cls(response) + :rtype: int + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_overflow_int32_request( + template_url=self.get_overflow_int32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow_int32.metadata = {"url": "/int/overflowint32"} # type: ignore + + @distributed_trace + def get_underflow_int32( + self, **kwargs # type: Any + ): + # type: (...) -> int + """Get underflow Int32 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: int, or the result of cls(response) + :rtype: int + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_underflow_int32_request( + template_url=self.get_underflow_int32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow_int32.metadata = {"url": "/int/underflowint32"} # type: ignore + + @distributed_trace + def get_overflow_int64( + self, **kwargs # type: Any + ): + # type: (...) -> int + """Get overflow Int64 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: long, or the result of cls(response) + :rtype: long + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_overflow_int64_request( + template_url=self.get_overflow_int64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("long", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_overflow_int64.metadata = {"url": "/int/overflowint64"} # type: ignore + + @distributed_trace + def get_underflow_int64( + self, **kwargs # type: Any + ): + # type: (...) -> int + """Get underflow Int64 value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: long, or the result of cls(response) + :rtype: long + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[int] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_underflow_int64_request( + template_url=self.get_underflow_int64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("long", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_underflow_int64.metadata = {"url": "/int/underflowint64"} # type: ignore + + @distributed_trace + def put_max32( + self, + int_body, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Put max int32 value. + + :param int_body: int body. + :type int_body: int + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "int") + + request = rest_int.build_put_max32_request( + content_type=content_type, + json=json, + template_url=self.put_max32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_max32.metadata = {"url": "/int/max/32"} # type: ignore + + @distributed_trace + def put_max64( + self, + int_body, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Put max int64 value. + + :param int_body: int body. + :type int_body: long + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "long") + + request = rest_int.build_put_max64_request( + content_type=content_type, + json=json, + template_url=self.put_max64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_max64.metadata = {"url": "/int/max/64"} # type: ignore + + @distributed_trace + def put_min32( + self, + int_body, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Put min int32 value. + + :param int_body: int body. + :type int_body: int + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "int") + + request = rest_int.build_put_min32_request( + content_type=content_type, + json=json, + template_url=self.put_min32.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_min32.metadata = {"url": "/int/min/32"} # type: ignore + + @distributed_trace + def put_min64( + self, + int_body, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Put min int64 value. + + :param int_body: int body. + :type int_body: long + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "long") + + request = rest_int.build_put_min64_request( + content_type=content_type, + json=json, + template_url=self.put_min64.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_min64.metadata = {"url": "/int/min/64"} # type: ignore + + @distributed_trace + def get_unix_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get datetime encoded as Unix time value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_unix_time_request( + template_url=self.get_unix_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("unix-time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_unix_time.metadata = {"url": "/int/unixtime"} # type: ignore + + @distributed_trace + def put_unix_time_date( + self, + int_body, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Put datetime encoded as Unix time. + + :param int_body: int body. + :type int_body: ~datetime.datetime + :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/json") # type: Optional[str] + + json = self._serialize.body(int_body, "unix-time") + + request = rest_int.build_put_unix_time_date_request( + content_type=content_type, + json=json, + template_url=self.put_unix_time_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_unix_time_date.metadata = {"url": "/int/unixtime"} # type: ignore + + @distributed_trace + def get_invalid_unix_time( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.datetime + """Get invalid Unix time value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime, or the result of cls(response) + :rtype: ~datetime.datetime + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.datetime] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_invalid_unix_time_request( + template_url=self.get_invalid_unix_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("unix-time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_unix_time.metadata = {"url": "/int/invalidunixtime"} # type: ignore + + @distributed_trace + def get_null_unix_time( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[datetime.datetime] + """Get null Unix time value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[datetime.datetime]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_null_unix_time_request( + template_url=self.get_null_unix_time.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("unix-time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_unix_time.metadata = {"url": "/int/nullunixtime"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/setup.py new file mode 100644 index 00000000000..770bf745d71 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/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 = "autorestintegertestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestIntegerTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestIntegerTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_auto_rest_number_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_auto_rest_number_test_service.py new file mode 100644 index 00000000000..1ba7db404bb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_auto_rest_number_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestNumberTestServiceConfiguration +from .operations import NumberOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestNumberTestService(object): + """Test Infrastructure for AutoRest. + + :ivar number: NumberOperations operations + :vartype number: bodynumber.operations.NumberOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestNumberTestServiceConfiguration(**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.number = NumberOperations(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. + + We have helper methods to create requests specific to this service in `bodynumber.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodynumber._rest import number + >>> request = number.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestNumberTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_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/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/__init__.py new file mode 100644 index 00000000000..cce808da949 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_invalid_float_request + from ._request_builders_py3 import build_get_invalid_double_request + from ._request_builders_py3 import build_get_invalid_decimal_request + from ._request_builders_py3 import build_put_big_float_request + from ._request_builders_py3 import build_get_big_float_request + from ._request_builders_py3 import build_put_big_double_request + from ._request_builders_py3 import build_get_big_double_request + from ._request_builders_py3 import build_put_big_double_positive_decimal_request + from ._request_builders_py3 import build_get_big_double_positive_decimal_request + from ._request_builders_py3 import build_put_big_double_negative_decimal_request + from ._request_builders_py3 import build_get_big_double_negative_decimal_request + from ._request_builders_py3 import build_put_big_decimal_request + from ._request_builders_py3 import build_get_big_decimal_request + from ._request_builders_py3 import build_put_big_decimal_positive_decimal_request + from ._request_builders_py3 import build_get_big_decimal_positive_decimal_request + from ._request_builders_py3 import build_put_big_decimal_negative_decimal_request + from ._request_builders_py3 import build_get_big_decimal_negative_decimal_request + from ._request_builders_py3 import build_put_small_float_request + from ._request_builders_py3 import build_get_small_float_request + from ._request_builders_py3 import build_put_small_double_request + from ._request_builders_py3 import build_get_small_double_request + from ._request_builders_py3 import build_put_small_decimal_request + from ._request_builders_py3 import build_get_small_decimal_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_float_request # type: ignore + from ._request_builders import build_get_invalid_double_request # type: ignore + from ._request_builders import build_get_invalid_decimal_request # type: ignore + from ._request_builders import build_put_big_float_request # type: ignore + from ._request_builders import build_get_big_float_request # type: ignore + from ._request_builders import build_put_big_double_request # type: ignore + from ._request_builders import build_get_big_double_request # type: ignore + from ._request_builders import build_put_big_double_positive_decimal_request # type: ignore + from ._request_builders import build_get_big_double_positive_decimal_request # type: ignore + from ._request_builders import build_put_big_double_negative_decimal_request # type: ignore + from ._request_builders import build_get_big_double_negative_decimal_request # type: ignore + from ._request_builders import build_put_big_decimal_request # type: ignore + from ._request_builders import build_get_big_decimal_request # type: ignore + from ._request_builders import build_put_big_decimal_positive_decimal_request # type: ignore + from ._request_builders import build_get_big_decimal_positive_decimal_request # type: ignore + from ._request_builders import build_put_big_decimal_negative_decimal_request # type: ignore + from ._request_builders import build_get_big_decimal_negative_decimal_request # type: ignore + from ._request_builders import build_put_small_float_request # type: ignore + from ._request_builders import build_get_small_float_request # type: ignore + from ._request_builders import build_put_small_double_request # type: ignore + from ._request_builders import build_get_small_double_request # type: ignore + from ._request_builders import build_put_small_decimal_request # type: ignore + from ._request_builders import build_get_small_decimal_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_float_request", + "build_get_invalid_double_request", + "build_get_invalid_decimal_request", + "build_put_big_float_request", + "build_get_big_float_request", + "build_put_big_double_request", + "build_get_big_double_request", + "build_put_big_double_positive_decimal_request", + "build_get_big_double_positive_decimal_request", + "build_put_big_double_negative_decimal_request", + "build_get_big_double_negative_decimal_request", + "build_put_big_decimal_request", + "build_get_big_decimal_request", + "build_put_big_decimal_positive_decimal_request", + "build_get_big_decimal_positive_decimal_request", + "build_put_big_decimal_negative_decimal_request", + "build_get_big_decimal_negative_decimal_request", + "build_put_small_float_request", + "build_get_small_float_request", + "build_put_small_double_request", + "build_get_small_double_request", + "build_put_small_decimal_request", + "build_get_small_decimal_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/_request_builders.py new file mode 100644 index 00000000000..2c7795a19ee --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/_request_builders.py @@ -0,0 +1,862 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid float Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/invalidfloat') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid double Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/invaliddouble') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid decimal Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/invaliddecimal') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/float/3.402823e+20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/float/3.402823e+20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/2.5976931e+101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/2.5976931e+101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_double_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_double_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_double_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/-99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_double_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/-99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/2.5976931e+101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/2.5976931e+101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_decimal_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_decimal_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_decimal_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/-99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_decimal_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/-99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_small_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put small float value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/float/3.402823e-20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_small_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/float/3.402823e-20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_small_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put small double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/double/2.5976931e-101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_small_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/double/2.5976931e-101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_small_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/decimal/2.5976931e-101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_small_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/decimal/2.5976931e-101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/_request_builders_py3.py new file mode 100644 index 00000000000..98531bc05e4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_rest/number/_request_builders_py3.py @@ -0,0 +1,673 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_float_request(**kwargs: Any) -> HttpRequest: + """Get invalid float Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/invalidfloat") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_double_request(**kwargs: Any) -> HttpRequest: + """Get invalid double Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/invaliddouble") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_decimal_request(**kwargs: Any) -> HttpRequest: + """Get invalid decimal Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/invaliddecimal") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_float_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/float/3.402823e+20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_float_request(**kwargs: Any) -> HttpRequest: + """Get big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/float/3.402823e+20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_double_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/2.5976931e+101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_double_request(**kwargs: Any) -> HttpRequest: + """Get big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/2.5976931e+101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_double_positive_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_double_positive_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_double_negative_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/-99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_double_negative_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/-99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_decimal_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/2.5976931e+101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/2.5976931e+101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_decimal_positive_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_decimal_positive_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_decimal_negative_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/-99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_decimal_negative_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/-99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_small_float_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put small float value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/float/3.402823e-20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_small_float_request(**kwargs: Any) -> HttpRequest: + """Get big double value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/float/3.402823e-20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_small_double_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put small double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/double/2.5976931e-101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_small_double_request(**kwargs: Any) -> HttpRequest: + """Get big double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/double/2.5976931e-101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_small_decimal_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/decimal/2.5976931e-101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_small_decimal_request(**kwargs: Any) -> HttpRequest: + """Get small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/decimal/2.5976931e-101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_auto_rest_number_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_auto_rest_number_test_service.py new file mode 100644 index 00000000000..3a9d77c41e4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_auto_rest_number_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestNumberTestServiceConfiguration +from .operations import NumberOperations + + +class AutoRestNumberTestService: + """Test Infrastructure for AutoRest. + + :ivar number: NumberOperations operations + :vartype number: bodynumber.aio.operations.NumberOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestNumberTestServiceConfiguration(**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.number = NumberOperations(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. + + We have helper methods to create requests specific to this service in `bodynumber.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodynumber._rest import number + >>> request = number.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestNumberTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py new file mode 100644 index 00000000000..e68cf7c4d81 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py @@ -0,0 +1,965 @@ +# 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 ... import models as _models +from ..._rest import number as rest_number + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class NumberOperations: + """NumberOperations 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: ~bodynumber.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 get_null(self, **kwargs: Any) -> Optional[float]: + """Get null Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float or None, or the result of cls(response) + :rtype: float or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/number/null"} # type: ignore + + @distributed_trace_async + async def get_invalid_float(self, **kwargs: Any) -> float: + """Get invalid float Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_invalid_float_request( + template_url=self.get_invalid_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_float.metadata = {"url": "/number/invalidfloat"} # type: ignore + + @distributed_trace_async + async def get_invalid_double(self, **kwargs: Any) -> float: + """Get invalid double Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_invalid_double_request( + template_url=self.get_invalid_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_double.metadata = {"url": "/number/invaliddouble"} # type: ignore + + @distributed_trace_async + async def get_invalid_decimal(self, **kwargs: Any) -> float: + """Get invalid decimal Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_invalid_decimal_request( + template_url=self.get_invalid_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_decimal.metadata = {"url": "/number/invaliddecimal"} # type: ignore + + @distributed_trace_async + async def put_big_float(self, number_body: float, **kwargs: Any) -> None: + """Put big float value 3.402823e+20. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_float_request( + content_type=content_type, + json=json, + template_url=self.put_big_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore + + @distributed_trace_async + async def get_big_float(self, **kwargs: Any) -> float: + """Get big float value 3.402823e+20. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_float_request( + template_url=self.get_big_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore + + @distributed_trace_async + async def put_big_double(self, number_body: float, **kwargs: Any) -> None: + """Put big double value 2.5976931e+101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_double_request( + content_type=content_type, + json=json, + template_url=self.put_big_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore + + @distributed_trace_async + async def get_big_double(self, **kwargs: Any) -> float: + """Get big double value 2.5976931e+101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_double_request( + template_url=self.get_big_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore + + @distributed_trace_async + async def put_big_double_positive_decimal(self, **kwargs: Any) -> None: + """Put big double value 99999999.99. + + :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/json") # type: Optional[str] + + number_body = 99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_double_positive_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_double_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore + + @distributed_trace_async + async def get_big_double_positive_decimal(self, **kwargs: Any) -> float: + """Get big double value 99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_double_positive_decimal_request( + template_url=self.get_big_double_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore + + @distributed_trace_async + async def put_big_double_negative_decimal(self, **kwargs: Any) -> None: + """Put big double value -99999999.99. + + :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/json") # type: Optional[str] + + number_body = -99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_double_negative_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_double_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore + + @distributed_trace_async + async def get_big_double_negative_decimal(self, **kwargs: Any) -> float: + """Get big double value -99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_double_negative_decimal_request( + template_url=self.get_big_double_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore + + @distributed_trace_async + async def put_big_decimal(self, number_body: float, **kwargs: Any) -> None: + """Put big decimal value 2.5976931e+101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore + + @distributed_trace_async + async def get_big_decimal(self, **kwargs: Any) -> float: + """Get big decimal value 2.5976931e+101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_decimal_request( + template_url=self.get_big_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore + + @distributed_trace_async + async def put_big_decimal_positive_decimal(self, **kwargs: Any) -> None: + """Put big decimal value 99999999.99. + + :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/json") # type: Optional[str] + + number_body = 99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_decimal_positive_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_decimal_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore + + @distributed_trace_async + async def get_big_decimal_positive_decimal(self, **kwargs: Any) -> float: + """Get big decimal value 99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_decimal_positive_decimal_request( + template_url=self.get_big_decimal_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore + + @distributed_trace_async + async def put_big_decimal_negative_decimal(self, **kwargs: Any) -> None: + """Put big decimal value -99999999.99. + + :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/json") # type: Optional[str] + + number_body = -99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_decimal_negative_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_decimal_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore + + @distributed_trace_async + async def get_big_decimal_negative_decimal(self, **kwargs: Any) -> float: + """Get big decimal value -99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_decimal_negative_decimal_request( + template_url=self.get_big_decimal_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore + + @distributed_trace_async + async def put_small_float(self, number_body: float, **kwargs: Any) -> None: + """Put small float value 3.402823e-20. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_small_float_request( + content_type=content_type, + json=json, + template_url=self.put_small_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore + + @distributed_trace_async + async def get_small_float(self, **kwargs: Any) -> float: + """Get big double value 3.402823e-20. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_small_float_request( + template_url=self.get_small_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore + + @distributed_trace_async + async def put_small_double(self, number_body: float, **kwargs: Any) -> None: + """Put small double value 2.5976931e-101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_small_double_request( + content_type=content_type, + json=json, + template_url=self.put_small_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore + + @distributed_trace_async + async def get_small_double(self, **kwargs: Any) -> float: + """Get big double value 2.5976931e-101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_small_double_request( + template_url=self.get_small_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore + + @distributed_trace_async + async def put_small_decimal(self, number_body: float, **kwargs: Any) -> None: + """Put small decimal value 2.5976931e-101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_small_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_small_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore + + @distributed_trace_async + async def get_small_decimal(self, **kwargs: Any) -> float: + """Get small decimal value 2.5976931e-101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_small_decimal_request( + template_url=self.get_small_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py new file mode 100644 index 00000000000..bdd74a56226 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py @@ -0,0 +1,1005 @@ +# 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 .. import models as _models +from .._rest import number as rest_number + +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]] + + +class NumberOperations(object): + """NumberOperations 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: ~bodynumber.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[float] + """Get null Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float or None, or the result of cls(response) + :rtype: float or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[float]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/number/null"} # type: ignore + + @distributed_trace + def get_invalid_float( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get invalid float Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_invalid_float_request( + template_url=self.get_invalid_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_float.metadata = {"url": "/number/invalidfloat"} # type: ignore + + @distributed_trace + def get_invalid_double( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get invalid double Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_invalid_double_request( + template_url=self.get_invalid_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_double.metadata = {"url": "/number/invaliddouble"} # type: ignore + + @distributed_trace + def get_invalid_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get invalid decimal Number value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_invalid_decimal_request( + template_url=self.get_invalid_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_invalid_decimal.metadata = {"url": "/number/invaliddecimal"} # type: ignore + + @distributed_trace + def put_big_float( + self, + number_body, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Put big float value 3.402823e+20. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_float_request( + content_type=content_type, + json=json, + template_url=self.put_big_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore + + @distributed_trace + def get_big_float( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big float value 3.402823e+20. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_float_request( + template_url=self.get_big_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_float.metadata = {"url": "/number/big/float/3.402823e+20"} # type: ignore + + @distributed_trace + def put_big_double( + self, + number_body, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Put big double value 2.5976931e+101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_double_request( + content_type=content_type, + json=json, + template_url=self.put_big_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore + + @distributed_trace + def get_big_double( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big double value 2.5976931e+101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_double_request( + template_url=self.get_big_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_double.metadata = {"url": "/number/big/double/2.5976931e+101"} # type: ignore + + @distributed_trace + def put_big_double_positive_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Put big double value 99999999.99. + + :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/json") # type: Optional[str] + + number_body = 99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_double_positive_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_double_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore + + @distributed_trace + def get_big_double_positive_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big double value 99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_double_positive_decimal_request( + template_url=self.get_big_double_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_double_positive_decimal.metadata = {"url": "/number/big/double/99999999.99"} # type: ignore + + @distributed_trace + def put_big_double_negative_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Put big double value -99999999.99. + + :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/json") # type: Optional[str] + + number_body = -99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_double_negative_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_double_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore + + @distributed_trace + def get_big_double_negative_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big double value -99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_double_negative_decimal_request( + template_url=self.get_big_double_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_double_negative_decimal.metadata = {"url": "/number/big/double/-99999999.99"} # type: ignore + + @distributed_trace + def put_big_decimal( + self, + number_body, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Put big decimal value 2.5976931e+101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore + + @distributed_trace + def get_big_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big decimal value 2.5976931e+101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_decimal_request( + template_url=self.get_big_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_decimal.metadata = {"url": "/number/big/decimal/2.5976931e+101"} # type: ignore + + @distributed_trace + def put_big_decimal_positive_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Put big decimal value 99999999.99. + + :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/json") # type: Optional[str] + + number_body = 99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_decimal_positive_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_decimal_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore + + @distributed_trace + def get_big_decimal_positive_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big decimal value 99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_decimal_positive_decimal_request( + template_url=self.get_big_decimal_positive_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_decimal_positive_decimal.metadata = {"url": "/number/big/decimal/99999999.99"} # type: ignore + + @distributed_trace + def put_big_decimal_negative_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Put big decimal value -99999999.99. + + :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/json") # type: Optional[str] + + number_body = -99999999.99 + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_big_decimal_negative_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_big_decimal_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore + + @distributed_trace + def get_big_decimal_negative_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big decimal value -99999999.99. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_big_decimal_negative_decimal_request( + template_url=self.get_big_decimal_negative_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_big_decimal_negative_decimal.metadata = {"url": "/number/big/decimal/-99999999.99"} # type: ignore + + @distributed_trace + def put_small_float( + self, + number_body, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Put small float value 3.402823e-20. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_small_float_request( + content_type=content_type, + json=json, + template_url=self.put_small_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore + + @distributed_trace + def get_small_float( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big double value 3.402823e-20. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_small_float_request( + template_url=self.get_small_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_small_float.metadata = {"url": "/number/small/float/3.402823e-20"} # type: ignore + + @distributed_trace + def put_small_double( + self, + number_body, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Put small double value 2.5976931e-101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_small_double_request( + content_type=content_type, + json=json, + template_url=self.put_small_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore + + @distributed_trace + def get_small_double( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get big double value 2.5976931e-101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_small_double_request( + template_url=self.get_small_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_small_double.metadata = {"url": "/number/small/double/2.5976931e-101"} # type: ignore + + @distributed_trace + def put_small_decimal( + self, + number_body, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Put small decimal value 2.5976931e-101. + + :param number_body: number body. + :type number_body: float + :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/json") # type: Optional[str] + + json = self._serialize.body(number_body, "float") + + request = rest_number.build_put_small_decimal_request( + content_type=content_type, + json=json, + template_url=self.put_small_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore + + @distributed_trace + def get_small_decimal( + self, **kwargs # type: Any + ): + # type: (...) -> float + """Get small decimal value 2.5976931e-101. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: float, or the result of cls(response) + :rtype: float + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[float] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_number.build_get_small_decimal_request( + template_url=self.get_small_decimal.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_small_decimal.metadata = {"url": "/number/small/decimal/2.5976931e-101"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/setup.py new file mode 100644 index 00000000000..c3cbe8a4696 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/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 = "autorestnumbertestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestNumberTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestNumberTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_auto_rest_swagger_bat_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_auto_rest_swagger_bat_service.py new file mode 100644 index 00000000000..4b5097b5bdb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_auto_rest_swagger_bat_service.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. +# -------------------------------------------------------------------------- + +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 AutoRestSwaggerBATServiceConfiguration +from .operations import EnumOperations, StringOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar string: StringOperations operations + :vartype string: bodystring.operations.StringOperations + :ivar enum: EnumOperations operations + :vartype enum: bodystring.operations.EnumOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATServiceConfiguration(**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.string = StringOperations(self._client, self._config, self._serialize, self._deserialize) + self.enum = EnumOperations(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. + + We have helper methods to create requests specific to this service in `bodystring.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodystring._rest import string + >>> request = string.build_get_null_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_patch.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_patch.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/_patch.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_patch.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_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/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/__init__.py new file mode 100644 index 00000000000..b47975af01f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/__init__.py @@ -0,0 +1,31 @@ +# 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_get_not_expandable_request + from ._request_builders_py3 import build_put_not_expandable_request + from ._request_builders_py3 import build_get_referenced_request + from ._request_builders_py3 import build_put_referenced_request + from ._request_builders_py3 import build_get_referenced_constant_request + from ._request_builders_py3 import build_put_referenced_constant_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_not_expandable_request # type: ignore + from ._request_builders import build_put_not_expandable_request # type: ignore + from ._request_builders import build_get_referenced_request # type: ignore + from ._request_builders import build_put_referenced_request # type: ignore + from ._request_builders import build_get_referenced_constant_request # type: ignore + from ._request_builders import build_put_referenced_constant_request # type: ignore + +__all__ = [ + "build_get_not_expandable_request", + "build_put_not_expandable_request", + "build_get_referenced_request", + "build_put_referenced_request", + "build_get_referenced_constant_request", + "build_put_referenced_constant_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/_request_builders.py new file mode 100644 index 00000000000..7f1de7cab65 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/_request_builders.py @@ -0,0 +1,234 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_not_expandable_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/notExpandable') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_not_expandable_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/notExpandable') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_referenced_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/Referenced') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_referenced_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/Referenced') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_referenced_constant_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get value 'green-color' from the constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/ReferencedConstant') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_referenced_constant_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Sends value 'green-color' from a constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/ReferencedConstant') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/_request_builders_py3.py new file mode 100644 index 00000000000..fdb86ff5550 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/enum/_request_builders_py3.py @@ -0,0 +1,181 @@ +# 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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_not_expandable_request(**kwargs: Any) -> HttpRequest: + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/notExpandable") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_not_expandable_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/notExpandable") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_referenced_request(**kwargs: Any) -> HttpRequest: + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/Referenced") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_referenced_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/Referenced") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_referenced_constant_request(**kwargs: Any) -> HttpRequest: + """Get value 'green-color' from the constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/ReferencedConstant") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_referenced_constant_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Sends value 'green-color' from a constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/ReferencedConstant") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/__init__.py new file mode 100644 index 00000000000..9ace38ded20 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/__init__.py @@ -0,0 +1,52 @@ +# 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_get_null_request + from ._request_builders_py3 import build_put_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_mbcs_request + from ._request_builders_py3 import build_put_mbcs_request + from ._request_builders_py3 import build_get_whitespace_request + from ._request_builders_py3 import build_put_whitespace_request + from ._request_builders_py3 import build_get_not_provided_request + from ._request_builders_py3 import build_get_base64_encoded_request + from ._request_builders_py3 import build_get_base64_url_encoded_request + from ._request_builders_py3 import build_put_base64_url_encoded_request + from ._request_builders_py3 import build_get_null_base64_url_encoded_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_put_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_mbcs_request # type: ignore + from ._request_builders import build_put_mbcs_request # type: ignore + from ._request_builders import build_get_whitespace_request # type: ignore + from ._request_builders import build_put_whitespace_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + from ._request_builders import build_get_base64_encoded_request # type: ignore + from ._request_builders import build_get_base64_url_encoded_request # type: ignore + from ._request_builders import build_put_base64_url_encoded_request # type: ignore + from ._request_builders import build_get_null_base64_url_encoded_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_put_null_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_mbcs_request", + "build_put_mbcs_request", + "build_get_whitespace_request", + "build_put_whitespace_request", + "build_get_not_provided_request", + "build_get_base64_encoded_request", + "build_get_base64_url_encoded_request", + "build_put_base64_url_encoded_request", + "build_get_null_base64_url_encoded_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/_request_builders.py new file mode 100644 index 00000000000..80dbe061ccc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/_request_builders.py @@ -0,0 +1,475 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null string value value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set string value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/null') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty string value value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set string value empty ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_mbcs_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/mbcs') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_mbcs_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/mbcs') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_whitespace_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/whitespace') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_whitespace_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set String value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/whitespace') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get String value when no string value is sent in response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/notProvided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get value that is base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/base64Encoding') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/base64UrlEncoding') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_base64_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/base64UrlEncoding') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_base64_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null value that is expected to be base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/nullBase64UrlEncoding') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/_request_builders_py3.py new file mode 100644 index 00000000000..e9d90e87803 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_rest/string/_request_builders_py3.py @@ -0,0 +1,366 @@ +# 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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null string value value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_null_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set string value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/null") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty string value value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set string value empty ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_mbcs_request(**kwargs: Any) -> HttpRequest: + """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/mbcs") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_mbcs_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/mbcs") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_whitespace_request(**kwargs: Any) -> HttpRequest: + """Get string value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/whitespace") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_whitespace_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set String value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/whitespace") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get String value when no string value is sent in response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/notProvided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_encoded_request(**kwargs: Any) -> HttpRequest: + """Get value that is base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/base64Encoding") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/base64UrlEncoding") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_base64_url_encoded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/base64UrlEncoding") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_base64_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get null value that is expected to be base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/nullBase64UrlEncoding") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/_auto_rest_swagger_bat_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/_auto_rest_swagger_bat_service.py new file mode 100644 index 00000000000..d7807218b65 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/_auto_rest_swagger_bat_service.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 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 AutoRestSwaggerBATServiceConfiguration +from .operations import EnumOperations, StringOperations + + +class AutoRestSwaggerBATService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar string: StringOperations operations + :vartype string: bodystring.aio.operations.StringOperations + :ivar enum: EnumOperations operations + :vartype enum: bodystring.aio.operations.EnumOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATServiceConfiguration(**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.string = StringOperations(self._client, self._config, self._serialize, self._deserialize) + self.enum = EnumOperations(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. + + We have helper methods to create requests specific to this service in `bodystring.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodystring._rest import string + >>> request = string.build_get_null_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py new file mode 100644 index 00000000000..5f49fa086df --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_enum_operations.py @@ -0,0 +1,283 @@ +# 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 ..._rest import enum as rest_enum + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EnumOperations: + """EnumOperations 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: ~bodystring.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 get_not_expandable(self, **kwargs: Any) -> Union[str, "_models.Colors"]: + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Colors, or the result of cls(response) + :rtype: str or ~bodystring.models.Colors + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_enum.build_get_not_expandable_request( + template_url=self.get_not_expandable.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore + + @distributed_trace_async + async def put_not_expandable(self, string_body: Union[str, "_models.Colors"], **kwargs: Any) -> None: + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :param string_body: string body. + :type string_body: str or ~bodystring.models.Colors + :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/json") # type: Optional[str] + + json = self._serialize.body(string_body, "str") + + request = rest_enum.build_put_not_expandable_request( + content_type=content_type, + json=json, + template_url=self.put_not_expandable.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore + + @distributed_trace_async + async def get_referenced(self, **kwargs: Any) -> Union[str, "_models.Colors"]: + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Colors, or the result of cls(response) + :rtype: str or ~bodystring.models.Colors + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_enum.build_get_referenced_request( + template_url=self.get_referenced.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore + + @distributed_trace_async + async def put_referenced(self, enum_string_body: Union[str, "_models.Colors"], **kwargs: Any) -> None: + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :param enum_string_body: enum string body. + :type enum_string_body: str or ~bodystring.models.Colors + :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/json") # type: Optional[str] + + json = self._serialize.body(enum_string_body, "str") + + request = rest_enum.build_put_referenced_request( + content_type=content_type, + json=json, + template_url=self.put_referenced.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore + + @distributed_trace_async + async def get_referenced_constant(self, **kwargs: Any) -> "_models.RefColorConstant": + """Get value 'green-color' from the constant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RefColorConstant, or the result of cls(response) + :rtype: ~bodystring.models.RefColorConstant + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.RefColorConstant"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_enum.build_get_referenced_constant_request( + template_url=self.get_referenced_constant.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("RefColorConstant", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore + + @distributed_trace_async + async def put_referenced_constant(self, field1: Optional[str] = None, **kwargs: Any) -> None: + """Sends value 'green-color' from a constant. + + :param field1: Sample string. + :type field1: 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/json") # type: Optional[str] + + _enum_string_body = _models.RefColorConstant(field1=field1) + json = self._serialize.body(_enum_string_body, "RefColorConstant") + + request = rest_enum.build_put_referenced_constant_request( + content_type=content_type, + json=json, + template_url=self.put_referenced_constant.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py new file mode 100644 index 00000000000..81e5dbab048 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py @@ -0,0 +1,551 @@ +# 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 ... import models as _models +from ..._rest import string as rest_string + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StringOperations: + """StringOperations 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: ~bodystring.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 get_null(self, **kwargs: Any) -> Optional[str]: + """Get null string value value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str or None, or the result of cls(response) + :rtype: str or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/string/null"} # type: ignore + + @distributed_trace_async + async def put_null(self, string_body: Optional[str] = None, **kwargs: Any) -> None: + """Set string value null. + + :param string_body: string body. + :type string_body: 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/json") # type: Optional[str] + + if string_body is not None: + json = self._serialize.body(string_body, "str") + else: + json = None + + request = rest_string.build_put_null_request( + content_type=content_type, + json=json, + template_url=self.put_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_null.metadata = {"url": "/string/null"} # type: ignore + + @distributed_trace_async + async def get_empty(self, **kwargs: Any) -> str: + """Get empty string value value ''. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/string/empty"} # type: ignore + + @distributed_trace_async + async def put_empty(self, **kwargs: Any) -> None: + """Set string value empty ''. + + :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/json") # type: Optional[str] + + string_body = "" + json = self._serialize.body(string_body, "str") + + request = rest_string.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/string/empty"} # type: ignore + + @distributed_trace_async + async def get_mbcs(self, **kwargs: Any) -> str: + """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_mbcs_request( + template_url=self.get_mbcs.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore + + @distributed_trace_async + async def put_mbcs(self, **kwargs: Any) -> None: + """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + :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/json") # type: Optional[str] + + string_body = "啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€" + json = self._serialize.body(string_body, "str") + + request = rest_string.build_put_mbcs_request( + content_type=content_type, + json=json, + template_url=self.put_mbcs.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore + + @distributed_trace_async + async def get_whitespace(self, **kwargs: Any) -> str: + """Get string value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_whitespace_request( + template_url=self.get_whitespace.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore + + @distributed_trace_async + async def put_whitespace(self, **kwargs: Any) -> None: + """Set String value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + :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/json") # type: Optional[str] + + string_body = " Now is the time for all good men to come to the aid of their country " + json = self._serialize.body(string_body, "str") + + request = rest_string.build_put_whitespace_request( + content_type=content_type, + json=json, + template_url=self.put_whitespace.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore + + @distributed_trace_async + async def get_not_provided(self, **kwargs: Any) -> str: + """Get String value when no string value is sent in response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/string/notProvided"} # type: ignore + + @distributed_trace_async + async def get_base64_encoded(self, **kwargs: Any) -> bytearray: + """Get value that is base64 encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_base64_encoded_request( + template_url=self.get_base64_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_encoded.metadata = {"url": "/string/base64Encoding"} # type: ignore + + @distributed_trace_async + async def get_base64_url_encoded(self, **kwargs: Any) -> bytes: + """Get value that is base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytes, or the result of cls(response) + :rtype: bytes + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytes] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_base64_url_encoded_request( + template_url=self.get_base64_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("base64", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore + + @distributed_trace_async + async def put_base64_url_encoded(self, string_body: bytes, **kwargs: Any) -> None: + """Put value that is base64url encoded. + + :param string_body: string body. + :type string_body: bytes + :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/json") # type: Optional[str] + + json = self._serialize.body(string_body, "base64") + + request = rest_string.build_put_base64_url_encoded_request( + content_type=content_type, + json=json, + template_url=self.put_base64_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore + + @distributed_trace_async + async def get_null_base64_url_encoded(self, **kwargs: Any) -> Optional[bytes]: + """Get null value that is expected to be base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytes or None, or the result of cls(response) + :rtype: bytes or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_null_base64_url_encoded_request( + template_url=self.get_null_base64_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("base64", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_base64_url_encoded.metadata = {"url": "/string/nullBase64UrlEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/_auto_rest_swagger_bat_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/_auto_rest_swagger_bat_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/_auto_rest_swagger_bat_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/_auto_rest_swagger_bat_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py new file mode 100644 index 00000000000..40342afc441 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_enum_operations.py @@ -0,0 +1,299 @@ +# 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 .. import models as _models +from .._rest import enum as rest_enum + +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]] + + +class EnumOperations(object): + """EnumOperations 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: ~bodystring.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 get_not_expandable( + self, **kwargs # type: Any + ): + # type: (...) -> Union[str, "_models.Colors"] + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Colors, or the result of cls(response) + :rtype: str or ~bodystring.models.Colors + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_enum.build_get_not_expandable_request( + template_url=self.get_not_expandable.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore + + @distributed_trace + def put_not_expandable( + self, + string_body, # type: Union[str, "_models.Colors"] + **kwargs # type: Any + ): + # type: (...) -> None + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :param string_body: string body. + :type string_body: str or ~bodystring.models.Colors + :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/json") # type: Optional[str] + + json = self._serialize.body(string_body, "str") + + request = rest_enum.build_put_not_expandable_request( + content_type=content_type, + json=json, + template_url=self.put_not_expandable.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_not_expandable.metadata = {"url": "/string/enum/notExpandable"} # type: ignore + + @distributed_trace + def get_referenced( + self, **kwargs # type: Any + ): + # type: (...) -> Union[str, "_models.Colors"] + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Colors, or the result of cls(response) + :rtype: str or ~bodystring.models.Colors + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[str, "_models.Colors"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_enum.build_get_referenced_request( + template_url=self.get_referenced.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore + + @distributed_trace + def put_referenced( + self, + enum_string_body, # type: Union[str, "_models.Colors"] + **kwargs # type: Any + ): + # type: (...) -> None + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + :param enum_string_body: enum string body. + :type enum_string_body: str or ~bodystring.models.Colors + :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/json") # type: Optional[str] + + json = self._serialize.body(enum_string_body, "str") + + request = rest_enum.build_put_referenced_request( + content_type=content_type, + json=json, + template_url=self.put_referenced.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_referenced.metadata = {"url": "/string/enum/Referenced"} # type: ignore + + @distributed_trace + def get_referenced_constant( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.RefColorConstant" + """Get value 'green-color' from the constant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RefColorConstant, or the result of cls(response) + :rtype: ~bodystring.models.RefColorConstant + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.RefColorConstant"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_enum.build_get_referenced_constant_request( + template_url=self.get_referenced_constant.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("RefColorConstant", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore + + @distributed_trace + def put_referenced_constant( + self, + field1=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Sends value 'green-color' from a constant. + + :param field1: Sample string. + :type field1: 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/json") # type: Optional[str] + + _enum_string_body = _models.RefColorConstant(field1=field1) + json = self._serialize.body(_enum_string_body, "RefColorConstant") + + request = rest_enum.build_put_referenced_constant_request( + content_type=content_type, + json=json, + template_url=self.put_referenced_constant.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_referenced_constant.metadata = {"url": "/string/enum/ReferencedConstant"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py new file mode 100644 index 00000000000..9c49007203b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py @@ -0,0 +1,572 @@ +# 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 .. import models as _models +from .._rest import string as rest_string + +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]] + + +class StringOperations(object): + """StringOperations 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: ~bodystring.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 get_null( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[str] + """Get null string value value. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str or None, or the result of cls(response) + :rtype: str or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[str]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_null_request( + template_url=self.get_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null.metadata = {"url": "/string/null"} # type: ignore + + @distributed_trace + def put_null( + self, + string_body=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set string value null. + + :param string_body: string body. + :type string_body: 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/json") # type: Optional[str] + + if string_body is not None: + json = self._serialize.body(string_body, "str") + else: + json = None + + request = rest_string.build_put_null_request( + content_type=content_type, + json=json, + template_url=self.put_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_null.metadata = {"url": "/string/null"} # type: ignore + + @distributed_trace + def get_empty( + self, **kwargs # type: Any + ): + # type: (...) -> str + """Get empty string value value ''. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty.metadata = {"url": "/string/empty"} # type: ignore + + @distributed_trace + def put_empty( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Set string value empty ''. + + :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/json") # type: Optional[str] + + string_body = "" + json = self._serialize.body(string_body, "str") + + request = rest_string.build_put_empty_request( + content_type=content_type, + json=json, + template_url=self.put_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty.metadata = {"url": "/string/empty"} # type: ignore + + @distributed_trace + def get_mbcs( + self, **kwargs # type: Any + ): + # type: (...) -> str + """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_mbcs_request( + template_url=self.get_mbcs.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore + + @distributed_trace + def put_mbcs( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + :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/json") # type: Optional[str] + + string_body = "啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€" + json = self._serialize.body(string_body, "str") + + request = rest_string.build_put_mbcs_request( + content_type=content_type, + json=json, + template_url=self.put_mbcs.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_mbcs.metadata = {"url": "/string/mbcs"} # type: ignore + + @distributed_trace + def get_whitespace( + self, **kwargs # type: Any + ): + # type: (...) -> str + """Get string value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_whitespace_request( + template_url=self.get_whitespace.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore + + @distributed_trace + def put_whitespace( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Set String value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + :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/json") # type: Optional[str] + + string_body = " Now is the time for all good men to come to the aid of their country " + json = self._serialize.body(string_body, "str") + + request = rest_string.build_put_whitespace_request( + content_type=content_type, + json=json, + template_url=self.put_whitespace.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_whitespace.metadata = {"url": "/string/whitespace"} # type: ignore + + @distributed_trace + def get_not_provided( + self, **kwargs # type: Any + ): + # type: (...) -> str + """Get String value when no string value is sent in response payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_not_provided_request( + template_url=self.get_not_provided.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_not_provided.metadata = {"url": "/string/notProvided"} # type: ignore + + @distributed_trace + def get_base64_encoded( + self, **kwargs # type: Any + ): + # type: (...) -> bytearray + """Get value that is base64 encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytearray, or the result of cls(response) + :rtype: bytearray + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytearray] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_base64_encoded_request( + template_url=self.get_base64_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bytearray", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_encoded.metadata = {"url": "/string/base64Encoding"} # type: ignore + + @distributed_trace + def get_base64_url_encoded( + self, **kwargs # type: Any + ): + # type: (...) -> bytes + """Get value that is base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytes, or the result of cls(response) + :rtype: bytes + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bytes] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_base64_url_encoded_request( + template_url=self.get_base64_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("base64", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore + + @distributed_trace + def put_base64_url_encoded( + self, + string_body, # type: bytes + **kwargs # type: Any + ): + # type: (...) -> None + """Put value that is base64url encoded. + + :param string_body: string body. + :type string_body: bytes + :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/json") # type: Optional[str] + + json = self._serialize.body(string_body, "base64") + + request = rest_string.build_put_base64_url_encoded_request( + content_type=content_type, + json=json, + template_url=self.put_base64_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_base64_url_encoded.metadata = {"url": "/string/base64UrlEncoding"} # type: ignore + + @distributed_trace + def get_null_base64_url_encoded( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[bytes] + """Get null value that is expected to be base64url encoded. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bytes or None, or the result of cls(response) + :rtype: bytes or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[bytes]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_string.build_get_null_base64_url_encoded_request( + template_url=self.get_null_base64_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("base64", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_null_base64_url_encoded.metadata = {"url": "/string/nullBase64UrlEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/setup.py new file mode 100644 index 00000000000..b64368f0a3d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/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 = "autorestswaggerbatservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_auto_rest_time_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_auto_rest_time_test_service.py new file mode 100644 index 00000000000..89a647fe9f9 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_auto_rest_time_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestTimeTestServiceConfiguration +from .operations import TimeOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestTimeTestService(object): + """Test Infrastructure for AutoRest. + + :ivar time: TimeOperations operations + :vartype time: bodytime.operations.TimeOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestTimeTestServiceConfiguration(**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.time = TimeOperations(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. + + We have helper methods to create requests specific to this service in `bodytime.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodytime._rest import time + >>> request = time.build_get_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestTimeTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_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/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/__init__.py new file mode 100644 index 00000000000..355267c5498 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/__init__.py @@ -0,0 +1,19 @@ +# 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_get_request + from ._request_builders_py3 import build_put_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_request # type: ignore + from ._request_builders import build_put_request # type: ignore + +__all__ = [ + "build_get_request", + "build_put_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/_request_builders.py new file mode 100644 index 00000000000..a957a2eb53f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/_request_builders.py @@ -0,0 +1,91 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get time value "11:34:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/time/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put time value "08:07:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put time value "08:07:56" in parameter to pass testserver. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put time value "08:07:56" in parameter to pass testserver. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/time/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/_request_builders_py3.py new file mode 100644 index 00000000000..d5ec4d56d4c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_rest/time/_request_builders_py3.py @@ -0,0 +1,70 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get time value "11:34:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/time/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put time value "08:07:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put time value "08:07:56" in parameter to pass testserver. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put time value "08:07:56" in parameter to pass testserver. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/time/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/_auto_rest_time_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/_auto_rest_time_test_service.py new file mode 100644 index 00000000000..7e17b7fd182 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/_auto_rest_time_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestTimeTestServiceConfiguration +from .operations import TimeOperations + + +class AutoRestTimeTestService: + """Test Infrastructure for AutoRest. + + :ivar time: TimeOperations operations + :vartype time: bodytime.aio.operations.TimeOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestTimeTestServiceConfiguration(**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.time = TimeOperations(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. + + We have helper methods to create requests specific to this service in `bodytime.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodytime._rest import time + >>> request = time.build_get_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestTimeTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py new file mode 100644 index 00000000000..e6b8df33c94 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/aio/operations/_time_operations.py @@ -0,0 +1,133 @@ +# 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 datetime +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 ... import models as _models +from ..._rest import time as rest_time + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TimeOperations: + """TimeOperations 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: ~bodytime.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 get(self, **kwargs: Any) -> datetime.time: + """Get time value "11:34:56". + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: time, or the result of cls(response) + :rtype: ~datetime.time + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.time] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_time.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/time/get"} # type: ignore + + @distributed_trace_async + async def put(self, time_body: datetime.time, **kwargs: Any) -> str: + """Put time value "08:07:56". + + :param time_body: Put time value "08:07:56" in parameter to pass testserver. + :type time_body: ~datetime.time + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(time_body, "time") + + request = rest_time.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/time/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/BodyTime/bodytime/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py new file mode 100644 index 00000000000..42eeb4af2ab --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/operations/_time_operations.py @@ -0,0 +1,141 @@ +# 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 datetime +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 .. import models as _models +from .._rest import time as rest_time + +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]] + + +class TimeOperations(object): + """TimeOperations 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: ~bodytime.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 get( + self, **kwargs # type: Any + ): + # type: (...) -> datetime.time + """Get time value "11:34:56". + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: time, or the result of cls(response) + :rtype: ~datetime.time + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[datetime.time] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_time.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("time", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/time/get"} # type: ignore + + @distributed_trace + def put( + self, + time_body, # type: datetime.time + **kwargs # type: Any + ): + # type: (...) -> str + """Put time value "08:07:56". + + :param time_body: Put time value "08:07:56" in parameter to pass testserver. + :type time_body: ~datetime.time + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(time_body, "time") + + request = rest_time.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/time/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/setup.py new file mode 100644 index 00000000000..92d1b4c9146 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/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 = "autoresttimetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestTimeTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestTimeTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_auto_rest_swagger_constant_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_auto_rest_swagger_constant_service.py new file mode 100644 index 00000000000..63ea6911f19 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_auto_rest_swagger_constant_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerConstantServiceConfiguration +from .operations import ContantsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerConstantService(object): + """Test Infrastructure for AutoRest Swagger Constant. + + :ivar contants: ContantsOperations operations + :vartype contants: constants.operations.ContantsOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerConstantServiceConfiguration(**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.contants = ContantsOperations(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. + + We have helper methods to create requests specific to this service in `constants.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from constants._rest import contants + >>> request = contants.build_put_no_model_as_string_no_required_two_value_no_default_request(input=input, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerConstantService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_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/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/__init__.py new file mode 100644 index 00000000000..81d5ec39170 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/__init__.py @@ -0,0 +1,61 @@ +# 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_put_no_model_as_string_no_required_two_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_no_required_two_value_default_request + from ._request_builders_py3 import build_put_no_model_as_string_no_required_one_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_no_required_one_value_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_two_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_two_value_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_one_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_one_value_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_two_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_two_value_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_one_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_one_value_default_request + from ._request_builders_py3 import build_put_model_as_string_required_two_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_required_two_value_default_request + from ._request_builders_py3 import build_put_model_as_string_required_one_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_required_one_value_default_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_no_model_as_string_no_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_no_required_two_value_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_no_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_no_required_one_value_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_two_value_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_one_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_two_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_one_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_two_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_one_value_default_request # type: ignore + +__all__ = [ + "build_put_no_model_as_string_no_required_two_value_no_default_request", + "build_put_no_model_as_string_no_required_two_value_default_request", + "build_put_no_model_as_string_no_required_one_value_no_default_request", + "build_put_no_model_as_string_no_required_one_value_default_request", + "build_put_no_model_as_string_required_two_value_no_default_request", + "build_put_no_model_as_string_required_two_value_default_request", + "build_put_no_model_as_string_required_one_value_no_default_request", + "build_put_no_model_as_string_required_one_value_default_request", + "build_put_model_as_string_no_required_two_value_no_default_request", + "build_put_model_as_string_no_required_two_value_default_request", + "build_put_model_as_string_no_required_one_value_no_default_request", + "build_put_model_as_string_no_required_one_value_default_request", + "build_put_model_as_string_required_two_value_no_default_request", + "build_put_model_as_string_required_two_value_default_request", + "build_put_model_as_string_required_one_value_no_default_request", + "build_put_model_as_string_required_one_value_default_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/_request_builders.py new file mode 100644 index 00000000000..bc5ea3aa891 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/_request_builders.py @@ -0,0 +1,596 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_no_model_as_string_no_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', None) # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_no_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_no_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_no_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input') # type: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', None) # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', None) # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredOneValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input') # type: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredOneValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input') # type: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredOneValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/_request_builders_py3.py new file mode 100644 index 00000000000..78f404a6826 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_rest/contants/_request_builders_py3.py @@ -0,0 +1,463 @@ +# 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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_no_model_as_string_no_required_two_value_no_default_request( + *, input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_no_required_two_value_default_request( + *, input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_no_required_one_value_no_default_request( + *, input: Optional[str] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_no_required_one_value_default_request( + *, input: Optional[str] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_two_value_no_default_request( + *, input: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_two_value_default_request( + *, input: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.NoModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_one_value_no_default_request(**kwargs: Any) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_one_value_default_request(**kwargs: Any) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_two_value_no_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_two_value_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_one_value_no_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] = None, **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_one_value_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringNoRequiredOneValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_two_value_no_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_two_value_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_one_value_no_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"], **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredOneValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_one_value_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constants.models.ModelAsStringRequiredOneValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/_auto_rest_swagger_constant_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/_auto_rest_swagger_constant_service.py new file mode 100644 index 00000000000..b086f71bf23 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/_auto_rest_swagger_constant_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerConstantServiceConfiguration +from .operations import ContantsOperations + + +class AutoRestSwaggerConstantService: + """Test Infrastructure for AutoRest Swagger Constant. + + :ivar contants: ContantsOperations operations + :vartype contants: constants.aio.operations.ContantsOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerConstantServiceConfiguration(**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.contants = ContantsOperations(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. + + We have helper methods to create requests specific to this service in `constants.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from constants._rest import contants + >>> request = contants.build_put_no_model_as_string_no_required_two_value_no_default_request(input=input, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerConstantService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py new file mode 100644 index 00000000000..8ee3f0b1d5e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/aio/operations/_contants_operations.py @@ -0,0 +1,677 @@ +# 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 ..._rest import contants as rest_contants + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ContantsOperations: + """ContantsOperations 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: ~constants.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 put_no_model_as_string_no_required_two_value_no_default( + self, + input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, + **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_two_value_no_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_no_required_two_value_default( + self, + input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", + **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_two_value_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_no_required_one_value_no_default( + self, input: Optional[str] = "value1", **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: 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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_one_value_no_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_no_required_one_value_default( + self, input: Optional[str] = "value1", **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: 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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_one_value_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_required_two_value_no_default( + self, input: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_two_value_no_default_request( + input=input, + template_url=self.put_no_model_as_string_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_required_two_value_default( + self, input: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_two_value_default_request( + input=input, + template_url=self.put_no_model_as_string_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_required_one_value_no_default(self, **kwargs: Any) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_one_value_no_default_request( + template_url=self.put_no_model_as_string_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_no_model_as_string_required_one_value_default(self, **kwargs: Any) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_one_value_default_request( + template_url=self.put_no_model_as_string_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_no_required_two_value_no_default( + self, + input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, + **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_two_value_no_default_request( + input=input, + template_url=self.put_model_as_string_no_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_no_required_two_value_default( + self, + input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", + **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_two_value_default_request( + input=input, + template_url=self.put_model_as_string_no_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_no_required_one_value_no_default( + self, + input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] = None, + **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_one_value_no_default_request( + input=input, + template_url=self.put_model_as_string_no_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_no_required_one_value_default( + self, + input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] = "value1", + **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_one_value_default_request( + input=input, + template_url=self.put_model_as_string_no_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_required_two_value_no_default( + self, input: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_two_value_no_default_request( + input=input, + template_url=self.put_model_as_string_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_required_two_value_default( + self, input: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_two_value_default_request( + input=input, + template_url=self.put_model_as_string_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_two_value_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_required_one_value_no_default( + self, input: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"], **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredOneValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_one_value_no_default_request( + input=input, + template_url=self.put_model_as_string_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace_async + async def put_model_as_string_required_one_value_default( + self, input: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] = "value1", **kwargs: Any + ) -> None: + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredOneValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_one_value_default_request( + input=input, + template_url=self.put_model_as_string_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_one_value_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueDefault"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/models/_auto_rest_swagger_constant_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/_auto_rest_swagger_constant_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/models/_auto_rest_swagger_constant_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/_auto_rest_swagger_constant_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Constants/constants/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Constants/constants/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py new file mode 100644 index 00000000000..e999060be6d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py @@ -0,0 +1,685 @@ +# 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 .. import models as _models +from .._rest import contants as rest_contants + +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]] + + +class ContantsOperations(object): + """ContantsOperations 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: ~constants.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 put_no_model_as_string_no_required_two_value_no_default( + self, + input=None, # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_two_value_no_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_no_required_two_value_default( + self, + input="value1", # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_two_value_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredTwoValueDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_no_required_one_value_no_default( + self, + input="value1", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: 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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_one_value_no_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_no_required_one_value_default( + self, + input="value1", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: 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", {})) + + request = rest_contants.build_put_no_model_as_string_no_required_one_value_default_request( + input=input, + template_url=self.put_no_model_as_string_no_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringNoRequiredOneValueDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_required_two_value_no_default( + self, + input, # type: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_two_value_no_default_request( + input=input, + template_url=self.put_no_model_as_string_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_required_two_value_default( + self, + input="value1", # type: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.NoModelAsStringRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_two_value_default_request( + input=input, + template_url=self.put_no_model_as_string_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_two_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredTwoValueDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_required_one_value_no_default( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_one_value_no_default_request( + template_url=self.put_no_model_as_string_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace + def put_no_model_as_string_required_one_value_default( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :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", {})) + + request = rest_contants.build_put_no_model_as_string_required_one_value_default_request( + template_url=self.put_no_model_as_string_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_no_model_as_string_required_one_value_default.metadata = {"url": "/constants/putNoModelAsStringRequiredOneValueDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_no_required_two_value_no_default( + self, + input=None, # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_two_value_no_default_request( + input=input, + template_url=self.put_model_as_string_no_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_no_required_two_value_default( + self, + input="value1", # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_two_value_default_request( + input=input, + template_url=self.put_model_as_string_no_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_two_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredTwoValueDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_no_required_one_value_no_default( + self, + input=None, # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_one_value_no_default_request( + input=input, + template_url=self.put_model_as_string_no_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_no_required_one_value_default( + self, + input="value1", # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringNoRequiredOneValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_no_required_one_value_default_request( + input=input, + template_url=self.put_model_as_string_no_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_no_required_one_value_default.metadata = {"url": "/constants/putModelAsStringNoRequiredOneValueDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_required_two_value_no_default( + self, + input, # type: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_two_value_no_default_request( + input=input, + template_url=self.put_model_as_string_required_two_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_two_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueNoDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_required_two_value_default( + self, + input="value1", # type: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredTwoValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_two_value_default_request( + input=input, + template_url=self.put_model_as_string_required_two_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_two_value_default.metadata = {"url": "/constants/putModelAsStringRequiredTwoValueDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_required_one_value_no_default( + self, + input, # type: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredOneValueNoDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_one_value_no_default_request( + input=input, + template_url=self.put_model_as_string_required_one_value_no_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_one_value_no_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueNoDefault"} # type: ignore + + @distributed_trace + def put_model_as_string_required_one_value_default( + self, + input="value1", # type: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts constants to the testserver. + + Puts constants to the testserver. + + :param input: + :type input: str or ~constants.models.ModelAsStringRequiredOneValueDefaultOpEnum + :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", {})) + + request = rest_contants.build_put_model_as_string_required_one_value_default_request( + input=input, + template_url=self.put_model_as_string_required_one_value_default.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_model_as_string_required_one_value_default.metadata = {"url": "/constants/putModelAsStringRequiredOneValueDefault"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Constants/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/setup.py new file mode 100644 index 00000000000..122b3e88598 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Constants/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 = "autorestswaggerconstantservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerConstantService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerConstantService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger Constant. + """, +) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__init__.py new file mode 100644 index 00000000000..b8067887b35 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/__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 ._auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestParameterizedHostTestClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..336b4570eb9 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,97 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration +from .operations import PathsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedHostTestClient(object): + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: custombaseurl.operations.PathsOperations + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurl.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurl._rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedHostTestClient + 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/CustomBaseUri/custombaseurl/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py new file mode 100644 index 00000000000..ad7661010a8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_configuration.py @@ -0,0 +1,57 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedHostTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AutoRestParameterizedHostTestClientConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "autorestparameterizedhosttestclient/{}".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/CustomBaseUri/custombaseurl/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_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/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/__init__.py new file mode 100644 index 00000000000..5daa0aa077d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/__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_get_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_request # type: ignore + +__all__ = [ + "build_get_empty_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders.py new file mode 100644 index 00000000000..0931964c6cb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders.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.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/customuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..5a2da7d8789 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_rest/paths/_request_builders_py3.py @@ -0,0 +1,36 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/customuri") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/_version.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/__init__.py new file mode 100644 index 00000000000..76852835031 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/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 ._auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient + +__all__ = ["AutoRestParameterizedHostTestClient"] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..5dcf9d9b3ed --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,79 @@ +# 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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestParameterizedHostTestClientConfiguration +from .operations import PathsOperations + + +class AutoRestParameterizedHostTestClient: + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: custombaseurl.aio.operations.PathsOperations + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **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.paths = PathsOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurl.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurl._rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedHostTestClient": + 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/CustomBaseUri/custombaseurl/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py new file mode 100644 index 00000000000..d8ad54e11fa --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/_configuration.py @@ -0,0 +1,45 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedHostTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AutoRestParameterizedHostTestClientConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "autorestparameterizedhosttestclient/{}".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/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.py new file mode 100644 index 00000000000..70f7776f229 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/aio/operations/_paths_operations.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. +# -------------------------------------------------------------------------- +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 ... import models as _models +from ..._rest import paths as rest_paths + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PathsOperations: + """PathsOperations 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: ~custombaseurl.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 get_empty(self, account_name: str, **kwargs: Any) -> None: + """Get a 200 to test a valid base uri. + + :param account_name: Account Name. + :type account_name: 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", {})) + + request = rest_paths.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py new file mode 100644 index 00000000000..6fecf75707f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/operations/_paths_operations.py @@ -0,0 +1,97 @@ +# 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 .. import models as _models +from .._rest import paths as rest_paths + +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]] + + +class PathsOperations(object): + """PathsOperations 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: ~custombaseurl.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 get_empty( + self, + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a 200 to test a valid base uri. + + :param account_name: Account Name. + :type account_name: 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", {})) + + request = rest_paths.build_get_empty_request( + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True), + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_empty.metadata = {"url": "/customuri"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/custombaseurl/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/setup.py new file mode 100644 index 00000000000..37d0593ce8f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUri/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 = "autorestparameterizedhosttestclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_auto_rest_parameterized_custom_host_test_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_auto_rest_parameterized_custom_host_test_client.py new file mode 100644 index 00000000000..bdf0c664672 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_auto_rest_parameterized_custom_host_test_client.py @@ -0,0 +1,104 @@ +# 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 AutoRestParameterizedCustomHostTestClientConfiguration +from .operations import PathsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedCustomHostTestClient(object): + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: custombaseurlmoreoptions.operations.PathsOperations + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the parameterized host. + Default value 'host'. + :type dns_suffix: str + """ + + def __init__( + self, + subscription_id, # type: str + dns_suffix="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "{vault}{secret}{dnsSuffix}" + self._config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, **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.paths = PathsOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurlmoreoptions.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlmoreoptions._rest import paths + >>> request = paths.build_get_empty_request(key_name, subscription_id, key_version=key_version, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "dnsSuffix": self._serialize.url( + "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True + ), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedCustomHostTestClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_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/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/__init__.py new file mode 100644 index 00000000000..5daa0aa077d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/__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_get_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_request # type: ignore + +__all__ = [ + "build_get_empty_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/_request_builders.py new file mode 100644 index 00000000000..34a5abdd325 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/_request_builders.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 typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_request( + key_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param key_name: The key name with value 'key1'. + :type key_name: str + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :keyword key_version: The key version. Default value 'v1'. + :paramtype key_version: str + :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 + """ + + key_version = kwargs.pop('key_version', "v1") # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/customuri/{subscriptionId}/{keyName}') + path_format_arguments = { + 'keyName': _SERIALIZER.url("key_name", key_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if key_version is not None: + query_parameters['keyVersion'] = _SERIALIZER.query("key_version", key_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..fbcd97e612b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_rest/paths/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_request( + key_name: str, subscription_id: str, *, key_version: Optional[str] = "v1", **kwargs: Any +) -> HttpRequest: + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param key_name: The key name with value 'key1'. + :type key_name: str + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :keyword key_version: The key version. Default value 'v1'. + :paramtype key_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/customuri/{subscriptionId}/{keyName}") + path_format_arguments = { + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if key_version is not None: + query_parameters["keyVersion"] = _SERIALIZER.query("key_version", key_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_auto_rest_parameterized_custom_host_test_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_auto_rest_parameterized_custom_host_test_client.py new file mode 100644 index 00000000000..dc14064e90c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_auto_rest_parameterized_custom_host_test_client.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 Any, Awaitable + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestParameterizedCustomHostTestClientConfiguration +from .operations import PathsOperations + + +class AutoRestParameterizedCustomHostTestClient: + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: custombaseurlmoreoptions.aio.operations.PathsOperations + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the parameterized host. + Default value 'host'. + :type dns_suffix: str + """ + + def __init__(self, subscription_id: str, dns_suffix: str = "host", **kwargs: Any) -> None: + base_url = "{vault}{secret}{dnsSuffix}" + self._config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, **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.paths = PathsOperations(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. + + We have helper methods to create requests specific to this service in `custombaseurlmoreoptions.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlmoreoptions._rest import paths + >>> request = paths.build_get_empty_request(key_name, subscription_id, key_version=key_version, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "dnsSuffix": self._serialize.url( + "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True + ), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedCustomHostTestClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py new file mode 100644 index 00000000000..8f937615606 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/operations/_paths_operations.py @@ -0,0 +1,104 @@ +# 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 ... import models as _models +from ..._rest import paths as rest_paths + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PathsOperations: + """PathsOperations 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: ~custombaseurlmoreoptions.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 get_empty( + self, vault: str, secret: str, key_name: str, key_version: Optional[str] = "v1", **kwargs: Any + ) -> None: + """Get a 200 to test a valid base uri. + + :param vault: The vault name, e.g. https://myvault. + :type vault: str + :param secret: Secret value. + :type secret: str + :param key_name: The key name with value 'key1'. + :type key_name: str + :param key_version: The key version. Default value 'v1'. + :type key_version: 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", {})) + + request = rest_paths.build_get_empty_request( + key_name=key_name, + subscription_id=self._config.subscription_id, + key_version=key_version, + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "vault": self._serialize.url("vault", vault, "str", skip_quote=True), + "secret": self._serialize.url("secret", secret, "str", skip_quote=True), + "dnsSuffix": self._serialize.url( + "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True + ), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_empty.metadata = {"url": "/customuri/{subscriptionId}/{keyName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py new file mode 100644 index 00000000000..7e0366e01b5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/operations/_paths_operations.py @@ -0,0 +1,112 @@ +# 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 .. import models as _models +from .._rest import paths as rest_paths + +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]] + + +class PathsOperations(object): + """PathsOperations 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: ~custombaseurlmoreoptions.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 get_empty( + self, + vault, # type: str + secret, # type: str + key_name, # type: str + key_version="v1", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Get a 200 to test a valid base uri. + + :param vault: The vault name, e.g. https://myvault. + :type vault: str + :param secret: Secret value. + :type secret: str + :param key_name: The key name with value 'key1'. + :type key_name: str + :param key_version: The key version. Default value 'v1'. + :type key_version: 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", {})) + + request = rest_paths.build_get_empty_request( + key_name=key_name, + subscription_id=self._config.subscription_id, + key_version=key_version, + template_url=self.get_empty.metadata["url"], + )._to_pipeline_transport_request() + path_format_arguments = { + "vault": self._serialize.url("vault", vault, "str", skip_quote=True), + "secret": self._serialize.url("secret", secret, "str", skip_quote=True), + "dnsSuffix": self._serialize.url( + "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True + ), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_empty.metadata = {"url": "/customuri/{subscriptionId}/{keyName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py new file mode 100644 index 00000000000..be943bbad97 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/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 = "autorestparameterizedcustomhosttestclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedCustomHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedCustomHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_pet_store_inc.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_pet_store_inc.py new file mode 100644 index 00000000000..d9a788977ad --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_pet_store_inc.py @@ -0,0 +1,96 @@ +# 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 PetStoreIncConfiguration +from .operations import PetOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class PetStoreInc(object): + """PetStore. + + :ivar pet: PetOperations operations + :vartype pet: extensibleenumsswagger.operations.PetOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = PetStoreIncConfiguration(**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.pet = PetOperations(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. + + We have helper methods to create requests specific to this service in `extensibleenumsswagger.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from extensibleenumsswagger._rest import pet + >>> request = pet.build_get_by_pet_id_request(pet_id, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> PetStoreInc + 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/ExtensibleEnums/extensibleenumsswagger/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_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/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/__init__.py new file mode 100644 index 00000000000..c2d46d43efe --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/__init__.py @@ -0,0 +1,19 @@ +# 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_get_by_pet_id_request + from ._request_builders_py3 import build_add_pet_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_by_pet_id_request # type: ignore + from ._request_builders import build_add_pet_request # type: ignore + +__all__ = [ + "build_get_by_pet_id_request", + "build_add_pet_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/_request_builders.py new file mode 100644 index 00000000000..07456a20835 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/_request_builders.py @@ -0,0 +1,98 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_by_pet_id_request( + pet_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """get pet by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: Pet id. + :type pet_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/extensibleenums/pet/{petId}') + path_format_arguments = { + 'petId': _SERIALIZER.url("pet_id", pet_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_add_pet_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """add pet. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. pet param. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). pet param. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/extensibleenums/pet/addPet') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/_request_builders_py3.py new file mode 100644 index 00000000000..9fe95e84881 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_rest/pet/_request_builders_py3.py @@ -0,0 +1,76 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_by_pet_id_request(pet_id: str, **kwargs: Any) -> HttpRequest: + """get pet by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: Pet id. + :type pet_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/extensibleenums/pet/{petId}") + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_add_pet_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """add pet. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. pet param. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). pet param. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/extensibleenums/pet/addPet") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_pet_store_inc.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_pet_store_inc.py new file mode 100644 index 00000000000..26cf625b5d7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/_pet_store_inc.py @@ -0,0 +1,78 @@ +# 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 PetStoreIncConfiguration +from .operations import PetOperations + + +class PetStoreInc: + """PetStore. + + :ivar pet: PetOperations operations + :vartype pet: extensibleenumsswagger.aio.operations.PetOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = PetStoreIncConfiguration(**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.pet = PetOperations(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. + + We have helper methods to create requests specific to this service in `extensibleenumsswagger.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from extensibleenumsswagger._rest import pet + >>> request = pet.build_get_by_pet_id_request(pet_id, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "PetStoreInc": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py new file mode 100644 index 00000000000..64a21132649 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/aio/operations/_pet_operations.py @@ -0,0 +1,136 @@ +# 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 ... import models as _models +from ..._rest import pet as rest_pet + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PetOperations: + """PetOperations 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: ~extensibleenumsswagger.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 get_by_pet_id(self, pet_id: str, **kwargs: Any) -> "_models.Pet": + """get pet by id. + + :param pet_id: Pet id. + :type pet_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~extensibleenumsswagger.models.Pet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_get_by_pet_id_request( + pet_id=pet_id, + template_url=self.get_by_pet_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_pet_id.metadata = {"url": "/extensibleenums/pet/{petId}"} # type: ignore + + @distributed_trace_async + async def add_pet(self, pet_param: Optional["_models.Pet"] = None, **kwargs: Any) -> "_models.Pet": + """add pet. + + :param pet_param: pet param. + :type pet_param: ~extensibleenumsswagger.models.Pet + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~extensibleenumsswagger.models.Pet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if pet_param is not None: + json = self._serialize.body(pet_param, "Pet") + else: + json = None + + request = rest_pet.build_add_pet_request( + content_type=content_type, + json=json, + template_url=self.add_pet.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + add_pet.metadata = {"url": "/extensibleenums/pet/addPet"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_pet_store_inc_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_pet_store_inc_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_pet_store_inc_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/models/_pet_store_inc_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py new file mode 100644 index 00000000000..4d2d1469e42 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/operations/_pet_operations.py @@ -0,0 +1,146 @@ +# 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 .. import models as _models +from .._rest import pet as rest_pet + +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]] + + +class PetOperations(object): + """PetOperations 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: ~extensibleenumsswagger.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 get_by_pet_id( + self, + pet_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Pet" + """get pet by id. + + :param pet_id: Pet id. + :type pet_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~extensibleenumsswagger.models.Pet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_get_by_pet_id_request( + pet_id=pet_id, + template_url=self.get_by_pet_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_pet_id.metadata = {"url": "/extensibleenums/pet/{petId}"} # type: ignore + + @distributed_trace + def add_pet( + self, + pet_param=None, # type: Optional["_models.Pet"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Pet" + """add pet. + + :param pet_param: pet param. + :type pet_param: ~extensibleenumsswagger.models.Pet + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~extensibleenumsswagger.models.Pet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if pet_param is not None: + json = self._serialize.body(pet_param, "Pet") + else: + json = None + + request = rest_pet.build_add_pet_request( + content_type=content_type, + json=json, + template_url=self.add_pet.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + add_pet.metadata = {"url": "/extensibleenums/pet/addPet"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/setup.py new file mode 100644 index 00000000000..dddcaae773f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/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 = "petstoreinc" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="PetStoreInc", + author_email="", + url="", + keywords=["Swagger", "PetStoreInc"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + PetStore. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_auto_rest_swagger_bat_header_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_auto_rest_swagger_bat_header_service.py new file mode 100644 index 00000000000..8dec652cbd4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_auto_rest_swagger_bat_header_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATHeaderServiceConfiguration +from .operations import HeaderOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATHeaderService(object): + """Test Infrastructure for AutoRest. + + :ivar header: HeaderOperations operations + :vartype header: header.operations.HeaderOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATHeaderServiceConfiguration(**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.header = HeaderOperations(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. + + We have helper methods to create requests specific to this service in `header.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from header._rest import header + >>> request = header.build_param_existing_key_request(user_agent_parameter=user_agent_parameter, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATHeaderService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_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/legacy/Expected/AcceptanceTests/Header/header/_rest/header/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/__init__.py new file mode 100644 index 00000000000..62ca0400102 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/__init__.py @@ -0,0 +1,100 @@ +# 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_param_existing_key_request + from ._request_builders_py3 import build_response_existing_key_request + from ._request_builders_py3 import build_param_protected_key_request + from ._request_builders_py3 import build_response_protected_key_request + from ._request_builders_py3 import build_param_integer_request + from ._request_builders_py3 import build_response_integer_request + from ._request_builders_py3 import build_param_long_request + from ._request_builders_py3 import build_response_long_request + from ._request_builders_py3 import build_param_float_request + from ._request_builders_py3 import build_response_float_request + from ._request_builders_py3 import build_param_double_request + from ._request_builders_py3 import build_response_double_request + from ._request_builders_py3 import build_param_bool_request + from ._request_builders_py3 import build_response_bool_request + from ._request_builders_py3 import build_param_string_request + from ._request_builders_py3 import build_response_string_request + from ._request_builders_py3 import build_param_date_request + from ._request_builders_py3 import build_response_date_request + from ._request_builders_py3 import build_param_datetime_request + from ._request_builders_py3 import build_response_datetime_request + from ._request_builders_py3 import build_param_datetime_rfc1123_request + from ._request_builders_py3 import build_response_datetime_rfc1123_request + from ._request_builders_py3 import build_param_duration_request + from ._request_builders_py3 import build_response_duration_request + from ._request_builders_py3 import build_param_byte_request + from ._request_builders_py3 import build_response_byte_request + from ._request_builders_py3 import build_param_enum_request + from ._request_builders_py3 import build_response_enum_request + from ._request_builders_py3 import build_custom_request_id_request +except (SyntaxError, ImportError): + from ._request_builders import build_param_existing_key_request # type: ignore + from ._request_builders import build_response_existing_key_request # type: ignore + from ._request_builders import build_param_protected_key_request # type: ignore + from ._request_builders import build_response_protected_key_request # type: ignore + from ._request_builders import build_param_integer_request # type: ignore + from ._request_builders import build_response_integer_request # type: ignore + from ._request_builders import build_param_long_request # type: ignore + from ._request_builders import build_response_long_request # type: ignore + from ._request_builders import build_param_float_request # type: ignore + from ._request_builders import build_response_float_request # type: ignore + from ._request_builders import build_param_double_request # type: ignore + from ._request_builders import build_response_double_request # type: ignore + from ._request_builders import build_param_bool_request # type: ignore + from ._request_builders import build_response_bool_request # type: ignore + from ._request_builders import build_param_string_request # type: ignore + from ._request_builders import build_response_string_request # type: ignore + from ._request_builders import build_param_date_request # type: ignore + from ._request_builders import build_response_date_request # type: ignore + from ._request_builders import build_param_datetime_request # type: ignore + from ._request_builders import build_response_datetime_request # type: ignore + from ._request_builders import build_param_datetime_rfc1123_request # type: ignore + from ._request_builders import build_response_datetime_rfc1123_request # type: ignore + from ._request_builders import build_param_duration_request # type: ignore + from ._request_builders import build_response_duration_request # type: ignore + from ._request_builders import build_param_byte_request # type: ignore + from ._request_builders import build_response_byte_request # type: ignore + from ._request_builders import build_param_enum_request # type: ignore + from ._request_builders import build_response_enum_request # type: ignore + from ._request_builders import build_custom_request_id_request # type: ignore + +__all__ = [ + "build_param_existing_key_request", + "build_response_existing_key_request", + "build_param_protected_key_request", + "build_response_protected_key_request", + "build_param_integer_request", + "build_response_integer_request", + "build_param_long_request", + "build_response_long_request", + "build_param_float_request", + "build_response_float_request", + "build_param_double_request", + "build_response_double_request", + "build_param_bool_request", + "build_response_bool_request", + "build_param_string_request", + "build_response_string_request", + "build_param_date_request", + "build_response_date_request", + "build_param_datetime_request", + "build_response_datetime_request", + "build_param_datetime_rfc1123_request", + "build_response_datetime_rfc1123_request", + "build_param_duration_request", + "build_response_duration_request", + "build_param_byte_request", + "build_response_byte_request", + "build_param_enum_request", + "build_response_enum_request", + "build_custom_request_id_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/_request_builders.py new file mode 100644 index 00000000000..aaebbeecbd5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/_request_builders.py @@ -0,0 +1,1116 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_param_existing_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". + :paramtype user_agent_parameter: str + :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 + """ + + user_agent_parameter = kwargs.pop('user_agent_parameter') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/existingkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['User-Agent'] = _SERIALIZER.header("user_agent_parameter", user_agent_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_existing_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/existingkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_protected_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + content_type = kwargs.pop('content_type') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/protectedkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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, + **kwargs + ) + + +def build_response_protected_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/protectedkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_integer_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 1 or -2. + :paramtype value: int + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: int + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/integer') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_integer_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 1 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/integer') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 105 or -2. + :paramtype value: long + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: int + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'long') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 105 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 0.07 or -3.0. + :paramtype value: float + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: float + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'float') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 0.07 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 7e120 or -3.0. + :paramtype value: float + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: float + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/double') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'float') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 7e120 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/double') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "true", "value": true or "scenario": + "false", "value": false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :keyword value: Send a post request with header values true or false. + :paramtype value: bool + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: bool + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'bool') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": true or false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps + over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values "The quick brown fox jumps over the lazy + dog" or null or "". + :paramtype value: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + if value is not None: + header_parameters['value'] = _SERIALIZER.header("value", value, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or + "scenario": "min", "value": "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01" or "0001-01-01". + :paramtype value: ~datetime.date + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: datetime.date + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'date') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "2010-01-01" or "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_datetime_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or + "scenario": "min", "value": "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01T12:34:56Z" or + "0001-01-01T00:00:00Z". + :paramtype value: ~datetime.datetime + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: datetime.datetime + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/datetime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'iso-8601') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_datetime_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/datetime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_datetime_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 + GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, + 01 Jan 0001 00:00:00 GMT". + :paramtype value: ~datetime.datetime + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value', None) # type: Optional[datetime.datetime] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/datetimerfc1123') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + if value is not None: + header_parameters['value'] = _SERIALIZER.header("value", value, 'rfc-1123') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_datetime_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 + GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/datetimerfc1123') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "P123DT22H14M12.011S". + :paramtype value: ~datetime.timedelta + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: datetime.timedelta + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/duration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'duration') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/duration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". + :paramtype value: bytearray + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: bytearray + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/byte') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'bytearray') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/byte') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_enum_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": + "null", "value": null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values 'GREY'. + :paramtype value: str or ~header.models.GreyscaleColors + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value', None) # type: Optional[Union[str, "_models.GreyscaleColors"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/enum') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + if value is not None: + header_parameters['value'] = _SERIALIZER.header("value", value, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_enum_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "GREY" or null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/enum') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_custom_request_id_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the + request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/_request_builders_py3.py new file mode 100644 index 00000000000..bd8fae8fccd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_rest/header/_request_builders_py3.py @@ -0,0 +1,821 @@ +# 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 datetime +from typing import Any, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_param_existing_key_request(*, user_agent_parameter: str, **kwargs: Any) -> HttpRequest: + """Send a post request with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". + :paramtype user_agent_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/existingkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["User-Agent"] = _SERIALIZER.header("user_agent_parameter", user_agent_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_existing_key_request(**kwargs: Any) -> HttpRequest: + """Get a response with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/existingkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_protected_key_request(**kwargs: Any) -> HttpRequest: + """Send a post request with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + content_type = kwargs.pop("content_type") # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/protectedkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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, **kwargs) + + +def build_response_protected_key_request(**kwargs: Any) -> HttpRequest: + """Get a response with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/protectedkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_integer_request(*, scenario: str, value: int, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 1 or -2. + :paramtype value: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/integer") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_integer_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 1 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/integer") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_long_request(*, scenario: str, value: int, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 105 or -2. + :paramtype value: long + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "long") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_long_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 105 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_float_request(*, scenario: str, value: float, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 0.07 or -3.0. + :paramtype value: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "float") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_float_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 0.07 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_double_request(*, scenario: str, value: float, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 7e120 or -3.0. + :paramtype value: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/double") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "float") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_double_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 7e120 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/double") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_bool_request(*, scenario: str, value: bool, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "true", "value": true or "scenario": + "false", "value": false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :keyword value: Send a post request with header values true or false. + :paramtype value: bool + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "bool") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_bool_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": true or false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_string_request(*, scenario: str, value: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps + over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values "The quick brown fox jumps over the lazy + dog" or null or "". + :paramtype value: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + if value is not None: + header_parameters["value"] = _SERIALIZER.header("value", value, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_string_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_date_request(*, scenario: str, value: datetime.date, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or + "scenario": "min", "value": "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01" or "0001-01-01". + :paramtype value: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "date") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_date_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "2010-01-01" or "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_datetime_request(*, scenario: str, value: datetime.datetime, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or + "scenario": "min", "value": "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01T12:34:56Z" or + "0001-01-01T00:00:00Z". + :paramtype value: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/datetime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "iso-8601") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_datetime_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/datetime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_datetime_rfc1123_request( + *, scenario: str, value: Optional[datetime.datetime] = None, **kwargs: Any +) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 + GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, + 01 Jan 0001 00:00:00 GMT". + :paramtype value: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/datetimerfc1123") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + if value is not None: + header_parameters["value"] = _SERIALIZER.header("value", value, "rfc-1123") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_datetime_rfc1123_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 + GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/datetimerfc1123") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_duration_request(*, scenario: str, value: datetime.timedelta, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "P123DT22H14M12.011S". + :paramtype value: ~datetime.timedelta + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/duration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "duration") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_duration_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/duration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_byte_request(*, scenario: str, value: bytearray, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". + :paramtype value: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/byte") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "bytearray") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_byte_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/byte") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_enum_request( + *, scenario: str, value: Optional[Union[str, "_models.GreyscaleColors"]] = None, **kwargs: Any +) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": + "null", "value": null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values 'GREY'. + :paramtype value: str or ~header.models.GreyscaleColors + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/enum") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + if value is not None: + header_parameters["value"] = _SERIALIZER.header("value", value, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_enum_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "GREY" or null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/enum") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_custom_request_id_request(**kwargs: Any) -> HttpRequest: + """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the + request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/_auto_rest_swagger_bat_header_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/_auto_rest_swagger_bat_header_service.py new file mode 100644 index 00000000000..3946e0033a6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/_auto_rest_swagger_bat_header_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATHeaderServiceConfiguration +from .operations import HeaderOperations + + +class AutoRestSwaggerBATHeaderService: + """Test Infrastructure for AutoRest. + + :ivar header: HeaderOperations operations + :vartype header: header.aio.operations.HeaderOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATHeaderServiceConfiguration(**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.header = HeaderOperations(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. + + We have helper methods to create requests specific to this service in `header.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from header._rest import header + >>> request = header.build_param_existing_key_request(user_agent_parameter=user_agent_parameter, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATHeaderService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py new file mode 100644 index 00000000000..4257bbc3faf --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/aio/operations/_header_operations.py @@ -0,0 +1,1187 @@ +# 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 datetime +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 ..._rest import header as rest_header + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HeaderOperations: + """HeaderOperations 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: ~header.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 param_existing_key(self, user_agent_parameter: str, **kwargs: Any) -> None: + """Send a post request with header value "User-Agent": "overwrite". + + :param user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". + :type user_agent_parameter: 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", {})) + + request = rest_header.build_param_existing_key_request( + user_agent_parameter=user_agent_parameter, + template_url=self.param_existing_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_existing_key.metadata = {"url": "/header/param/existingkey"} # type: ignore + + @distributed_trace_async + async def response_existing_key(self, **kwargs: Any) -> None: + """Get a response with header value "User-Agent": "overwrite". + + :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", {})) + + request = rest_header.build_response_existing_key_request( + template_url=self.response_existing_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["User-Agent"] = self._deserialize("str", response.headers.get("User-Agent")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_existing_key.metadata = {"url": "/header/response/existingkey"} # type: ignore + + @distributed_trace_async + async def param_protected_key(self, **kwargs: Any) -> None: + """Send a post request with header value "Content-Type": "text/html". + + :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") # type: str + + request = rest_header.build_param_protected_key_request( + content_type=content_type, + template_url=self.param_protected_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_protected_key.metadata = {"url": "/header/param/protectedkey"} # type: ignore + + @distributed_trace_async + async def response_protected_key(self, **kwargs: Any) -> None: + """Get a response with header value "Content-Type": "text/html". + + :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", {})) + + request = rest_header.build_response_protected_key_request( + template_url=self.response_protected_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_protected_key.metadata = {"url": "/header/response/protectedkey"} # type: ignore + + @distributed_trace_async + async def param_integer(self, scenario: str, value: int, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": + "negative", "value": -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 1 or -2. + :type value: int + :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", {})) + + request = rest_header.build_param_integer_request( + scenario=scenario, + value=value, + template_url=self.param_integer.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_integer.metadata = {"url": "/header/param/prim/integer"} # type: ignore + + @distributed_trace_async + async def response_integer(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header value "value": 1 or -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_integer_request( + scenario=scenario, + template_url=self.response_integer.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("int", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_integer.metadata = {"url": "/header/response/prim/integer"} # type: ignore + + @distributed_trace_async + async def param_long(self, scenario: str, value: int, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": + "negative", "value": -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 105 or -2. + :type value: long + :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", {})) + + request = rest_header.build_param_long_request( + scenario=scenario, + value=value, + template_url=self.param_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_long.metadata = {"url": "/header/param/prim/long"} # type: ignore + + @distributed_trace_async + async def response_long(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header value "value": 105 or -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_long_request( + scenario=scenario, + template_url=self.response_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("long", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_long.metadata = {"url": "/header/response/prim/long"} # type: ignore + + @distributed_trace_async + async def param_float(self, scenario: str, value: float, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": + "negative", "value": -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 0.07 or -3.0. + :type value: float + :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", {})) + + request = rest_header.build_param_float_request( + scenario=scenario, + value=value, + template_url=self.param_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_float.metadata = {"url": "/header/param/prim/float"} # type: ignore + + @distributed_trace_async + async def response_float(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header value "value": 0.07 or -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_float_request( + scenario=scenario, + template_url=self.response_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("float", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_float.metadata = {"url": "/header/response/prim/float"} # type: ignore + + @distributed_trace_async + async def param_double(self, scenario: str, value: float, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": + "negative", "value": -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 7e120 or -3.0. + :type value: float + :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", {})) + + request = rest_header.build_param_double_request( + scenario=scenario, + value=value, + template_url=self.param_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_double.metadata = {"url": "/header/param/prim/double"} # type: ignore + + @distributed_trace_async + async def response_double(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header value "value": 7e120 or -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_double_request( + scenario=scenario, + template_url=self.response_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("float", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_double.metadata = {"url": "/header/response/prim/double"} # type: ignore + + @distributed_trace_async + async def param_bool(self, scenario: str, value: bool, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "true", "value": true or "scenario": + "false", "value": false. + + :param scenario: Send a post request with header values "scenario": "true" or "false". + :type scenario: str + :param value: Send a post request with header values true or false. + :type value: bool + :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", {})) + + request = rest_header.build_param_bool_request( + scenario=scenario, + value=value, + template_url=self.param_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_bool.metadata = {"url": "/header/param/prim/bool"} # type: ignore + + @distributed_trace_async + async def response_bool(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header value "value": true or false. + + :param scenario: Send a post request with header values "scenario": "true" or "false". + :type scenario: 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", {})) + + request = rest_header.build_response_bool_request( + scenario=scenario, + template_url=self.response_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("bool", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_bool.metadata = {"url": "/header/response/prim/bool"} # type: ignore + + @distributed_trace_async + async def param_string(self, scenario: str, value: Optional[str] = None, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps + over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: str + :param value: Send a post request with header values "The quick brown fox jumps over the lazy + dog" or null or "". + :type value: 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", {})) + + request = rest_header.build_param_string_request( + scenario=scenario, + value=value, + template_url=self.param_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_string.metadata = {"url": "/header/param/prim/string"} # type: ignore + + @distributed_trace_async + async def response_string(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: 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", {})) + + request = rest_header.build_response_string_request( + scenario=scenario, + template_url=self.response_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("str", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_string.metadata = {"url": "/header/response/prim/string"} # type: ignore + + @distributed_trace_async + async def param_date(self, scenario: str, value: datetime.date, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or + "scenario": "min", "value": "0001-01-01". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: str + :param value: Send a post request with header values "2010-01-01" or "0001-01-01". + :type value: ~datetime.date + :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", {})) + + request = rest_header.build_param_date_request( + scenario=scenario, + value=value, + template_url=self.param_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_date.metadata = {"url": "/header/param/prim/date"} # type: ignore + + @distributed_trace_async + async def response_date(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "2010-01-01" or "0001-01-01". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: 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", {})) + + request = rest_header.build_response_date_request( + scenario=scenario, + template_url=self.response_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("date", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_date.metadata = {"url": "/header/response/prim/date"} # type: ignore + + @distributed_trace_async + async def param_datetime(self, scenario: str, value: datetime.datetime, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or + "scenario": "min", "value": "0001-01-01T00:00:00Z". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: str + :param value: Send a post request with header values "2010-01-01T12:34:56Z" or + "0001-01-01T00:00:00Z". + :type value: ~datetime.datetime + :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", {})) + + request = rest_header.build_param_datetime_request( + scenario=scenario, + value=value, + template_url=self.param_datetime.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_datetime.metadata = {"url": "/header/param/prim/datetime"} # type: ignore + + @distributed_trace_async + async def response_datetime(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: 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", {})) + + request = rest_header.build_response_datetime_request( + scenario=scenario, + template_url=self.response_datetime.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("iso-8601", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_datetime.metadata = {"url": "/header/response/prim/datetime"} # type: ignore + + @distributed_trace_async + async def param_datetime_rfc1123( + self, scenario: str, value: Optional[datetime.datetime] = None, **kwargs: Any + ) -> None: + """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 + GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: str + :param value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, + 01 Jan 0001 00:00:00 GMT". + :type value: ~datetime.datetime + :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", {})) + + request = rest_header.build_param_datetime_rfc1123_request( + scenario=scenario, + value=value, + template_url=self.param_datetime_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_datetime_rfc1123.metadata = {"url": "/header/param/prim/datetimerfc1123"} # type: ignore + + @distributed_trace_async + async def response_datetime_rfc1123(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 + GMT". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: 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", {})) + + request = rest_header.build_response_datetime_rfc1123_request( + scenario=scenario, + template_url=self.response_datetime_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("rfc-1123", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_datetime_rfc1123.metadata = {"url": "/header/response/prim/datetimerfc1123"} # type: ignore + + @distributed_trace_async + async def param_duration(self, scenario: str, value: datetime.timedelta, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: str + :param value: Send a post request with header values "P123DT22H14M12.011S". + :type value: ~datetime.timedelta + :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", {})) + + request = rest_header.build_param_duration_request( + scenario=scenario, + value=value, + template_url=self.param_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_duration.metadata = {"url": "/header/param/prim/duration"} # type: ignore + + @distributed_trace_async + async def response_duration(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "P123DT22H14M12.011S". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: 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", {})) + + request = rest_header.build_response_duration_request( + scenario=scenario, + template_url=self.response_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("duration", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_duration.metadata = {"url": "/header/response/prim/duration"} # type: ignore + + @distributed_trace_async + async def param_byte(self, scenario: str, value: bytearray, **kwargs: Any) -> None: + """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: str + :param value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". + :type value: bytearray + :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", {})) + + request = rest_header.build_param_byte_request( + scenario=scenario, + value=value, + template_url=self.param_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_byte.metadata = {"url": "/header/param/prim/byte"} # type: ignore + + @distributed_trace_async + async def response_byte(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: 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", {})) + + request = rest_header.build_response_byte_request( + scenario=scenario, + template_url=self.response_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("bytearray", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_byte.metadata = {"url": "/header/response/prim/byte"} # type: ignore + + @distributed_trace_async + async def param_enum( + self, scenario: str, value: Optional[Union[str, "_models.GreyscaleColors"]] = None, **kwargs: Any + ) -> None: + """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": + "null", "value": null. + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: str + :param value: Send a post request with header values 'GREY'. + :type value: str or ~header.models.GreyscaleColors + :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", {})) + + request = rest_header.build_param_enum_request( + scenario=scenario, + value=value, + template_url=self.param_enum.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_enum.metadata = {"url": "/header/param/prim/enum"} # type: ignore + + @distributed_trace_async + async def response_enum(self, scenario: str, **kwargs: Any) -> None: + """Get a response with header values "GREY" or null. + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: 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", {})) + + request = rest_header.build_response_enum_request( + scenario=scenario, + template_url=self.response_enum.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("str", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_enum.metadata = {"url": "/header/response/prim/enum"} # type: ignore + + @distributed_trace_async + async def custom_request_id(self, **kwargs: Any) -> None: + """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the + request. + + :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", {})) + + request = rest_header.build_custom_request_id_request( + template_url=self.custom_request_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + custom_request_id.metadata = {"url": "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/models/_auto_rest_swagger_bat_header_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/_auto_rest_swagger_bat_header_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/models/_auto_rest_swagger_bat_header_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/_auto_rest_swagger_bat_header_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Header/header/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Header/header/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py new file mode 100644 index 00000000000..dc07a35d586 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/operations/_header_operations.py @@ -0,0 +1,1278 @@ +# 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 datetime +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 .. import models as _models +from .._rest import header as rest_header + +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]] + + +class HeaderOperations(object): + """HeaderOperations 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: ~header.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 param_existing_key( + self, + user_agent_parameter, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header value "User-Agent": "overwrite". + + :param user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". + :type user_agent_parameter: 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", {})) + + request = rest_header.build_param_existing_key_request( + user_agent_parameter=user_agent_parameter, + template_url=self.param_existing_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_existing_key.metadata = {"url": "/header/param/existingkey"} # type: ignore + + @distributed_trace + def response_existing_key( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "User-Agent": "overwrite". + + :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", {})) + + request = rest_header.build_response_existing_key_request( + template_url=self.response_existing_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["User-Agent"] = self._deserialize("str", response.headers.get("User-Agent")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_existing_key.metadata = {"url": "/header/response/existingkey"} # type: ignore + + @distributed_trace + def param_protected_key( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header value "Content-Type": "text/html". + + :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") # type: str + + request = rest_header.build_param_protected_key_request( + content_type=content_type, + template_url=self.param_protected_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_protected_key.metadata = {"url": "/header/param/protectedkey"} # type: ignore + + @distributed_trace + def response_protected_key( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "Content-Type": "text/html". + + :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", {})) + + request = rest_header.build_response_protected_key_request( + template_url=self.response_protected_key.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_protected_key.metadata = {"url": "/header/response/protectedkey"} # type: ignore + + @distributed_trace + def param_integer( + self, + scenario, # type: str + value, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": + "negative", "value": -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 1 or -2. + :type value: int + :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", {})) + + request = rest_header.build_param_integer_request( + scenario=scenario, + value=value, + template_url=self.param_integer.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_integer.metadata = {"url": "/header/param/prim/integer"} # type: ignore + + @distributed_trace + def response_integer( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "value": 1 or -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_integer_request( + scenario=scenario, + template_url=self.response_integer.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("int", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_integer.metadata = {"url": "/header/response/prim/integer"} # type: ignore + + @distributed_trace + def param_long( + self, + scenario, # type: str + value, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": + "negative", "value": -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 105 or -2. + :type value: long + :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", {})) + + request = rest_header.build_param_long_request( + scenario=scenario, + value=value, + template_url=self.param_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_long.metadata = {"url": "/header/param/prim/long"} # type: ignore + + @distributed_trace + def response_long( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "value": 105 or -2. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_long_request( + scenario=scenario, + template_url=self.response_long.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("long", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_long.metadata = {"url": "/header/response/prim/long"} # type: ignore + + @distributed_trace + def param_float( + self, + scenario, # type: str + value, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": + "negative", "value": -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 0.07 or -3.0. + :type value: float + :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", {})) + + request = rest_header.build_param_float_request( + scenario=scenario, + value=value, + template_url=self.param_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_float.metadata = {"url": "/header/param/prim/float"} # type: ignore + + @distributed_trace + def response_float( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "value": 0.07 or -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_float_request( + scenario=scenario, + template_url=self.response_float.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("float", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_float.metadata = {"url": "/header/response/prim/float"} # type: ignore + + @distributed_trace + def param_double( + self, + scenario, # type: str + value, # type: float + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": + "negative", "value": -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: str + :param value: Send a post request with header values 7e120 or -3.0. + :type value: float + :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", {})) + + request = rest_header.build_param_double_request( + scenario=scenario, + value=value, + template_url=self.param_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_double.metadata = {"url": "/header/param/prim/double"} # type: ignore + + @distributed_trace + def response_double( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "value": 7e120 or -3.0. + + :param scenario: Send a post request with header values "scenario": "positive" or "negative". + :type scenario: 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", {})) + + request = rest_header.build_response_double_request( + scenario=scenario, + template_url=self.response_double.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("float", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_double.metadata = {"url": "/header/response/prim/double"} # type: ignore + + @distributed_trace + def param_bool( + self, + scenario, # type: str + value, # type: bool + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "true", "value": true or "scenario": + "false", "value": false. + + :param scenario: Send a post request with header values "scenario": "true" or "false". + :type scenario: str + :param value: Send a post request with header values true or false. + :type value: bool + :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", {})) + + request = rest_header.build_param_bool_request( + scenario=scenario, + value=value, + template_url=self.param_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_bool.metadata = {"url": "/header/param/prim/bool"} # type: ignore + + @distributed_trace + def response_bool( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header value "value": true or false. + + :param scenario: Send a post request with header values "scenario": "true" or "false". + :type scenario: 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", {})) + + request = rest_header.build_response_bool_request( + scenario=scenario, + template_url=self.response_bool.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("bool", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_bool.metadata = {"url": "/header/response/prim/bool"} # type: ignore + + @distributed_trace + def param_string( + self, + scenario, # type: str + value=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps + over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: str + :param value: Send a post request with header values "The quick brown fox jumps over the lazy + dog" or null or "". + :type value: 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", {})) + + request = rest_header.build_param_string_request( + scenario=scenario, + value=value, + template_url=self.param_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_string.metadata = {"url": "/header/param/prim/string"} # type: ignore + + @distributed_trace + def response_string( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: 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", {})) + + request = rest_header.build_response_string_request( + scenario=scenario, + template_url=self.response_string.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("str", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_string.metadata = {"url": "/header/response/prim/string"} # type: ignore + + @distributed_trace + def param_date( + self, + scenario, # type: str + value, # type: datetime.date + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or + "scenario": "min", "value": "0001-01-01". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: str + :param value: Send a post request with header values "2010-01-01" or "0001-01-01". + :type value: ~datetime.date + :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", {})) + + request = rest_header.build_param_date_request( + scenario=scenario, + value=value, + template_url=self.param_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_date.metadata = {"url": "/header/param/prim/date"} # type: ignore + + @distributed_trace + def response_date( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "2010-01-01" or "0001-01-01". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: 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", {})) + + request = rest_header.build_response_date_request( + scenario=scenario, + template_url=self.response_date.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("date", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_date.metadata = {"url": "/header/response/prim/date"} # type: ignore + + @distributed_trace + def param_datetime( + self, + scenario, # type: str + value, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or + "scenario": "min", "value": "0001-01-01T00:00:00Z". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: str + :param value: Send a post request with header values "2010-01-01T12:34:56Z" or + "0001-01-01T00:00:00Z". + :type value: ~datetime.datetime + :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", {})) + + request = rest_header.build_param_datetime_request( + scenario=scenario, + value=value, + template_url=self.param_datetime.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_datetime.metadata = {"url": "/header/param/prim/datetime"} # type: ignore + + @distributed_trace + def response_datetime( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: 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", {})) + + request = rest_header.build_response_datetime_request( + scenario=scenario, + template_url=self.response_datetime.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("iso-8601", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_datetime.metadata = {"url": "/header/response/prim/datetime"} # type: ignore + + @distributed_trace + def param_datetime_rfc1123( + self, + scenario, # type: str + value=None, # type: Optional[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 + GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: str + :param value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, + 01 Jan 0001 00:00:00 GMT". + :type value: ~datetime.datetime + :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", {})) + + request = rest_header.build_param_datetime_rfc1123_request( + scenario=scenario, + value=value, + template_url=self.param_datetime_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_datetime_rfc1123.metadata = {"url": "/header/param/prim/datetimerfc1123"} # type: ignore + + @distributed_trace + def response_datetime_rfc1123( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 + GMT". + + :param scenario: Send a post request with header values "scenario": "valid" or "min". + :type scenario: 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", {})) + + request = rest_header.build_response_datetime_rfc1123_request( + scenario=scenario, + template_url=self.response_datetime_rfc1123.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("rfc-1123", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_datetime_rfc1123.metadata = {"url": "/header/response/prim/datetimerfc1123"} # type: ignore + + @distributed_trace + def param_duration( + self, + scenario, # type: str + value, # type: datetime.timedelta + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: str + :param value: Send a post request with header values "P123DT22H14M12.011S". + :type value: ~datetime.timedelta + :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", {})) + + request = rest_header.build_param_duration_request( + scenario=scenario, + value=value, + template_url=self.param_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_duration.metadata = {"url": "/header/param/prim/duration"} # type: ignore + + @distributed_trace + def response_duration( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "P123DT22H14M12.011S". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: 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", {})) + + request = rest_header.build_response_duration_request( + scenario=scenario, + template_url=self.response_duration.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("duration", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_duration.metadata = {"url": "/header/response/prim/duration"} # type: ignore + + @distributed_trace + def param_byte( + self, + scenario, # type: str + value, # type: bytearray + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: str + :param value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". + :type value: bytearray + :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", {})) + + request = rest_header.build_param_byte_request( + scenario=scenario, + value=value, + template_url=self.param_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_byte.metadata = {"url": "/header/param/prim/byte"} # type: ignore + + @distributed_trace + def response_byte( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". + + :param scenario: Send a post request with header values "scenario": "valid". + :type scenario: 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", {})) + + request = rest_header.build_response_byte_request( + scenario=scenario, + template_url=self.response_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("bytearray", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_byte.metadata = {"url": "/header/response/prim/byte"} # type: ignore + + @distributed_trace + def param_enum( + self, + scenario, # type: str + value=None, # type: Optional[Union[str, "_models.GreyscaleColors"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": + "null", "value": null. + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: str + :param value: Send a post request with header values 'GREY'. + :type value: str or ~header.models.GreyscaleColors + :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", {})) + + request = rest_header.build_param_enum_request( + scenario=scenario, + value=value, + template_url=self.param_enum.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + param_enum.metadata = {"url": "/header/param/prim/enum"} # type: ignore + + @distributed_trace + def response_enum( + self, + scenario, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get a response with header values "GREY" or null. + + :param scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :type scenario: 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", {})) + + request = rest_header.build_response_enum_request( + scenario=scenario, + template_url=self.response_enum.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["value"] = self._deserialize("str", response.headers.get("value")) + + if cls: + return cls(pipeline_response, None, response_headers) + + response_enum.metadata = {"url": "/header/response/prim/enum"} # type: ignore + + @distributed_trace + def custom_request_id( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the + request. + + :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", {})) + + request = rest_header.build_custom_request_id_request( + template_url=self.custom_request_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + custom_request_id.metadata = {"url": "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/Header/header/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Header/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Header/setup.py new file mode 100644 index 00000000000..6e39f645217 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Header/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 = "autorestswaggerbatheaderservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATHeaderService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATHeaderService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py new file mode 100644 index 00000000000..fa4a6867d95 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py @@ -0,0 +1,128 @@ +# 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 AutoRestHttpInfrastructureTestServiceConfiguration +from .operations import ( + HttpClientFailureOperations, + HttpFailureOperations, + HttpRedirectsOperations, + HttpRetryOperations, + HttpServerFailureOperations, + HttpSuccessOperations, + MultipleResponsesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHttpInfrastructureTestService(object): + """Test Infrastructure for AutoRest. + + :ivar http_failure: HttpFailureOperations operations + :vartype http_failure: httpinfrastructure.operations.HttpFailureOperations + :ivar http_success: HttpSuccessOperations operations + :vartype http_success: httpinfrastructure.operations.HttpSuccessOperations + :ivar http_redirects: HttpRedirectsOperations operations + :vartype http_redirects: httpinfrastructure.operations.HttpRedirectsOperations + :ivar http_client_failure: HttpClientFailureOperations operations + :vartype http_client_failure: httpinfrastructure.operations.HttpClientFailureOperations + :ivar http_server_failure: HttpServerFailureOperations operations + :vartype http_server_failure: httpinfrastructure.operations.HttpServerFailureOperations + :ivar http_retry: HttpRetryOperations operations + :vartype http_retry: httpinfrastructure.operations.HttpRetryOperations + :ivar multiple_responses: MultipleResponsesOperations operations + :vartype multiple_responses: httpinfrastructure.operations.MultipleResponsesOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHttpInfrastructureTestServiceConfiguration(**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.http_failure = HttpFailureOperations(self._client, self._config, self._serialize, self._deserialize) + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) + self.http_redirects = HttpRedirectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.http_client_failure = HttpClientFailureOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.http_server_failure = HttpServerFailureOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.http_retry = HttpRetryOperations(self._client, self._config, self._serialize, self._deserialize) + self.multiple_responses = MultipleResponsesOperations( + 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. + + We have helper methods to create requests specific to this service in `httpinfrastructure.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from httpinfrastructure._rest import http_failure + >>> request = http_failure.build_get_empty_error_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHttpInfrastructureTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_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/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/__init__.py new file mode 100644 index 00000000000..014c45ac99e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/__init__.py @@ -0,0 +1,91 @@ +# 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_head400_request + from ._request_builders_py3 import build_get400_request + from ._request_builders_py3 import build_options400_request + from ._request_builders_py3 import build_put400_request + from ._request_builders_py3 import build_patch400_request + from ._request_builders_py3 import build_post400_request + from ._request_builders_py3 import build_delete400_request + from ._request_builders_py3 import build_head401_request + from ._request_builders_py3 import build_get402_request + from ._request_builders_py3 import build_options403_request + from ._request_builders_py3 import build_get403_request + from ._request_builders_py3 import build_put404_request + from ._request_builders_py3 import build_patch405_request + from ._request_builders_py3 import build_post406_request + from ._request_builders_py3 import build_delete407_request + from ._request_builders_py3 import build_put409_request + from ._request_builders_py3 import build_head410_request + from ._request_builders_py3 import build_get411_request + from ._request_builders_py3 import build_options412_request + from ._request_builders_py3 import build_get412_request + from ._request_builders_py3 import build_put413_request + from ._request_builders_py3 import build_patch414_request + from ._request_builders_py3 import build_post415_request + from ._request_builders_py3 import build_get416_request + from ._request_builders_py3 import build_delete417_request + from ._request_builders_py3 import build_head429_request +except (SyntaxError, ImportError): + from ._request_builders import build_head400_request # type: ignore + from ._request_builders import build_get400_request # type: ignore + from ._request_builders import build_options400_request # type: ignore + from ._request_builders import build_put400_request # type: ignore + from ._request_builders import build_patch400_request # type: ignore + from ._request_builders import build_post400_request # type: ignore + from ._request_builders import build_delete400_request # type: ignore + from ._request_builders import build_head401_request # type: ignore + from ._request_builders import build_get402_request # type: ignore + from ._request_builders import build_options403_request # type: ignore + from ._request_builders import build_get403_request # type: ignore + from ._request_builders import build_put404_request # type: ignore + from ._request_builders import build_patch405_request # type: ignore + from ._request_builders import build_post406_request # type: ignore + from ._request_builders import build_delete407_request # type: ignore + from ._request_builders import build_put409_request # type: ignore + from ._request_builders import build_head410_request # type: ignore + from ._request_builders import build_get411_request # type: ignore + from ._request_builders import build_options412_request # type: ignore + from ._request_builders import build_get412_request # type: ignore + from ._request_builders import build_put413_request # type: ignore + from ._request_builders import build_patch414_request # type: ignore + from ._request_builders import build_post415_request # type: ignore + from ._request_builders import build_get416_request # type: ignore + from ._request_builders import build_delete417_request # type: ignore + from ._request_builders import build_head429_request # type: ignore + +__all__ = [ + "build_head400_request", + "build_get400_request", + "build_options400_request", + "build_put400_request", + "build_patch400_request", + "build_post400_request", + "build_delete400_request", + "build_head401_request", + "build_get402_request", + "build_options403_request", + "build_get403_request", + "build_put404_request", + "build_patch405_request", + "build_post406_request", + "build_delete407_request", + "build_put409_request", + "build_head410_request", + "build_get411_request", + "build_options412_request", + "build_get412_request", + "build_put413_request", + "build_patch414_request", + "build_post415_request", + "build_get416_request", + "build_delete417_request", + "build_head429_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/_request_builders.py new file mode 100644 index 00000000000..fa2fd51e628 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/_request_builders.py @@ -0,0 +1,954 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head401_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 401 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/401') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get402_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 402 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/402') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options403_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/403') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get403_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/403') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/404') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch405_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 405 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/405') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post406_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 406 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/406') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete407_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 407 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/407') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put409_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 409 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/409') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head410_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 410 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/410') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get411_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 411 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/411') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options412_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/412') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get412_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/412') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put413_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 413 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/413') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch414_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 414 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/414') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post415_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 415 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/415') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get416_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 416 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/416') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete417_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 417 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/417') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head429_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 429 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/429') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/_request_builders_py3.py new file mode 100644 index 00000000000..88816b49424 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_client_failure/_request_builders_py3.py @@ -0,0 +1,741 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head400_request(**kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get400_request(**kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options400_request(**kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_put400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head401_request(**kwargs: Any) -> HttpRequest: + """Return 401 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/401") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get402_request(**kwargs: Any) -> HttpRequest: + """Return 402 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/402") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options403_request(**kwargs: Any) -> HttpRequest: + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/403") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_get403_request(**kwargs: Any) -> HttpRequest: + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/403") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put404_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 404 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/404") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch405_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 405 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/405") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post406_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 406 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/406") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete407_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 407 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/407") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put409_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 409 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/409") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head410_request(**kwargs: Any) -> HttpRequest: + """Return 410 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/410") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get411_request(**kwargs: Any) -> HttpRequest: + """Return 411 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/411") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options412_request(**kwargs: Any) -> HttpRequest: + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/412") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_get412_request(**kwargs: Any) -> HttpRequest: + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/412") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put413_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 413 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/413") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch414_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 414 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/414") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post415_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 415 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/415") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get416_request(**kwargs: Any) -> HttpRequest: + """Return 416 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/416") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_delete417_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 417 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/417") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head429_request(**kwargs: Any) -> HttpRequest: + """Return 429 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/429") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/__init__.py new file mode 100644 index 00000000000..9aa026c9102 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/__init__.py @@ -0,0 +1,22 @@ +# 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_get_empty_error_request + from ._request_builders_py3 import build_get_no_model_error_request + from ._request_builders_py3 import build_get_no_model_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_error_request # type: ignore + from ._request_builders import build_get_no_model_error_request # type: ignore + from ._request_builders import build_get_no_model_empty_request # type: ignore + +__all__ = [ + "build_get_empty_error_request", + "build_get_no_model_error_request", + "build_get_no_model_empty_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/_request_builders.py new file mode 100644 index 00000000000..37537fc261e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/_request_builders.py @@ -0,0 +1,111 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_error_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/emptybody/error') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_no_model_error_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/nomodel/error') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_no_model_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty response from server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/nomodel/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/_request_builders_py3.py new file mode 100644 index 00000000000..d08e3bc8822 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_failure/_request_builders_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 Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_error_request(**kwargs: Any) -> HttpRequest: + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/emptybody/error") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_no_model_error_request(**kwargs: Any) -> HttpRequest: + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/nomodel/error") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_no_model_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty response from server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/nomodel/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/__init__.py new file mode 100644 index 00000000000..32da62631a7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/__init__.py @@ -0,0 +1,61 @@ +# 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_head300_request + from ._request_builders_py3 import build_get300_request + from ._request_builders_py3 import build_head301_request + from ._request_builders_py3 import build_get301_request + from ._request_builders_py3 import build_put301_request + from ._request_builders_py3 import build_head302_request + from ._request_builders_py3 import build_get302_request + from ._request_builders_py3 import build_patch302_request + from ._request_builders_py3 import build_post303_request + from ._request_builders_py3 import build_head307_request + from ._request_builders_py3 import build_get307_request + from ._request_builders_py3 import build_options307_request + from ._request_builders_py3 import build_put307_request + from ._request_builders_py3 import build_patch307_request + from ._request_builders_py3 import build_post307_request + from ._request_builders_py3 import build_delete307_request +except (SyntaxError, ImportError): + from ._request_builders import build_head300_request # type: ignore + from ._request_builders import build_get300_request # type: ignore + from ._request_builders import build_head301_request # type: ignore + from ._request_builders import build_get301_request # type: ignore + from ._request_builders import build_put301_request # type: ignore + from ._request_builders import build_head302_request # type: ignore + from ._request_builders import build_get302_request # type: ignore + from ._request_builders import build_patch302_request # type: ignore + from ._request_builders import build_post303_request # type: ignore + from ._request_builders import build_head307_request # type: ignore + from ._request_builders import build_get307_request # type: ignore + from ._request_builders import build_options307_request # type: ignore + from ._request_builders import build_put307_request # type: ignore + from ._request_builders import build_patch307_request # type: ignore + from ._request_builders import build_post307_request # type: ignore + from ._request_builders import build_delete307_request # type: ignore + +__all__ = [ + "build_head300_request", + "build_get300_request", + "build_head301_request", + "build_get301_request", + "build_put301_request", + "build_head302_request", + "build_get302_request", + "build_patch302_request", + "build_post303_request", + "build_head307_request", + "build_get307_request", + "build_options307_request", + "build_put307_request", + "build_patch307_request", + "build_post307_request", + "build_delete307_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/_request_builders.py new file mode 100644 index 00000000000..401ea826523 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/_request_builders.py @@ -0,0 +1,587 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head300_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get300_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head301_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/301') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get301_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/301') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put301_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 301. This request should not be automatically + redirected, but should return the received 301 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/301') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head302_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/302') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get302_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/302') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch302_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returns 302. This request should not be automatically + redirected, but should return the received 302 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/302') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post303_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 303. This request should be automatically + redirected usign a get, ultimately returning a 200 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/303') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Redirect with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Redirect get with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """options redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/_request_builders_py3.py new file mode 100644 index 00000000000..4c8c06460c6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_redirects/_request_builders_py3.py @@ -0,0 +1,454 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head300_request(**kwargs: Any) -> HttpRequest: + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get300_request(**kwargs: Any) -> HttpRequest: + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_head301_request(**kwargs: Any) -> HttpRequest: + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/301") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get301_request(**kwargs: Any) -> HttpRequest: + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/301") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put301_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 301. This request should not be automatically + redirected, but should return the received 301 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/301") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head302_request(**kwargs: Any) -> HttpRequest: + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/302") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get302_request(**kwargs: Any) -> HttpRequest: + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/302") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_patch302_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returns 302. This request should not be automatically + redirected, but should return the received 302 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/302") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post303_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 303. This request should be automatically + redirected usign a get, ultimately returning a 200 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/303") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head307_request(**kwargs: Any) -> HttpRequest: + """Redirect with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get307_request(**kwargs: Any) -> HttpRequest: + """Redirect get with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options307_request(**kwargs: Any) -> HttpRequest: + """options redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_put307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/__init__.py new file mode 100644 index 00000000000..c645a81dabd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/__init__.py @@ -0,0 +1,40 @@ +# 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_head408_request + from ._request_builders_py3 import build_put500_request + from ._request_builders_py3 import build_patch500_request + from ._request_builders_py3 import build_get502_request + from ._request_builders_py3 import build_options502_request + from ._request_builders_py3 import build_post503_request + from ._request_builders_py3 import build_delete503_request + from ._request_builders_py3 import build_put504_request + from ._request_builders_py3 import build_patch504_request +except (SyntaxError, ImportError): + from ._request_builders import build_head408_request # type: ignore + from ._request_builders import build_put500_request # type: ignore + from ._request_builders import build_patch500_request # type: ignore + from ._request_builders import build_get502_request # type: ignore + from ._request_builders import build_options502_request # type: ignore + from ._request_builders import build_post503_request # type: ignore + from ._request_builders import build_delete503_request # type: ignore + from ._request_builders import build_put504_request # type: ignore + from ._request_builders import build_patch504_request # type: ignore + +__all__ = [ + "build_head408_request", + "build_put500_request", + "build_patch500_request", + "build_get502_request", + "build_options502_request", + "build_post503_request", + "build_delete503_request", + "build_put504_request", + "build_patch504_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/_request_builders.py new file mode 100644 index 00000000000..c4588eea76b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/_request_builders.py @@ -0,0 +1,357 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head408_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 408 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/408') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put500_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/500') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch500_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/500') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get502_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/502') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options502_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/502') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post503_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/503') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete503_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/503') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put504_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/504') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch504_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/504') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/_request_builders_py3.py new file mode 100644 index 00000000000..1187688273b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_retry/_request_builders_py3.py @@ -0,0 +1,280 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head408_request(**kwargs: Any) -> HttpRequest: + """Return 408 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/408") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_put500_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/500") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch500_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/500") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get502_request(**kwargs: Any) -> HttpRequest: + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/502") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options502_request(**kwargs: Any) -> HttpRequest: + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/502") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_post503_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/503") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete503_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/503") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put504_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/504") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch504_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/504") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/__init__.py new file mode 100644 index 00000000000..6c9509398a2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/__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 ._request_builders_py3 import build_head501_request + from ._request_builders_py3 import build_get501_request + from ._request_builders_py3 import build_post505_request + from ._request_builders_py3 import build_delete505_request +except (SyntaxError, ImportError): + from ._request_builders import build_head501_request # type: ignore + from ._request_builders import build_get501_request # type: ignore + from ._request_builders import build_post505_request # type: ignore + from ._request_builders import build_delete505_request # type: ignore + +__all__ = [ + "build_head501_request", + "build_get501_request", + "build_post505_request", + "build_delete505_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/_request_builders.py new file mode 100644 index 00000000000..b6144a0f9fd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/_request_builders.py @@ -0,0 +1,162 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head501_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/501') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get501_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/501') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post505_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/505') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete505_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/505') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/_request_builders_py3.py new file mode 100644 index 00000000000..8aa88ac45d6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_server_failure/_request_builders_py3.py @@ -0,0 +1,125 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head501_request(**kwargs: Any) -> HttpRequest: + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/501") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get501_request(**kwargs: Any) -> HttpRequest: + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/501") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_post505_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/505") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete505_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/505") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/__init__.py new file mode 100644 index 00000000000..6d355239b28 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/__init__.py @@ -0,0 +1,70 @@ +# 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_head200_request + from ._request_builders_py3 import build_get200_request + from ._request_builders_py3 import build_options200_request + from ._request_builders_py3 import build_put200_request + from ._request_builders_py3 import build_patch200_request + from ._request_builders_py3 import build_post200_request + from ._request_builders_py3 import build_delete200_request + from ._request_builders_py3 import build_put201_request + from ._request_builders_py3 import build_post201_request + from ._request_builders_py3 import build_put202_request + from ._request_builders_py3 import build_patch202_request + from ._request_builders_py3 import build_post202_request + from ._request_builders_py3 import build_delete202_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_put204_request + from ._request_builders_py3 import build_patch204_request + from ._request_builders_py3 import build_post204_request + from ._request_builders_py3 import build_delete204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_get200_request # type: ignore + from ._request_builders import build_options200_request # type: ignore + from ._request_builders import build_put200_request # type: ignore + from ._request_builders import build_patch200_request # type: ignore + from ._request_builders import build_post200_request # type: ignore + from ._request_builders import build_delete200_request # type: ignore + from ._request_builders import build_put201_request # type: ignore + from ._request_builders import build_post201_request # type: ignore + from ._request_builders import build_put202_request # type: ignore + from ._request_builders import build_patch202_request # type: ignore + from ._request_builders import build_post202_request # type: ignore + from ._request_builders import build_delete202_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_put204_request # type: ignore + from ._request_builders import build_patch204_request # type: ignore + from ._request_builders import build_post204_request # type: ignore + from ._request_builders import build_delete204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_get200_request", + "build_options200_request", + "build_put200_request", + "build_patch200_request", + "build_post200_request", + "build_delete200_request", + "build_put201_request", + "build_post201_request", + "build_put202_request", + "build_patch202_request", + "build_post202_request", + "build_delete202_request", + "build_head204_request", + "build_put204_request", + "build_patch204_request", + "build_post204_request", + "build_delete204_request", + "build_head404_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/_request_builders.py new file mode 100644 index 00000000000..a3fef5cc9ff --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/_request_builders.py @@ -0,0 +1,747 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Options 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put boolean value true returning 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returning 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post bollean value true in request that returns a 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete simple boolean value true returns 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 201. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/201') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post201_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 201 (Created). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/201') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returns 202. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete true Boolean value in request returns 202 (accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..ec27b92a96b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/http_success/_request_builders_py3.py @@ -0,0 +1,590 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get200_request(**kwargs: Any) -> HttpRequest: + """Get 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options200_request(**kwargs: Any) -> HttpRequest: + """Options 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_put200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put boolean value true returning 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returning 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post bollean value true in request that returns a 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete simple boolean value true returns 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 201. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/201") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post201_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 201 (Created). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/201") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returns 202. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete true Boolean value in request returns 202 (accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_put204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/__init__.py new file mode 100644 index 00000000000..6a4f9bc9a49 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/__init__.py @@ -0,0 +1,115 @@ +# 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_get200_model204_no_model_default_error200_valid_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error204_valid_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error201_invalid_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error202_none_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error400_valid_request + from ._request_builders_py3 import build_get200_model201_model_default_error200_valid_request + from ._request_builders_py3 import build_get200_model201_model_default_error201_valid_request + from ._request_builders_py3 import build_get200_model201_model_default_error400_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error200_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error201_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error404_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error400_valid_request + from ._request_builders_py3 import build_get202_none204_none_default_error202_none_request + from ._request_builders_py3 import build_get202_none204_none_default_error204_none_request + from ._request_builders_py3 import build_get202_none204_none_default_error400_valid_request + from ._request_builders_py3 import build_get202_none204_none_default_none202_invalid_request + from ._request_builders_py3 import build_get202_none204_none_default_none204_none_request + from ._request_builders_py3 import build_get202_none204_none_default_none400_none_request + from ._request_builders_py3 import build_get202_none204_none_default_none400_invalid_request + from ._request_builders_py3 import build_get_default_model_a200_valid_request + from ._request_builders_py3 import build_get_default_model_a200_none_request + from ._request_builders_py3 import build_get_default_model_a400_valid_request + from ._request_builders_py3 import build_get_default_model_a400_none_request + from ._request_builders_py3 import build_get_default_none200_invalid_request + from ._request_builders_py3 import build_get_default_none200_none_request + from ._request_builders_py3 import build_get_default_none400_invalid_request + from ._request_builders_py3 import build_get_default_none400_none_request + from ._request_builders_py3 import build_get200_model_a200_none_request + from ._request_builders_py3 import build_get200_model_a200_valid_request + from ._request_builders_py3 import build_get200_model_a200_invalid_request + from ._request_builders_py3 import build_get200_model_a400_none_request + from ._request_builders_py3 import build_get200_model_a400_valid_request + from ._request_builders_py3 import build_get200_model_a400_invalid_request + from ._request_builders_py3 import build_get200_model_a202_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get200_model204_no_model_default_error200_valid_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error204_valid_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error201_invalid_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error202_none_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error400_valid_request # type: ignore + from ._request_builders import build_get200_model201_model_default_error200_valid_request # type: ignore + from ._request_builders import build_get200_model201_model_default_error201_valid_request # type: ignore + from ._request_builders import build_get200_model201_model_default_error400_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error200_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error201_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error404_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error400_valid_request # type: ignore + from ._request_builders import build_get202_none204_none_default_error202_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_error204_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_error400_valid_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none202_invalid_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none204_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none400_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none400_invalid_request # type: ignore + from ._request_builders import build_get_default_model_a200_valid_request # type: ignore + from ._request_builders import build_get_default_model_a200_none_request # type: ignore + from ._request_builders import build_get_default_model_a400_valid_request # type: ignore + from ._request_builders import build_get_default_model_a400_none_request # type: ignore + from ._request_builders import build_get_default_none200_invalid_request # type: ignore + from ._request_builders import build_get_default_none200_none_request # type: ignore + from ._request_builders import build_get_default_none400_invalid_request # type: ignore + from ._request_builders import build_get_default_none400_none_request # type: ignore + from ._request_builders import build_get200_model_a200_none_request # type: ignore + from ._request_builders import build_get200_model_a200_valid_request # type: ignore + from ._request_builders import build_get200_model_a200_invalid_request # type: ignore + from ._request_builders import build_get200_model_a400_none_request # type: ignore + from ._request_builders import build_get200_model_a400_valid_request # type: ignore + from ._request_builders import build_get200_model_a400_invalid_request # type: ignore + from ._request_builders import build_get200_model_a202_valid_request # type: ignore + +__all__ = [ + "build_get200_model204_no_model_default_error200_valid_request", + "build_get200_model204_no_model_default_error204_valid_request", + "build_get200_model204_no_model_default_error201_invalid_request", + "build_get200_model204_no_model_default_error202_none_request", + "build_get200_model204_no_model_default_error400_valid_request", + "build_get200_model201_model_default_error200_valid_request", + "build_get200_model201_model_default_error201_valid_request", + "build_get200_model201_model_default_error400_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error200_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error201_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error404_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error400_valid_request", + "build_get202_none204_none_default_error202_none_request", + "build_get202_none204_none_default_error204_none_request", + "build_get202_none204_none_default_error400_valid_request", + "build_get202_none204_none_default_none202_invalid_request", + "build_get202_none204_none_default_none204_none_request", + "build_get202_none204_none_default_none400_none_request", + "build_get202_none204_none_default_none400_invalid_request", + "build_get_default_model_a200_valid_request", + "build_get_default_model_a200_none_request", + "build_get_default_model_a400_valid_request", + "build_get_default_model_a400_none_request", + "build_get_default_none200_invalid_request", + "build_get_default_none200_none_request", + "build_get_default_none400_invalid_request", + "build_get_default_none400_none_request", + "build_get200_model_a200_none_request", + "build_get200_model_a200_valid_request", + "build_get200_model_a200_invalid_request", + "build_get200_model_a400_none_request", + "build_get200_model_a400_valid_request", + "build_get200_model_a400_invalid_request", + "build_get200_model_a202_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/_request_builders.py new file mode 100644 index 00000000000..c6fbfcd4951 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/_request_builders.py @@ -0,0 +1,1025 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get200_model204_no_model_default_error200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error204_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/204/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error201_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 201 response with valid payload: {'statusCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/201/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error202_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with no payload:. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/202/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model201_model_default_error200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/B/default/Error/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model201_model_default_error201_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/B/default/Error/response/201/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model201_model_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/B/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error201_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'httpCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error404_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'httpStatusCode': '404'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_error202_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/Error/response/202/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_error204_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/Error/response/204/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_none202_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/202/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get202_none204_none_default_none204_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/204/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get202_none204_none_default_none400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/400/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get202_none204_none_default_none400_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/400/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_model_a200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_model_a200_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/200/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_model_a400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_model_a400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/400/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_none200_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with invalid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/200/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_none200_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/200/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_none400_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/400/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_none400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/400/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get200_model_a200_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with no payload, when a payload is expected - client should return a null + object of thde type for model A. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/200/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with payload {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a200_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/200/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload client should treat as an http error with no error model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/400/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with payload {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a400_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/400/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a202_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with payload {'statusCode': '202'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/202/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/_request_builders_py3.py new file mode 100644 index 00000000000..125b35cd259 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_rest/multiple_responses/_request_builders_py3.py @@ -0,0 +1,756 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get200_model204_no_model_default_error200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error204_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/204/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error201_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 201 response with valid payload: {'statusCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/201/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error202_none_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with no payload:. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/202/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model201_model_default_error200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/B/default/Error/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model201_model_default_error201_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/B/default/Error/response/201/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model201_model_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/B/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error201_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'httpCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error404_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'httpStatusCode': '404'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_error202_none_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/Error/response/202/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_error204_none_request(**kwargs: Any) -> HttpRequest: + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/Error/response/204/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_none202_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/202/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get202_none204_none_default_none204_none_request(**kwargs: Any) -> HttpRequest: + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/204/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get202_none204_none_default_none400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/400/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get202_none204_none_default_none400_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/400/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_model_a200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_model_a200_none_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/200/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_model_a400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_model_a400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/400/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_none200_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with invalid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/200/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_none200_none_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/200/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_none400_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/400/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_none400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/400/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get200_model_a200_none_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with no payload, when a payload is expected - client should return a null + object of thde type for model A. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/200/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with payload {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a200_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/200/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload client should treat as an http error with no error model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/400/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with payload {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a400_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/400/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a202_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with payload {'statusCode': '202'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/202/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py new file mode 100644 index 00000000000..d5befa639d3 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py @@ -0,0 +1,110 @@ +# 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 AutoRestHttpInfrastructureTestServiceConfiguration +from .operations import ( + HttpClientFailureOperations, + HttpFailureOperations, + HttpRedirectsOperations, + HttpRetryOperations, + HttpServerFailureOperations, + HttpSuccessOperations, + MultipleResponsesOperations, +) + + +class AutoRestHttpInfrastructureTestService: + """Test Infrastructure for AutoRest. + + :ivar http_failure: HttpFailureOperations operations + :vartype http_failure: httpinfrastructure.aio.operations.HttpFailureOperations + :ivar http_success: HttpSuccessOperations operations + :vartype http_success: httpinfrastructure.aio.operations.HttpSuccessOperations + :ivar http_redirects: HttpRedirectsOperations operations + :vartype http_redirects: httpinfrastructure.aio.operations.HttpRedirectsOperations + :ivar http_client_failure: HttpClientFailureOperations operations + :vartype http_client_failure: httpinfrastructure.aio.operations.HttpClientFailureOperations + :ivar http_server_failure: HttpServerFailureOperations operations + :vartype http_server_failure: httpinfrastructure.aio.operations.HttpServerFailureOperations + :ivar http_retry: HttpRetryOperations operations + :vartype http_retry: httpinfrastructure.aio.operations.HttpRetryOperations + :ivar multiple_responses: MultipleResponsesOperations operations + :vartype multiple_responses: httpinfrastructure.aio.operations.MultipleResponsesOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHttpInfrastructureTestServiceConfiguration(**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.http_failure = HttpFailureOperations(self._client, self._config, self._serialize, self._deserialize) + self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize) + self.http_redirects = HttpRedirectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.http_client_failure = HttpClientFailureOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.http_server_failure = HttpServerFailureOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.http_retry = HttpRetryOperations(self._client, self._config, self._serialize, self._deserialize) + self.multiple_responses = MultipleResponsesOperations( + 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. + + We have helper methods to create requests specific to this service in `httpinfrastructure.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from httpinfrastructure._rest import http_failure + >>> request = http_failure.build_get_empty_error_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHttpInfrastructureTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py new file mode 100644 index 00000000000..dbc3a8efba3 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_client_failure_operations.py @@ -0,0 +1,1039 @@ +# 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 ... import models as _models +from ..._rest import http_client_failure as rest_http_client_failure + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpClientFailureOperations: + """HttpClientFailureOperations 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: ~httpinfrastructure.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 head400(self, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head400_request( + template_url=self.head400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def get400(self, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get400_request( + template_url=self.get400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def options400(self, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_options400_request( + template_url=self.options400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + options400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def put400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put400_request( + content_type=content_type, + json=json, + template_url=self.put400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def patch400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_patch400_request( + content_type=content_type, + json=json, + template_url=self.patch400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def post400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_post400_request( + content_type=content_type, + json=json, + template_url=self.post400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def delete400(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_delete400_request( + content_type=content_type, + json=json, + template_url=self.delete400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace_async + async def head401(self, **kwargs: Any) -> None: + """Return 401 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head401_request( + template_url=self.head401.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head401.metadata = {"url": "/http/failure/client/401"} # type: ignore + + @distributed_trace_async + async def get402(self, **kwargs: Any) -> None: + """Return 402 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get402_request( + template_url=self.get402.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get402.metadata = {"url": "/http/failure/client/402"} # type: ignore + + @distributed_trace_async + async def options403(self, **kwargs: Any) -> None: + """Return 403 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_options403_request( + template_url=self.options403.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + options403.metadata = {"url": "/http/failure/client/403"} # type: ignore + + @distributed_trace_async + async def get403(self, **kwargs: Any) -> None: + """Return 403 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get403_request( + template_url=self.get403.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get403.metadata = {"url": "/http/failure/client/403"} # type: ignore + + @distributed_trace_async + async def put404(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 404 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put404_request( + content_type=content_type, + json=json, + template_url=self.put404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put404.metadata = {"url": "/http/failure/client/404"} # type: ignore + + @distributed_trace_async + async def patch405(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 405 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_patch405_request( + content_type=content_type, + json=json, + template_url=self.patch405.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch405.metadata = {"url": "/http/failure/client/405"} # type: ignore + + @distributed_trace_async + async def post406(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 406 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_post406_request( + content_type=content_type, + json=json, + template_url=self.post406.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post406.metadata = {"url": "/http/failure/client/406"} # type: ignore + + @distributed_trace_async + async def delete407(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 407 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_delete407_request( + content_type=content_type, + json=json, + template_url=self.delete407.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete407.metadata = {"url": "/http/failure/client/407"} # type: ignore + + @distributed_trace_async + async def put409(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 409 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put409_request( + content_type=content_type, + json=json, + template_url=self.put409.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put409.metadata = {"url": "/http/failure/client/409"} # type: ignore + + @distributed_trace_async + async def head410(self, **kwargs: Any) -> None: + """Return 410 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head410_request( + template_url=self.head410.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head410.metadata = {"url": "/http/failure/client/410"} # type: ignore + + @distributed_trace_async + async def get411(self, **kwargs: Any) -> None: + """Return 411 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get411_request( + template_url=self.get411.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get411.metadata = {"url": "/http/failure/client/411"} # type: ignore + + @distributed_trace_async + async def options412(self, **kwargs: Any) -> None: + """Return 412 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_options412_request( + template_url=self.options412.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + options412.metadata = {"url": "/http/failure/client/412"} # type: ignore + + @distributed_trace_async + async def get412(self, **kwargs: Any) -> None: + """Return 412 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get412_request( + template_url=self.get412.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get412.metadata = {"url": "/http/failure/client/412"} # type: ignore + + @distributed_trace_async + async def put413(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 413 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put413_request( + content_type=content_type, + json=json, + template_url=self.put413.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put413.metadata = {"url": "/http/failure/client/413"} # type: ignore + + @distributed_trace_async + async def patch414(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 414 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_patch414_request( + content_type=content_type, + json=json, + template_url=self.patch414.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch414.metadata = {"url": "/http/failure/client/414"} # type: ignore + + @distributed_trace_async + async def post415(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 415 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_post415_request( + content_type=content_type, + json=json, + template_url=self.post415.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post415.metadata = {"url": "/http/failure/client/415"} # type: ignore + + @distributed_trace_async + async def get416(self, **kwargs: Any) -> None: + """Return 416 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get416_request( + template_url=self.get416.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get416.metadata = {"url": "/http/failure/client/416"} # type: ignore + + @distributed_trace_async + async def delete417(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 417 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_delete417_request( + content_type=content_type, + json=json, + template_url=self.delete417.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete417.metadata = {"url": "/http/failure/client/417"} # type: ignore + + @distributed_trace_async + async def head429(self, **kwargs: Any) -> None: + """Return 429 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head429_request( + template_url=self.head429.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head429.metadata = {"url": "/http/failure/client/429"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py new file mode 100644 index 00000000000..c71fa9ca8eb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_failure_operations.py @@ -0,0 +1,160 @@ +# 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 ... import models as _models +from ..._rest import http_failure as rest_http_failure + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpFailureOperations: + """HttpFailureOperations 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: ~httpinfrastructure.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 get_empty_error(self, **kwargs: Any) -> bool: + """Get empty error form server. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_failure.build_get_empty_error_request( + template_url=self.get_empty_error.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_error.metadata = {"url": "/http/failure/emptybody/error"} # type: ignore + + @distributed_trace_async + async def get_no_model_error(self, **kwargs: Any) -> bool: + """Get empty error form server. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_failure.build_get_no_model_error_request( + template_url=self.get_no_model_error.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_no_model_error.metadata = {"url": "/http/failure/nomodel/error"} # type: ignore + + @distributed_trace_async + async def get_no_model_empty(self, **kwargs: Any) -> bool: + """Get empty response from server. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_failure.build_get_no_model_empty_request( + template_url=self.get_no_model_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_no_model_empty.metadata = {"url": "/http/failure/nomodel/empty"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py new file mode 100644 index 00000000000..ac6cc8804f8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_redirects_operations.py @@ -0,0 +1,719 @@ +# 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, List, 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 ... import models as _models +from ..._rest import http_redirects as rest_http_redirects + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpRedirectsOperations: + """HttpRedirectsOperations 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: ~httpinfrastructure.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 head300(self, **kwargs: Any) -> None: + """Return 300 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_head300_request( + template_url=self.head300.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 300]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 300: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head300.metadata = {"url": "/http/redirect/300"} # type: ignore + + @distributed_trace_async + async def get300(self, **kwargs: Any) -> Optional[List[str]]: + """Return 300 status code and redirect to /http/success/200. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_redirects.build_get300_request( + template_url=self.get300.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 300]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + response_headers = {} + if response.status_code == 300: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get300.metadata = {"url": "/http/redirect/300"} # type: ignore + + @distributed_trace_async + async def head301(self, **kwargs: Any) -> None: + """Return 301 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_head301_request( + template_url=self.head301.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 301]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 301: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head301.metadata = {"url": "/http/redirect/301"} # type: ignore + + @distributed_trace_async + async def get301(self, **kwargs: Any) -> None: + """Return 301 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_get301_request( + template_url=self.get301.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 301]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 301: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get301.metadata = {"url": "/http/redirect/301"} # type: ignore + + @distributed_trace_async + async def put301(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Put true Boolean value in request returns 301. This request should not be automatically + redirected, but should return the received 301 to the caller for evaluation. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_put301_request( + content_type=content_type, + json=json, + template_url=self.put301.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [301]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + put301.metadata = {"url": "/http/redirect/301"} # type: ignore + + @distributed_trace_async + async def head302(self, **kwargs: Any) -> None: + """Return 302 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_head302_request( + template_url=self.head302.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 302]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 302: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head302.metadata = {"url": "/http/redirect/302"} # type: ignore + + @distributed_trace_async + async def get302(self, **kwargs: Any) -> None: + """Return 302 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_get302_request( + template_url=self.get302.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 302]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 302: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get302.metadata = {"url": "/http/redirect/302"} # type: ignore + + @distributed_trace_async + async def patch302(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Patch true Boolean value in request returns 302. This request should not be automatically + redirected, but should return the received 302 to the caller for evaluation. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_patch302_request( + content_type=content_type, + json=json, + template_url=self.patch302.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [302]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + patch302.metadata = {"url": "/http/redirect/302"} # type: ignore + + @distributed_trace_async + async def post303(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Post true Boolean value in request returns 303. This request should be automatically + redirected usign a get, ultimately returning a 200 status code. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_post303_request( + content_type=content_type, + json=json, + template_url=self.post303.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 303]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 303: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + post303.metadata = {"url": "/http/redirect/303"} # type: ignore + + @distributed_trace_async + async def head307(self, **kwargs: Any) -> None: + """Redirect with 307, resulting in a 200 success. + + :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", {})) + + request = rest_http_redirects.build_head307_request( + template_url=self.head307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace_async + async def get307(self, **kwargs: Any) -> None: + """Redirect get with 307, resulting in a 200 success. + + :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", {})) + + request = rest_http_redirects.build_get307_request( + template_url=self.get307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace_async + async def options307(self, **kwargs: Any) -> None: + """options redirected with 307, resulting in a 200 after redirect. + + :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", {})) + + request = rest_http_redirects.build_options307_request( + template_url=self.options307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + options307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace_async + async def put307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Put redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_put307_request( + content_type=content_type, + json=json, + template_url=self.put307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + put307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace_async + async def patch307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Patch redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_patch307_request( + content_type=content_type, + json=json, + template_url=self.patch307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + patch307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace_async + async def post307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Post redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_post307_request( + content_type=content_type, + json=json, + template_url=self.post307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + post307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace_async + async def delete307(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Delete redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_delete307_request( + content_type=content_type, + json=json, + template_url=self.delete307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + delete307.metadata = {"url": "/http/redirect/307"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py new file mode 100644 index 00000000000..58739b5c3fc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_retry_operations.py @@ -0,0 +1,412 @@ +# 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 ... import models as _models +from ..._rest import http_retry as rest_http_retry + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpRetryOperations: + """HttpRetryOperations 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: ~httpinfrastructure.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 head408(self, **kwargs: Any) -> None: + """Return 408 status code, then 200 after retry. + + :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", {})) + + request = rest_http_retry.build_head408_request( + template_url=self.head408.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head408.metadata = {"url": "/http/retry/408"} # type: ignore + + @distributed_trace_async + async def put500(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 500 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_put500_request( + content_type=content_type, + json=json, + template_url=self.put500.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put500.metadata = {"url": "/http/retry/500"} # type: ignore + + @distributed_trace_async + async def patch500(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 500 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_patch500_request( + content_type=content_type, + json=json, + template_url=self.patch500.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch500.metadata = {"url": "/http/retry/500"} # type: ignore + + @distributed_trace_async + async def get502(self, **kwargs: Any) -> None: + """Return 502 status code, then 200 after retry. + + :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", {})) + + request = rest_http_retry.build_get502_request( + template_url=self.get502.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get502.metadata = {"url": "/http/retry/502"} # type: ignore + + @distributed_trace_async + async def options502(self, **kwargs: Any) -> bool: + """Return 502 status code, then 200 after retry. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_retry.build_options502_request( + template_url=self.options502.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + options502.metadata = {"url": "/http/retry/502"} # type: ignore + + @distributed_trace_async + async def post503(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 503 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_post503_request( + content_type=content_type, + json=json, + template_url=self.post503.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post503.metadata = {"url": "/http/retry/503"} # type: ignore + + @distributed_trace_async + async def delete503(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 503 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_delete503_request( + content_type=content_type, + json=json, + template_url=self.delete503.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete503.metadata = {"url": "/http/retry/503"} # type: ignore + + @distributed_trace_async + async def put504(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 504 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_put504_request( + content_type=content_type, + json=json, + template_url=self.put504.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put504.metadata = {"url": "/http/retry/504"} # type: ignore + + @distributed_trace_async + async def patch504(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 504 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_patch504_request( + content_type=content_type, + json=json, + template_url=self.patch504.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch504.metadata = {"url": "/http/retry/504"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py new file mode 100644 index 00000000000..0709748bcea --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_server_failure_operations.py @@ -0,0 +1,203 @@ +# 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 ... import models as _models +from ..._rest import http_server_failure as rest_http_server_failure + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpServerFailureOperations: + """HttpServerFailureOperations 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: ~httpinfrastructure.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 head501(self, **kwargs: Any) -> None: + """Return 501 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_server_failure.build_head501_request( + template_url=self.head501.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head501.metadata = {"url": "/http/failure/server/501"} # type: ignore + + @distributed_trace_async + async def get501(self, **kwargs: Any) -> None: + """Return 501 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_server_failure.build_get501_request( + template_url=self.get501.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get501.metadata = {"url": "/http/failure/server/501"} # type: ignore + + @distributed_trace_async + async def post505(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 505 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_server_failure.build_post505_request( + content_type=content_type, + json=json, + template_url=self.post505.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post505.metadata = {"url": "/http/failure/server/505"} # type: ignore + + @distributed_trace_async + async def delete505(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Return 505 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_server_failure.build_delete505_request( + content_type=content_type, + json=json, + template_url=self.delete505.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete505.metadata = {"url": "/http/failure/server/505"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py new file mode 100644 index 00000000000..a0060a2137c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_http_success_operations.py @@ -0,0 +1,826 @@ +# 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 ... import models as _models +from ..._rest import http_success as rest_http_success + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HttpSuccessOperations: + """HttpSuccessOperations 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: ~httpinfrastructure.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 head200(self, **kwargs: Any) -> None: + """Return 200 status code if successful. + + :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", {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def get200(self, **kwargs: Any) -> bool: + """Get 200 success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_success.build_get200_request( + template_url=self.get200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def options200(self, **kwargs: Any) -> bool: + """Options 200 success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_success.build_options200_request( + template_url=self.options200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + options200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def put200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Put boolean value true returning 200 success. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put200_request( + content_type=content_type, + json=json, + template_url=self.put200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def patch200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Patch true Boolean value in request returning 200. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_patch200_request( + content_type=content_type, + json=json, + template_url=self.patch200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def post200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Post bollean value true in request that returns a 200. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post200_request( + content_type=content_type, + json=json, + template_url=self.post200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def delete200(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Delete simple boolean value true returns 200. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_delete200_request( + content_type=content_type, + json=json, + template_url=self.delete200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace_async + async def put201(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Put true Boolean value in request returns 201. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put201_request( + content_type=content_type, + json=json, + template_url=self.put201.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put201.metadata = {"url": "/http/success/201"} # type: ignore + + @distributed_trace_async + async def post201(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Post true Boolean value in request returns 201 (Created). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post201_request( + content_type=content_type, + json=json, + template_url=self.post201.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post201.metadata = {"url": "/http/success/201"} # type: ignore + + @distributed_trace_async + async def put202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Put true Boolean value in request returns 202 (Accepted). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put202_request( + content_type=content_type, + json=json, + template_url=self.put202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace_async + async def patch202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Patch true Boolean value in request returns 202. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_patch202_request( + content_type=content_type, + json=json, + template_url=self.patch202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace_async + async def post202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Post true Boolean value in request returns 202 (Accepted). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post202_request( + content_type=content_type, + json=json, + template_url=self.post202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace_async + async def delete202(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Delete true Boolean value in request returns 202 (accepted). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_delete202_request( + content_type=content_type, + json=json, + template_url=self.delete202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace_async + async def head204(self, **kwargs: Any) -> None: + """Return 204 status code if successful. + + :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", {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def put204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Put true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put204_request( + content_type=content_type, + json=json, + template_url=self.put204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def patch204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Patch true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_patch204_request( + content_type=content_type, + json=json, + template_url=self.patch204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def post204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Post true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post204_request( + content_type=content_type, + json=json, + template_url=self.post204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def delete204(self, boolean_value: Optional[bool] = True, **kwargs: Any) -> None: + """Delete true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_delete204_request( + content_type=content_type, + json=json, + template_url=self.delete204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace_async + async def head404(self, **kwargs: Any) -> None: + """Return 404 status code. + + :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", {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py new file mode 100644 index 00000000000..75fbebe8504 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations/_multiple_responses_operations.py @@ -0,0 +1,1309 @@ +# 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 ..._rest import multiple_responses as rest_multiple_responses + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MultipleResponsesOperations: + """MultipleResponsesOperations 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: ~httpinfrastructure.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 get200_model204_no_model_default_error200_valid(self, **kwargs: Any) -> Optional["_models.MyException"]: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error200_valid_request( + template_url=self.get200_model204_no_model_default_error200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/200/valid"} # type: ignore + + @distributed_trace_async + async def get200_model204_no_model_default_error204_valid(self, **kwargs: Any) -> Optional["_models.MyException"]: + """Send a 204 response with no payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error204_valid_request( + template_url=self.get200_model204_no_model_default_error204_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error204_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/204/none"} # type: ignore + + @distributed_trace_async + async def get200_model204_no_model_default_error201_invalid(self, **kwargs: Any) -> Optional["_models.MyException"]: + """Send a 201 response with valid payload: {'statusCode': '201'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error201_invalid_request( + template_url=self.get200_model204_no_model_default_error201_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error201_invalid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/201/valid"} # type: ignore + + @distributed_trace_async + async def get200_model204_no_model_default_error202_none(self, **kwargs: Any) -> Optional["_models.MyException"]: + """Send a 202 response with no payload:. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error202_none_request( + template_url=self.get200_model204_no_model_default_error202_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error202_none.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/202/none"} # type: ignore + + @distributed_trace_async + async def get200_model204_no_model_default_error400_valid(self, **kwargs: Any) -> Optional["_models.MyException"]: + """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error400_valid_request( + template_url=self.get200_model204_no_model_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/400/valid"} # type: ignore + + @distributed_trace_async + async def get200_model201_model_default_error200_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.B"]: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or B, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model201_model_default_error200_valid_request( + template_url=self.get200_model201_model_default_error200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("B", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model201_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/200/valid"} # type: ignore + + @distributed_trace_async + async def get200_model201_model_default_error201_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.B"]: + """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or B, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model201_model_default_error201_valid_request( + template_url=self.get200_model201_model_default_error201_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("B", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model201_model_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/201/valid"} # type: ignore + + @distributed_trace_async + async def get200_model201_model_default_error400_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.B"]: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or B, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model201_model_default_error400_valid_request( + template_url=self.get200_model201_model_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("B", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model201_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/400/valid"} # type: ignore + + @distributed_trace_async + async def get200_model_a201_model_c404_model_d_default_error200_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.C", "_models.D"]: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error200_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid"} # type: ignore + + @distributed_trace_async + async def get200_model_a201_model_c404_model_d_default_error201_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.C", "_models.D"]: + """Send a 200 response with valid payload: {'httpCode': '201'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error201_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error201_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid"} # type: ignore + + @distributed_trace_async + async def get200_model_a201_model_c404_model_d_default_error404_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.C", "_models.D"]: + """Send a 200 response with valid payload: {'httpStatusCode': '404'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error404_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error404_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error404_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid"} # type: ignore + + @distributed_trace_async + async def get200_model_a201_model_c404_model_d_default_error400_valid( + self, **kwargs: Any + ) -> Union["_models.MyException", "_models.C", "_models.D"]: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error400_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_error202_none(self, **kwargs: Any) -> None: + """Send a 202 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_error202_none_request( + template_url=self.get202_none204_none_default_error202_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_error202_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/202/none"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_error204_none(self, **kwargs: Any) -> None: + """Send a 204 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_error204_none_request( + template_url=self.get202_none204_none_default_error204_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_error204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/204/none"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_error400_valid(self, **kwargs: Any) -> None: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_error400_valid_request( + template_url=self.get202_none204_none_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_error400_valid.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/400/valid"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_none202_invalid(self, **kwargs: Any) -> None: + """Send a 202 response with an unexpected payload {'property': 'value'}. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none202_invalid_request( + template_url=self.get202_none204_none_default_none202_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none202_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/202/invalid"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_none204_none(self, **kwargs: Any) -> None: + """Send a 204 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none204_none_request( + template_url=self.get202_none204_none_default_none204_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/204/none"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_none400_none(self, **kwargs: Any) -> None: + """Send a 400 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none400_none_request( + template_url=self.get202_none204_none_default_none400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none400_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/none"} # type: ignore + + @distributed_trace_async + async def get202_none204_none_default_none400_invalid(self, **kwargs: Any) -> None: + """Send a 400 response with an unexpected payload {'property': 'value'}. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none400_invalid_request( + template_url=self.get202_none204_none_default_none400_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none400_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/invalid"} # type: ignore + + @distributed_trace_async + async def get_default_model_a200_valid(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get_default_model_a200_valid_request( + template_url=self.get_default_model_a200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_default_model_a200_valid.metadata = {"url": "/http/payloads/default/A/response/200/valid"} # type: ignore + + @distributed_trace_async + async def get_default_model_a200_none(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with no payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get_default_model_a200_none_request( + template_url=self.get_default_model_a200_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_default_model_a200_none.metadata = {"url": "/http/payloads/default/A/response/200/none"} # type: ignore + + @distributed_trace_async + async def get_default_model_a400_valid(self, **kwargs: Any) -> None: + """Send a 400 response with valid payload: {'statusCode': '400'}. + + :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", {})) + + request = rest_multiple_responses.build_get_default_model_a400_valid_request( + template_url=self.get_default_model_a400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyException, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_model_a400_valid.metadata = {"url": "/http/payloads/default/A/response/400/valid"} # type: ignore + + @distributed_trace_async + async def get_default_model_a400_none(self, **kwargs: Any) -> None: + """Send a 400 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get_default_model_a400_none_request( + template_url=self.get_default_model_a400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyException, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_model_a400_none.metadata = {"url": "/http/payloads/default/A/response/400/none"} # type: ignore + + @distributed_trace_async + async def get_default_none200_invalid(self, **kwargs: Any) -> None: + """Send a 200 response with invalid payload: {'statusCode': '200'}. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none200_invalid_request( + template_url=self.get_default_none200_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none200_invalid.metadata = {"url": "/http/payloads/default/none/response/200/invalid"} # type: ignore + + @distributed_trace_async + async def get_default_none200_none(self, **kwargs: Any) -> None: + """Send a 200 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none200_none_request( + template_url=self.get_default_none200_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none200_none.metadata = {"url": "/http/payloads/default/none/response/200/none"} # type: ignore + + @distributed_trace_async + async def get_default_none400_invalid(self, **kwargs: Any) -> None: + """Send a 400 response with valid payload: {'statusCode': '400'}. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none400_invalid_request( + template_url=self.get_default_none400_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none400_invalid.metadata = {"url": "/http/payloads/default/none/response/400/invalid"} # type: ignore + + @distributed_trace_async + async def get_default_none400_none(self, **kwargs: Any) -> None: + """Send a 400 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none400_none_request( + template_url=self.get_default_none400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none400_none.metadata = {"url": "/http/payloads/default/none/response/400/none"} # type: ignore + + @distributed_trace_async + async def get200_model_a200_none(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with no payload, when a payload is expected - client should return a null + object of thde type for model A. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a200_none_request( + template_url=self.get200_model_a200_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a200_none.metadata = {"url": "/http/payloads/200/A/response/200/none"} # type: ignore + + @distributed_trace_async + async def get200_model_a200_valid(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with payload {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a200_valid_request( + template_url=self.get200_model_a200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a200_valid.metadata = {"url": "/http/payloads/200/A/response/200/valid"} # type: ignore + + @distributed_trace_async + async def get200_model_a200_invalid(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a200_invalid_request( + template_url=self.get200_model_a200_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a200_invalid.metadata = {"url": "/http/payloads/200/A/response/200/invalid"} # type: ignore + + @distributed_trace_async + async def get200_model_a400_none(self, **kwargs: Any) -> "_models.MyException": + """Send a 400 response with no payload client should treat as an http error with no error model. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a400_none_request( + template_url=self.get200_model_a400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a400_none.metadata = {"url": "/http/payloads/200/A/response/400/none"} # type: ignore + + @distributed_trace_async + async def get200_model_a400_valid(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with payload {'statusCode': '400'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a400_valid_request( + template_url=self.get200_model_a400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a400_valid.metadata = {"url": "/http/payloads/200/A/response/400/valid"} # type: ignore + + @distributed_trace_async + async def get200_model_a400_invalid(self, **kwargs: Any) -> "_models.MyException": + """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a400_invalid_request( + template_url=self.get200_model_a400_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a400_invalid.metadata = {"url": "/http/payloads/200/A/response/400/invalid"} # type: ignore + + @distributed_trace_async + async def get200_model_a202_valid(self, **kwargs: Any) -> "_models.MyException": + """Send a 202 response with payload {'statusCode': '202'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a202_valid_request( + template_url=self.get200_model_a202_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a202_valid.metadata = {"url": "/http/payloads/200/A/response/202/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py new file mode 100644 index 00000000000..be7d5608793 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_client_failure_operations.py @@ -0,0 +1,1095 @@ +# 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 .. import models as _models +from .._rest import http_client_failure as rest_http_client_failure + +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]] + + +class HttpClientFailureOperations(object): + """HttpClientFailureOperations 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: ~httpinfrastructure.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 head400( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head400_request( + template_url=self.head400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def get400( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get400_request( + template_url=self.get400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def options400( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_options400_request( + template_url=self.options400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + options400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def put400( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put400_request( + content_type=content_type, + json=json, + template_url=self.put400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def patch400( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_patch400_request( + content_type=content_type, + json=json, + template_url=self.patch400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def post400( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_post400_request( + content_type=content_type, + json=json, + template_url=self.post400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def delete400( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 400 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_delete400_request( + content_type=content_type, + json=json, + template_url=self.delete400.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete400.metadata = {"url": "/http/failure/client/400"} # type: ignore + + @distributed_trace + def head401( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 401 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head401_request( + template_url=self.head401.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head401.metadata = {"url": "/http/failure/client/401"} # type: ignore + + @distributed_trace + def get402( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 402 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get402_request( + template_url=self.get402.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get402.metadata = {"url": "/http/failure/client/402"} # type: ignore + + @distributed_trace + def options403( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 403 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_options403_request( + template_url=self.options403.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + options403.metadata = {"url": "/http/failure/client/403"} # type: ignore + + @distributed_trace + def get403( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 403 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get403_request( + template_url=self.get403.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get403.metadata = {"url": "/http/failure/client/403"} # type: ignore + + @distributed_trace + def put404( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 404 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put404_request( + content_type=content_type, + json=json, + template_url=self.put404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put404.metadata = {"url": "/http/failure/client/404"} # type: ignore + + @distributed_trace + def patch405( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 405 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_patch405_request( + content_type=content_type, + json=json, + template_url=self.patch405.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch405.metadata = {"url": "/http/failure/client/405"} # type: ignore + + @distributed_trace + def post406( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 406 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_post406_request( + content_type=content_type, + json=json, + template_url=self.post406.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post406.metadata = {"url": "/http/failure/client/406"} # type: ignore + + @distributed_trace + def delete407( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 407 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_delete407_request( + content_type=content_type, + json=json, + template_url=self.delete407.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete407.metadata = {"url": "/http/failure/client/407"} # type: ignore + + @distributed_trace + def put409( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 409 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put409_request( + content_type=content_type, + json=json, + template_url=self.put409.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put409.metadata = {"url": "/http/failure/client/409"} # type: ignore + + @distributed_trace + def head410( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 410 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head410_request( + template_url=self.head410.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head410.metadata = {"url": "/http/failure/client/410"} # type: ignore + + @distributed_trace + def get411( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 411 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get411_request( + template_url=self.get411.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get411.metadata = {"url": "/http/failure/client/411"} # type: ignore + + @distributed_trace + def options412( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 412 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_options412_request( + template_url=self.options412.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + options412.metadata = {"url": "/http/failure/client/412"} # type: ignore + + @distributed_trace + def get412( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 412 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get412_request( + template_url=self.get412.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get412.metadata = {"url": "/http/failure/client/412"} # type: ignore + + @distributed_trace + def put413( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 413 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_put413_request( + content_type=content_type, + json=json, + template_url=self.put413.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put413.metadata = {"url": "/http/failure/client/413"} # type: ignore + + @distributed_trace + def patch414( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 414 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_patch414_request( + content_type=content_type, + json=json, + template_url=self.patch414.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch414.metadata = {"url": "/http/failure/client/414"} # type: ignore + + @distributed_trace + def post415( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 415 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_post415_request( + content_type=content_type, + json=json, + template_url=self.post415.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post415.metadata = {"url": "/http/failure/client/415"} # type: ignore + + @distributed_trace + def get416( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 416 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_get416_request( + template_url=self.get416.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get416.metadata = {"url": "/http/failure/client/416"} # type: ignore + + @distributed_trace + def delete417( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 417 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_client_failure.build_delete417_request( + content_type=content_type, + json=json, + template_url=self.delete417.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete417.metadata = {"url": "/http/failure/client/417"} # type: ignore + + @distributed_trace + def head429( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 429 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_client_failure.build_head429_request( + template_url=self.head429.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head429.metadata = {"url": "/http/failure/client/429"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py new file mode 100644 index 00000000000..59d6666ea2d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_failure_operations.py @@ -0,0 +1,167 @@ +# 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 .. import models as _models +from .._rest import http_failure as rest_http_failure + +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]] + + +class HttpFailureOperations(object): + """HttpFailureOperations 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: ~httpinfrastructure.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 get_empty_error( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get empty error form server. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_failure.build_get_empty_error_request( + template_url=self.get_empty_error.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_error.metadata = {"url": "/http/failure/emptybody/error"} # type: ignore + + @distributed_trace + def get_no_model_error( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get empty error form server. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_failure.build_get_no_model_error_request( + template_url=self.get_no_model_error.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_no_model_error.metadata = {"url": "/http/failure/nomodel/error"} # type: ignore + + @distributed_trace + def get_no_model_empty( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get empty response from server. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_failure.build_get_no_model_empty_request( + template_url=self.get_no_model_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_no_model_empty.metadata = {"url": "/http/failure/nomodel/empty"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py new file mode 100644 index 00000000000..5b3bc0ac958 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py @@ -0,0 +1,753 @@ +# 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 .. import models as _models +from .._rest import http_redirects as rest_http_redirects + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class HttpRedirectsOperations(object): + """HttpRedirectsOperations 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: ~httpinfrastructure.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 head300( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 300 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_head300_request( + template_url=self.head300.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 300]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 300: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head300.metadata = {"url": "/http/redirect/300"} # type: ignore + + @distributed_trace + def get300( + self, **kwargs # type: Any + ): + # type: (...) -> Optional[List[str]] + """Return 300 status code and redirect to /http/success/200. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of str, or the result of cls(response) + :rtype: list[str] or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional[List[str]]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_redirects.build_get300_request( + template_url=self.get300.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 300]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + response_headers = {} + if response.status_code == 300: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("[str]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get300.metadata = {"url": "/http/redirect/300"} # type: ignore + + @distributed_trace + def head301( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 301 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_head301_request( + template_url=self.head301.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 301]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 301: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head301.metadata = {"url": "/http/redirect/301"} # type: ignore + + @distributed_trace + def get301( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 301 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_get301_request( + template_url=self.get301.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 301]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 301: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get301.metadata = {"url": "/http/redirect/301"} # type: ignore + + @distributed_trace + def put301( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Put true Boolean value in request returns 301. This request should not be automatically + redirected, but should return the received 301 to the caller for evaluation. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_put301_request( + content_type=content_type, + json=json, + template_url=self.put301.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [301]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + put301.metadata = {"url": "/http/redirect/301"} # type: ignore + + @distributed_trace + def head302( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 302 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_head302_request( + template_url=self.head302.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 302]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 302: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head302.metadata = {"url": "/http/redirect/302"} # type: ignore + + @distributed_trace + def get302( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 302 status code and redirect to /http/success/200. + + :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", {})) + + request = rest_http_redirects.build_get302_request( + template_url=self.get302.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 302]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 302: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get302.metadata = {"url": "/http/redirect/302"} # type: ignore + + @distributed_trace + def patch302( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Patch true Boolean value in request returns 302. This request should not be automatically + redirected, but should return the received 302 to the caller for evaluation. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_patch302_request( + content_type=content_type, + json=json, + template_url=self.patch302.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [302]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + patch302.metadata = {"url": "/http/redirect/302"} # type: ignore + + @distributed_trace + def post303( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Post true Boolean value in request returns 303. This request should be automatically + redirected usign a get, ultimately returning a 200 status code. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_post303_request( + content_type=content_type, + json=json, + template_url=self.post303.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 303]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 303: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + post303.metadata = {"url": "/http/redirect/303"} # type: ignore + + @distributed_trace + def head307( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Redirect with 307, resulting in a 200 success. + + :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", {})) + + request = rest_http_redirects.build_head307_request( + template_url=self.head307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + head307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace + def get307( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Redirect get with 307, resulting in a 200 success. + + :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", {})) + + request = rest_http_redirects.build_get307_request( + template_url=self.get307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace + def options307( + self, **kwargs # type: Any + ): + # type: (...) -> None + """options redirected with 307, resulting in a 200 after redirect. + + :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", {})) + + request = rest_http_redirects.build_options307_request( + template_url=self.options307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + options307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace + def put307( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Put redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_put307_request( + content_type=content_type, + json=json, + template_url=self.put307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + put307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace + def patch307( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Patch redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_patch307_request( + content_type=content_type, + json=json, + template_url=self.patch307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + patch307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace + def post307( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Post redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_post307_request( + content_type=content_type, + json=json, + template_url=self.post307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + post307.metadata = {"url": "/http/redirect/307"} # type: ignore + + @distributed_trace + def delete307( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Delete redirected with 307, resulting in a 200 after redirect. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_redirects.build_delete307_request( + content_type=content_type, + json=json, + template_url=self.delete307.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 307]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + if response.status_code == 307: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + delete307.metadata = {"url": "/http/redirect/307"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py new file mode 100644 index 00000000000..0765e9f15c0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_retry_operations.py @@ -0,0 +1,437 @@ +# 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 .. import models as _models +from .._rest import http_retry as rest_http_retry + +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]] + + +class HttpRetryOperations(object): + """HttpRetryOperations 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: ~httpinfrastructure.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 head408( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 408 status code, then 200 after retry. + + :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", {})) + + request = rest_http_retry.build_head408_request( + template_url=self.head408.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head408.metadata = {"url": "/http/retry/408"} # type: ignore + + @distributed_trace + def put500( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 500 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_put500_request( + content_type=content_type, + json=json, + template_url=self.put500.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put500.metadata = {"url": "/http/retry/500"} # type: ignore + + @distributed_trace + def patch500( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 500 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_patch500_request( + content_type=content_type, + json=json, + template_url=self.patch500.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch500.metadata = {"url": "/http/retry/500"} # type: ignore + + @distributed_trace + def get502( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 502 status code, then 200 after retry. + + :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", {})) + + request = rest_http_retry.build_get502_request( + template_url=self.get502.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get502.metadata = {"url": "/http/retry/502"} # type: ignore + + @distributed_trace + def options502( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Return 502 status code, then 200 after retry. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_retry.build_options502_request( + template_url=self.options502.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + options502.metadata = {"url": "/http/retry/502"} # type: ignore + + @distributed_trace + def post503( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 503 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_post503_request( + content_type=content_type, + json=json, + template_url=self.post503.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post503.metadata = {"url": "/http/retry/503"} # type: ignore + + @distributed_trace + def delete503( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 503 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_delete503_request( + content_type=content_type, + json=json, + template_url=self.delete503.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete503.metadata = {"url": "/http/retry/503"} # type: ignore + + @distributed_trace + def put504( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 504 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_put504_request( + content_type=content_type, + json=json, + template_url=self.put504.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put504.metadata = {"url": "/http/retry/504"} # type: ignore + + @distributed_trace + def patch504( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 504 status code, then 200 after retry. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_retry.build_patch504_request( + content_type=content_type, + json=json, + template_url=self.patch504.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch504.metadata = {"url": "/http/retry/504"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py new file mode 100644 index 00000000000..15d4355e9df --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_server_failure_operations.py @@ -0,0 +1,215 @@ +# 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 .. import models as _models +from .._rest import http_server_failure as rest_http_server_failure + +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]] + + +class HttpServerFailureOperations(object): + """HttpServerFailureOperations 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: ~httpinfrastructure.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 head501( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 501 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_server_failure.build_head501_request( + template_url=self.head501.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head501.metadata = {"url": "/http/failure/server/501"} # type: ignore + + @distributed_trace + def get501( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 501 status code - should be represented in the client as an error. + + :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", {})) + + request = rest_http_server_failure.build_get501_request( + template_url=self.get501.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get501.metadata = {"url": "/http/failure/server/501"} # type: ignore + + @distributed_trace + def post505( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 505 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_server_failure.build_post505_request( + content_type=content_type, + json=json, + template_url=self.post505.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post505.metadata = {"url": "/http/failure/server/505"} # type: ignore + + @distributed_trace + def delete505( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Return 505 status code - should be represented in the client as an error. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_server_failure.build_delete505_request( + content_type=content_type, + json=json, + template_url=self.delete505.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in []: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete505.metadata = {"url": "/http/failure/server/505"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py new file mode 100644 index 00000000000..475b2a7d4af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_success_operations.py @@ -0,0 +1,877 @@ +# 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 .. import models as _models +from .._rest import http_success as rest_http_success + +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]] + + +class HttpSuccessOperations(object): + """HttpSuccessOperations 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: ~httpinfrastructure.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 head200( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 200 status code if successful. + + :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", {})) + + request = rest_http_success.build_head200_request( + template_url=self.head200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def get200( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Get 200 success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_success.build_get200_request( + template_url=self.get200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def options200( + self, **kwargs # type: Any + ): + # type: (...) -> bool + """Options 200 success. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[bool] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_http_success.build_options200_request( + template_url=self.options200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("bool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + options200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def put200( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Put boolean value true returning 200 success. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put200_request( + content_type=content_type, + json=json, + template_url=self.put200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def patch200( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Patch true Boolean value in request returning 200. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_patch200_request( + content_type=content_type, + json=json, + template_url=self.patch200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def post200( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Post bollean value true in request that returns a 200. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post200_request( + content_type=content_type, + json=json, + template_url=self.post200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def delete200( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Delete simple boolean value true returns 200. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_delete200_request( + content_type=content_type, + json=json, + template_url=self.delete200.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete200.metadata = {"url": "/http/success/200"} # type: ignore + + @distributed_trace + def put201( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Put true Boolean value in request returns 201. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put201_request( + content_type=content_type, + json=json, + template_url=self.put201.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put201.metadata = {"url": "/http/success/201"} # type: ignore + + @distributed_trace + def post201( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Post true Boolean value in request returns 201 (Created). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post201_request( + content_type=content_type, + json=json, + template_url=self.post201.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post201.metadata = {"url": "/http/success/201"} # type: ignore + + @distributed_trace + def put202( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Put true Boolean value in request returns 202 (Accepted). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put202_request( + content_type=content_type, + json=json, + template_url=self.put202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace + def patch202( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Patch true Boolean value in request returns 202. + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_patch202_request( + content_type=content_type, + json=json, + template_url=self.patch202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace + def post202( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Post true Boolean value in request returns 202 (Accepted). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post202_request( + content_type=content_type, + json=json, + template_url=self.post202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace + def delete202( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Delete true Boolean value in request returns 202 (accepted). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_delete202_request( + content_type=content_type, + json=json, + template_url=self.delete202.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete202.metadata = {"url": "/http/success/202"} # type: ignore + + @distributed_trace + def head204( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 204 status code if successful. + + :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", {})) + + request = rest_http_success.build_head204_request( + template_url=self.head204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def put204( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Put true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_put204_request( + content_type=content_type, + json=json, + template_url=self.put204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def patch204( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Patch true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_patch204_request( + content_type=content_type, + json=json, + template_url=self.patch204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + patch204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def post204( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Post true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_post204_request( + content_type=content_type, + json=json, + template_url=self.post204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def delete204( + self, + boolean_value=True, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Delete true Boolean value in request returns 204 (no content). + + :param boolean_value: Simple boolean value true. + :type boolean_value: bool + :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/json") # type: Optional[str] + + if boolean_value is not None: + json = self._serialize.body(boolean_value, "bool") + else: + json = None + + request = rest_http_success.build_delete204_request( + content_type=content_type, + json=json, + template_url=self.delete204.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + delete204.metadata = {"url": "/http/success/204"} # type: ignore + + @distributed_trace + def head404( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Return 404 status code. + + :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", {})) + + request = rest_http_success.build_head404_request( + template_url=self.head404.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + head404.metadata = {"url": "/http/success/404"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py new file mode 100644 index 00000000000..296d8e573a4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py @@ -0,0 +1,1333 @@ +# 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 .. import models as _models +from .._rest import multiple_responses as rest_multiple_responses + +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]] + + +class MultipleResponsesOperations(object): + """MultipleResponsesOperations 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: ~httpinfrastructure.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 get200_model204_no_model_default_error200_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.MyException"] + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error200_valid_request( + template_url=self.get200_model204_no_model_default_error200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/200/valid"} # type: ignore + + @distributed_trace + def get200_model204_no_model_default_error204_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.MyException"] + """Send a 204 response with no payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error204_valid_request( + template_url=self.get200_model204_no_model_default_error204_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error204_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/204/none"} # type: ignore + + @distributed_trace + def get200_model204_no_model_default_error201_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.MyException"] + """Send a 201 response with valid payload: {'statusCode': '201'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error201_invalid_request( + template_url=self.get200_model204_no_model_default_error201_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error201_invalid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/201/valid"} # type: ignore + + @distributed_trace + def get200_model204_no_model_default_error202_none( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.MyException"] + """Send a 202 response with no payload:. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error202_none_request( + template_url=self.get200_model204_no_model_default_error202_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error202_none.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/202/none"} # type: ignore + + @distributed_trace + def get200_model204_no_model_default_error400_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Optional["_models.MyException"] + """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.MyException"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model204_no_model_default_error400_valid_request( + template_url=self.get200_model204_no_model_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model204_no_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/204/none/default/Error/response/400/valid"} # type: ignore + + @distributed_trace + def get200_model201_model_default_error200_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.B"] + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or B, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model201_model_default_error200_valid_request( + template_url=self.get200_model201_model_default_error200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("B", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model201_model_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/200/valid"} # type: ignore + + @distributed_trace + def get200_model201_model_default_error201_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.B"] + """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or B, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model201_model_default_error201_valid_request( + template_url=self.get200_model201_model_default_error201_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("B", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model201_model_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/201/valid"} # type: ignore + + @distributed_trace + def get200_model201_model_default_error400_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.B"] + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or B, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.B + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.B"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model201_model_default_error400_valid_request( + template_url=self.get200_model201_model_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("B", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model201_model_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/B/default/Error/response/400/valid"} # type: ignore + + @distributed_trace + def get200_model_a201_model_c404_model_d_default_error200_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error200_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error200_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid"} # type: ignore + + @distributed_trace + def get200_model_a201_model_c404_model_d_default_error201_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] + """Send a 200 response with valid payload: {'httpCode': '201'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error201_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error201_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error201_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid"} # type: ignore + + @distributed_trace + def get200_model_a201_model_c404_model_d_default_error404_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] + """Send a 200 response with valid payload: {'httpStatusCode': '404'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error404_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error404_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error404_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid"} # type: ignore + + @distributed_trace + def get200_model_a201_model_c404_model_d_default_error400_valid( + self, **kwargs # type: Any + ): + # type: (...) -> Union["_models.MyException", "_models.C", "_models.D"] + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException or C or D, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException or ~httpinfrastructure.models.C or + ~httpinfrastructure.models.D + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union["_models.MyException", "_models.C", "_models.D"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a201_model_c404_model_d_default_error400_valid_request( + template_url=self.get200_model_a201_model_c404_model_d_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize("MyException", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("C", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("D", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a201_model_c404_model_d_default_error400_valid.metadata = {"url": "/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid"} # type: ignore + + @distributed_trace + def get202_none204_none_default_error202_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 202 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_error202_none_request( + template_url=self.get202_none204_none_default_error202_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_error202_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/202/none"} # type: ignore + + @distributed_trace + def get202_none204_none_default_error204_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 204 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_error204_none_request( + template_url=self.get202_none204_none_default_error204_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_error204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/204/none"} # type: ignore + + @distributed_trace + def get202_none204_none_default_error400_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_error400_valid_request( + template_url=self.get202_none204_none_default_error400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_error400_valid.metadata = {"url": "/http/payloads/202/none/204/none/default/Error/response/400/valid"} # type: ignore + + @distributed_trace + def get202_none204_none_default_none202_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 202 response with an unexpected payload {'property': 'value'}. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none202_invalid_request( + template_url=self.get202_none204_none_default_none202_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none202_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/202/invalid"} # type: ignore + + @distributed_trace + def get202_none204_none_default_none204_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 204 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none204_none_request( + template_url=self.get202_none204_none_default_none204_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none204_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/204/none"} # type: ignore + + @distributed_trace + def get202_none204_none_default_none400_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none400_none_request( + template_url=self.get202_none204_none_default_none400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none400_none.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/none"} # type: ignore + + @distributed_trace + def get202_none204_none_default_none400_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with an unexpected payload {'property': 'value'}. + + :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", {})) + + request = rest_multiple_responses.build_get202_none204_none_default_none400_invalid_request( + template_url=self.get202_none204_none_default_none400_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get202_none204_none_default_none400_invalid.metadata = {"url": "/http/payloads/202/none/204/none/default/none/response/400/invalid"} # type: ignore + + @distributed_trace + def get_default_model_a200_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with valid payload: {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get_default_model_a200_valid_request( + template_url=self.get_default_model_a200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_default_model_a200_valid.metadata = {"url": "/http/payloads/default/A/response/200/valid"} # type: ignore + + @distributed_trace + def get_default_model_a200_none( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with no payload. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get_default_model_a200_none_request( + template_url=self.get_default_model_a200_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_default_model_a200_none.metadata = {"url": "/http/payloads/default/A/response/200/none"} # type: ignore + + @distributed_trace + def get_default_model_a400_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with valid payload: {'statusCode': '400'}. + + :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", {})) + + request = rest_multiple_responses.build_get_default_model_a400_valid_request( + template_url=self.get_default_model_a400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyException, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_model_a400_valid.metadata = {"url": "/http/payloads/default/A/response/400/valid"} # type: ignore + + @distributed_trace + def get_default_model_a400_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get_default_model_a400_none_request( + template_url=self.get_default_model_a400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyException, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_model_a400_none.metadata = {"url": "/http/payloads/default/A/response/400/none"} # type: ignore + + @distributed_trace + def get_default_none200_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 200 response with invalid payload: {'statusCode': '200'}. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none200_invalid_request( + template_url=self.get_default_none200_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none200_invalid.metadata = {"url": "/http/payloads/default/none/response/200/invalid"} # type: ignore + + @distributed_trace + def get_default_none200_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 200 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none200_none_request( + template_url=self.get_default_none200_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none200_none.metadata = {"url": "/http/payloads/default/none/response/200/none"} # type: ignore + + @distributed_trace + def get_default_none400_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with valid payload: {'statusCode': '400'}. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none400_invalid_request( + template_url=self.get_default_none400_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none400_invalid.metadata = {"url": "/http/payloads/default/none/response/400/invalid"} # type: ignore + + @distributed_trace + def get_default_none400_none( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Send a 400 response with no payload. + + :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", {})) + + request = rest_multiple_responses.build_get_default_none400_none_request( + template_url=self.get_default_none400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_default_none400_none.metadata = {"url": "/http/payloads/default/none/response/400/none"} # type: ignore + + @distributed_trace + def get200_model_a200_none( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with no payload, when a payload is expected - client should return a null + object of thde type for model A. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a200_none_request( + template_url=self.get200_model_a200_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a200_none.metadata = {"url": "/http/payloads/200/A/response/200/none"} # type: ignore + + @distributed_trace + def get200_model_a200_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with payload {'statusCode': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a200_valid_request( + template_url=self.get200_model_a200_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a200_valid.metadata = {"url": "/http/payloads/200/A/response/200/valid"} # type: ignore + + @distributed_trace + def get200_model_a200_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a200_invalid_request( + template_url=self.get200_model_a200_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a200_invalid.metadata = {"url": "/http/payloads/200/A/response/200/invalid"} # type: ignore + + @distributed_trace + def get200_model_a400_none( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 400 response with no payload client should treat as an http error with no error model. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a400_none_request( + template_url=self.get200_model_a400_none.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a400_none.metadata = {"url": "/http/payloads/200/A/response/400/none"} # type: ignore + + @distributed_trace + def get200_model_a400_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with payload {'statusCode': '400'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a400_valid_request( + template_url=self.get200_model_a400_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a400_valid.metadata = {"url": "/http/payloads/200/A/response/400/valid"} # type: ignore + + @distributed_trace + def get200_model_a400_invalid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a400_invalid_request( + template_url=self.get200_model_a400_invalid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a400_invalid.metadata = {"url": "/http/payloads/200/A/response/400/invalid"} # type: ignore + + @distributed_trace + def get200_model_a202_valid( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.MyException" + """Send a 202 response with payload {'statusCode': '202'}. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MyException, or the result of cls(response) + :rtype: ~httpinfrastructure.models.MyException + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.MyException"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_multiple_responses.build_get200_model_a202_valid_request( + template_url=self.get200_model_a202_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("MyException", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get200_model_a202_valid.metadata = {"url": "/http/payloads/200/A/response/202/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Http/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Http/setup.py new file mode 100644 index 00000000000..fcfd79cd81c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Http/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 = "autoresthttpinfrastructuretestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHttpInfrastructureTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHttpInfrastructureTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_incorrect_returned_error_model.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_incorrect_returned_error_model.py new file mode 100644 index 00000000000..f353f4f68e4 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_incorrect_returned_error_model.py @@ -0,0 +1,93 @@ +# 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 IncorrectReturnedErrorModelConfiguration +from .operations import IncorrectReturnedErrorModelOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class IncorrectReturnedErrorModel(IncorrectReturnedErrorModelOperationsMixin): + """Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = IncorrectReturnedErrorModelConfiguration(**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 + + 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 `incorrecterrorresponse.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from incorrecterrorresponse._rest import build_get_incorrect_error_from_server_request + >>> request = build_get_incorrect_error_from_server_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> IncorrectReturnedErrorModel + 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/IncorrectErrorResponse/incorrecterrorresponse/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/__init__.py new file mode 100644 index 00000000000..dc1410e2374 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/__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_get_incorrect_error_from_server_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_incorrect_error_from_server_request # type: ignore + +__all__ = [ + "build_get_incorrect_error_from_server_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/_request_builders.py new file mode 100644 index 00000000000..5d04266b137 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/_request_builders.py @@ -0,0 +1,44 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_incorrect_error_from_server_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an error response from the server that is not as described in our Error object. Want to + swallow the deserialization error and still return an HttpResponseError to the users. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/incorrectError') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..52f28f5764a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_rest/_request_builders_py3.py @@ -0,0 +1,32 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_incorrect_error_from_server_request(**kwargs: Any) -> HttpRequest: + """Get an error response from the server that is not as described in our Error object. Want to + swallow the deserialization error and still return an HttpResponseError to the users. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/incorrectError") + + return HttpRequest(method="GET", url=url, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_incorrect_returned_error_model.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_incorrect_returned_error_model.py new file mode 100644 index 00000000000..237ba081fa5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/_incorrect_returned_error_model.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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import IncorrectReturnedErrorModelConfiguration +from .operations import IncorrectReturnedErrorModelOperationsMixin + + +class IncorrectReturnedErrorModel(IncorrectReturnedErrorModelOperationsMixin): + """Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = IncorrectReturnedErrorModelConfiguration(**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 + + 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 `incorrecterrorresponse.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from incorrecterrorresponse._rest import build_get_incorrect_error_from_server_request + >>> request = build_get_incorrect_error_from_server_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "IncorrectReturnedErrorModel": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py new file mode 100644 index 00000000000..41dd8df64d2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py @@ -0,0 +1,62 @@ +# 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 ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IncorrectReturnedErrorModelOperationsMixin: + @distributed_trace_async + async def get_incorrect_error_from_server(self, **kwargs: Any) -> None: + """Get an error response from the server that is not as described in our Error object. Want to + swallow the deserialization error and still return an HttpResponseError to the users. + + :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", {})) + + request = rest.build_get_incorrect_error_from_server_request( + template_url=self.get_incorrect_error_from_server.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_incorrect_error_from_server.metadata = {"url": "/incorrectError"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py new file mode 100644 index 00000000000..ff84dfb4349 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/operations/_incorrect_returned_error_model_operations.py @@ -0,0 +1,67 @@ +# 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 .. import _rest as rest, models as _models + +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]] + + +class IncorrectReturnedErrorModelOperationsMixin(object): + @distributed_trace + def get_incorrect_error_from_server( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get an error response from the server that is not as described in our Error object. Want to + swallow the deserialization error and still return an HttpResponseError to the users. + + :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", {})) + + request = rest.build_get_incorrect_error_from_server_request( + template_url=self.get_incorrect_error_from_server.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_incorrect_error_from_server.metadata = {"url": "/incorrectError"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/setup.py new file mode 100644 index 00000000000..efcb49f90cd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/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 = "incorrectreturnederrormodel" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="IncorrectReturnedErrorModel", + author_email="", + url="", + keywords=["Swagger", "IncorrectReturnedErrorModel"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_media_types_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_media_types_client.py new file mode 100644 index 00000000000..7229a3be0d6 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_media_types_client.py @@ -0,0 +1,93 @@ +# 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 MediaTypesClientConfiguration +from .operations import MediaTypesClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class MediaTypesClient(MediaTypesClientOperationsMixin): + """Play with produces/consumes and media-types in general. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = MediaTypesClientConfiguration(**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 + + 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 `mediatypes.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from mediatypes._rest import build_analyze_body_request + >>> request = build_analyze_body_request(json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> MediaTypesClient + 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/MediaTypes/mediatypes/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/__init__.py new file mode 100644 index 00000000000..276b724f566 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_analyze_body_request + from ._request_builders_py3 import build_content_type_with_encoding_request +except (SyntaxError, ImportError): + from ._request_builders import build_analyze_body_request # type: ignore + from ._request_builders import build_content_type_with_encoding_request # type: ignore + +__all__ = [ + "build_analyze_body_request", + "build_content_type_with_encoding_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/_request_builders.py new file mode 100644 index 00000000000..86adb503781 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/_request_builders.py @@ -0,0 +1,100 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_analyze_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Analyze body, that could be different media types. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/mediatypes/analyze') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_content_type_with_encoding_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/mediatypes/contentTypeWithEncoding') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..1dc0b03e9f5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_rest/_request_builders_py3.py @@ -0,0 +1,79 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_analyze_body_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Analyze body, that could be different media types. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[Union[str, "_models.ContentType"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/mediatypes/analyze") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_content_type_with_encoding_request(*, content: Any = None, **kwargs: Any) -> HttpRequest: + """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/mediatypes/contentTypeWithEncoding") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, content=content, **kwargs) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_version.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_version.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_version.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_media_types_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_media_types_client.py new file mode 100644 index 00000000000..ead426c54b1 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/_media_types_client.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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import MediaTypesClientConfiguration +from .operations import MediaTypesClientOperationsMixin + + +class MediaTypesClient(MediaTypesClientOperationsMixin): + """Play with produces/consumes and media-types in general. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = MediaTypesClientConfiguration(**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 + + 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 `mediatypes.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from mediatypes._rest import build_analyze_body_request + >>> request = build_analyze_body_request(json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "MediaTypesClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py new file mode 100644 index 00000000000..b86fcf1c2da --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py @@ -0,0 +1,135 @@ +# 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, IO, 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 _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MediaTypesClientOperationsMixin: + @distributed_trace_async + async def analyze_body(self, input: Optional[Union[IO, "_models.SourcePath"]] = None, **kwargs: Any) -> str: + """Analyze body, that could be different media types. + + :param input: Input parameter. + :type input: IO or ~mediatypes.models.SourcePath + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop( + "content_type", "application/json" + ) # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ["application/pdf", "image/jpeg", "image/png", "image/tiff"]: + content = input + elif content_type.split(";")[0] in ["application/json"]: + if input is not None: + json = self._serialize.body(input, "SourcePath") + else: + raise ValueError( + "The content_type '{}' is not one of the allowed values: " + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) + ) + + request = rest.build_analyze_body_request( + content_type=content_type, + json=json, + content=content, + template_url=self.analyze_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + analyze_body.metadata = {"url": "/mediatypes/analyze"} # type: ignore + + @distributed_trace_async + async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) -> str: + """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. + + :param input: Input parameter. + :type input: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "text/plain") # type: Optional[str] + + if input is not None: + content = self._serialize.body(input, "str") + else: + content = None + + request = rest.build_content_type_with_encoding_request( + content_type=content_type, + content=content, + template_url=self.content_type_with_encoding.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + content_type_with_encoding.metadata = {"url": "/mediatypes/contentTypeWithEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_media_types_client_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_media_types_client_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_media_types_client_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_media_types_client_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py new file mode 100644 index 00000000000..200ad35a775 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/operations/_media_types_client_operations.py @@ -0,0 +1,145 @@ +# 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 .. import _rest as rest, models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class MediaTypesClientOperationsMixin(object): + @distributed_trace + def analyze_body( + self, + input=None, # type: Optional[Union[IO, "_models.SourcePath"]] + **kwargs # type: Any + ): + # type: (...) -> str + """Analyze body, that could be different media types. + + :param input: Input parameter. + :type input: IO or ~mediatypes.models.SourcePath + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop( + "content_type", "application/json" + ) # type: Optional[Union[str, "_models.ContentType"]] + + json = None + content = None + if content_type.split(";")[0] in ["application/pdf", "image/jpeg", "image/png", "image/tiff"]: + content = input + elif content_type.split(";")[0] in ["application/json"]: + if input is not None: + json = self._serialize.body(input, "SourcePath") + else: + raise ValueError( + "The content_type '{}' is not one of the allowed values: " + "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(content_type) + ) + + request = rest.build_analyze_body_request( + content_type=content_type, + json=json, + content=content, + template_url=self.analyze_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + analyze_body.metadata = {"url": "/mediatypes/analyze"} # type: ignore + + @distributed_trace + def content_type_with_encoding( + self, + input=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> str + """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. + + :param input: Input parameter. + :type input: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "text/plain") # type: Optional[str] + + if input is not None: + content = self._serialize.body(input, "str") + else: + content = None + + request = rest.build_content_type_with_encoding_request( + content_type=content_type, + content=content, + template_url=self.content_type_with_encoding.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + content_type_with_encoding.metadata = {"url": "/mediatypes/contentTypeWithEncoding"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/py.typed similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/py.typed rename to test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/py.typed diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/setup.py new file mode 100644 index 00000000000..dc511b5a976 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/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 = "mediatypesclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="MediaTypesClient", + author_email="", + url="", + keywords=["Swagger", "MediaTypesClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Play with produces/consumes and media-types in general. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_auto_rest_resource_flattening_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_auto_rest_resource_flattening_test_service.py new file mode 100644 index 00000000000..2b79b13b87b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_auto_rest_resource_flattening_test_service.py @@ -0,0 +1,93 @@ +# 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 AutoRestResourceFlatteningTestServiceConfiguration +from .operations import AutoRestResourceFlatteningTestServiceOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestResourceFlatteningTestService(AutoRestResourceFlatteningTestServiceOperationsMixin): + """Resource Flattening for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestResourceFlatteningTestServiceConfiguration(**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 + + 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 `modelflattening.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from modelflattening._rest import build_put_array_request + >>> request = build_put_array_request(json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestResourceFlatteningTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/__init__.py new file mode 100644 index 00000000000..f56a51a7756 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/__init__.py @@ -0,0 +1,46 @@ +# 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_put_array_request + from ._request_builders_py3 import build_get_array_request + from ._request_builders_py3 import build_put_wrapped_array_request + from ._request_builders_py3 import build_get_wrapped_array_request + from ._request_builders_py3 import build_put_dictionary_request + from ._request_builders_py3 import build_get_dictionary_request + from ._request_builders_py3 import build_put_resource_collection_request + from ._request_builders_py3 import build_get_resource_collection_request + from ._request_builders_py3 import build_put_simple_product_request + from ._request_builders_py3 import build_post_flattened_simple_product_request + from ._request_builders_py3 import build_put_simple_product_with_grouping_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_array_request # type: ignore + from ._request_builders import build_get_array_request # type: ignore + from ._request_builders import build_put_wrapped_array_request # type: ignore + from ._request_builders import build_get_wrapped_array_request # type: ignore + from ._request_builders import build_put_dictionary_request # type: ignore + from ._request_builders import build_get_dictionary_request # type: ignore + from ._request_builders import build_put_resource_collection_request # type: ignore + from ._request_builders import build_get_resource_collection_request # type: ignore + from ._request_builders import build_put_simple_product_request # type: ignore + from ._request_builders import build_post_flattened_simple_product_request # type: ignore + from ._request_builders import build_put_simple_product_with_grouping_request # type: ignore + +__all__ = [ + "build_put_array_request", + "build_get_array_request", + "build_put_wrapped_array_request", + "build_get_wrapped_array_request", + "build_put_dictionary_request", + "build_get_dictionary_request", + "build_put_resource_collection_request", + "build_get_resource_collection_request", + "build_put_simple_product_request", + "build_post_flattened_simple_product_request", + "build_put_simple_product_with_grouping_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/_request_builders.py new file mode 100644 index 00000000000..53d4567f8c8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/_request_builders.py @@ -0,0 +1,439 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/array') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/array') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_wrapped_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/wrappedarray') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_wrapped_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/wrappedarray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a Dictionary to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a Dictionary to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/dictionary') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/dictionary') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_resource_collection_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a ResourceCollection to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a ResourceCollection to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/resourcecollection') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_resource_collection_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/resourcecollection') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_simple_product_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/customFlattening') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_flattened_simple_product_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put Flattened Simple Product with client flattening true on the parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to post. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to post. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/customFlattening') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_simple_product_with_grouping_request( + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param name: Product name with value 'groupproduct'. + :type name: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/customFlattening/parametergrouping/{name}/') + path_format_arguments = { + 'name': _SERIALIZER.url("name", name, 'str'), + } + 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..f3c4d661f5f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_rest/_request_builders_py3.py @@ -0,0 +1,347 @@ +# 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, List, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_array_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/array") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_request(**kwargs: Any) -> HttpRequest: + """Get External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/array") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_wrapped_array_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/wrappedarray") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_wrapped_array_request(**kwargs: Any) -> HttpRequest: + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/wrappedarray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a Dictionary to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a Dictionary to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/dictionary") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_request(**kwargs: Any) -> HttpRequest: + """Get External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/dictionary") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_resource_collection_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a ResourceCollection to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a ResourceCollection to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/resourcecollection") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_resource_collection_request(**kwargs: Any) -> HttpRequest: + """Get External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/resourcecollection") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_simple_product_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/customFlattening") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_flattened_simple_product_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put Flattened Simple Product with client flattening true on the parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to post. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to post. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/customFlattening") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_simple_product_with_grouping_request( + name: str, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param name: Product name with value 'groupproduct'. + :type name: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/customFlattening/parametergrouping/{name}/") + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_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/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_auto_rest_resource_flattening_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_auto_rest_resource_flattening_test_service.py new file mode 100644 index 00000000000..5a88278c797 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_auto_rest_resource_flattening_test_service.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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestResourceFlatteningTestServiceConfiguration +from .operations import AutoRestResourceFlatteningTestServiceOperationsMixin + + +class AutoRestResourceFlatteningTestService(AutoRestResourceFlatteningTestServiceOperationsMixin): + """Resource Flattening for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestResourceFlatteningTestServiceConfiguration(**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 + + 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 `modelflattening.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from modelflattening._rest import build_put_array_request + >>> request = build_put_array_request(json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestResourceFlatteningTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py new file mode 100644 index 00000000000..bd3a46f9f19 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py @@ -0,0 +1,557 @@ +# 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, List, 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 ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutoRestResourceFlatteningTestServiceOperationsMixin: + @distributed_trace_async + async def put_array(self, resource_array: Optional[List["_models.Resource"]] = None, **kwargs: Any) -> None: + """Put External Resource as an Array. + + :param resource_array: External Resource as an Array to put. + :type resource_array: list[~modelflattening.models.Resource] + :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/json") # type: Optional[str] + + if resource_array is not None: + json = self._serialize.body(resource_array, "[Resource]") + else: + json = None + + request = rest.build_put_array_request( + content_type=content_type, + json=json, + template_url=self.put_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array.metadata = {"url": "/model-flatten/array"} # type: ignore + + @distributed_trace_async + async def get_array(self, **kwargs: Any) -> List["_models.FlattenedProduct"]: + """Get External Resource as an Array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of FlattenedProduct, or the result of cls(response) + :rtype: list[~modelflattening.models.FlattenedProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.FlattenedProduct"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_array_request( + template_url=self.get_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[FlattenedProduct]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array.metadata = {"url": "/model-flatten/array"} # type: ignore + + @distributed_trace_async + async def put_wrapped_array( + self, resource_array: Optional[List["_models.WrappedProduct"]] = None, **kwargs: Any + ) -> None: + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + :param resource_array: External Resource as an Array to put. + :type resource_array: list[~modelflattening.models.WrappedProduct] + :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/json") # type: Optional[str] + + if resource_array is not None: + json = self._serialize.body(resource_array, "[WrappedProduct]") + else: + json = None + + request = rest.build_put_wrapped_array_request( + content_type=content_type, + json=json, + template_url=self.put_wrapped_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore + + @distributed_trace_async + async def get_wrapped_array(self, **kwargs: Any) -> List["_models.ProductWrapper"]: + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of ProductWrapper, or the result of cls(response) + :rtype: list[~modelflattening.models.ProductWrapper] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.ProductWrapper"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_wrapped_array_request( + template_url=self.get_wrapped_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[ProductWrapper]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore + + @distributed_trace_async + async def put_dictionary( + self, resource_dictionary: Optional[Dict[str, "_models.FlattenedProduct"]] = None, **kwargs: Any + ) -> None: + """Put External Resource as a Dictionary. + + :param resource_dictionary: External Resource as a Dictionary to put. + :type resource_dictionary: dict[str, ~modelflattening.models.FlattenedProduct] + :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/json") # type: Optional[str] + + if resource_dictionary is not None: + json = self._serialize.body(resource_dictionary, "{FlattenedProduct}") + else: + json = None + + request = rest.build_put_dictionary_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore + + @distributed_trace_async + async def get_dictionary(self, **kwargs: Any) -> Dict[str, "_models.FlattenedProduct"]: + """Get External Resource as a Dictionary. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to FlattenedProduct, or the result of cls(response) + :rtype: dict[str, ~modelflattening.models.FlattenedProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.FlattenedProduct"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_dictionary_request( + template_url=self.get_dictionary.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{FlattenedProduct}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore + + @distributed_trace_async + async def put_resource_collection( + self, resource_complex_object: Optional["_models.ResourceCollection"] = None, **kwargs: Any + ) -> None: + """Put External Resource as a ResourceCollection. + + :param resource_complex_object: External Resource as a ResourceCollection to put. + :type resource_complex_object: ~modelflattening.models.ResourceCollection + :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/json") # type: Optional[str] + + if resource_complex_object is not None: + json = self._serialize.body(resource_complex_object, "ResourceCollection") + else: + json = None + + request = rest.build_put_resource_collection_request( + content_type=content_type, + json=json, + template_url=self.put_resource_collection.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore + + @distributed_trace_async + async def get_resource_collection(self, **kwargs: Any) -> "_models.ResourceCollection": + """Get External Resource as a ResourceCollection. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceCollection, or the result of cls(response) + :rtype: ~modelflattening.models.ResourceCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ResourceCollection"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_resource_collection_request( + template_url=self.get_resource_collection.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ResourceCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore + + @distributed_trace_async + async def put_simple_product( + self, simple_body_product: Optional["_models.SimpleProduct"] = None, **kwargs: Any + ) -> "_models.SimpleProduct": + """Put Simple Product with client flattening true on the model. + + :param simple_body_product: Simple body product to put. + :type simple_body_product: ~modelflattening.models.SimpleProduct + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimpleProduct, or the result of cls(response) + :rtype: ~modelflattening.models.SimpleProduct + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if simple_body_product is not None: + json = self._serialize.body(simple_body_product, "SimpleProduct") + else: + json = None + + request = rest.build_put_simple_product_request( + content_type=content_type, + json=json, + template_url=self.put_simple_product.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("SimpleProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore + + @distributed_trace_async + async def post_flattened_simple_product( + self, + product_id: str, + description: Optional[str] = None, + max_product_display_name: Optional[str] = None, + capacity: Optional[str] = "Large", + generic_value: Optional[str] = None, + odata_value: Optional[str] = None, + **kwargs: Any + ) -> "_models.SimpleProduct": + """Put Flattened Simple Product with client flattening true on the parameter. + + :param product_id: Unique identifier representing a specific product for a given latitude & + longitude. For example, uberX in San Francisco will have a different product_id than uberX in + Los Angeles. + :type product_id: str + :param description: Description of product. + :type description: str + :param max_product_display_name: Display name of product. + :type max_product_display_name: str + :param capacity: Capacity of product. For example, 4 people. + :type capacity: str + :param generic_value: Generic URL value. + :type generic_value: str + :param odata_value: URL value. + :type odata_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimpleProduct, or the result of cls(response) + :rtype: ~modelflattening.models.SimpleProduct + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _simple_body_product = _models.SimpleProduct( + product_id=product_id, + description=description, + max_product_display_name=max_product_display_name, + capacity=capacity, + generic_value=generic_value, + odata_value=odata_value, + ) + if _simple_body_product is not None: + json = self._serialize.body(_simple_body_product, "SimpleProduct") + else: + json = None + + request = rest.build_post_flattened_simple_product_request( + content_type=content_type, + json=json, + template_url=self.post_flattened_simple_product.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("SimpleProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + post_flattened_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore + + @distributed_trace_async + async def put_simple_product_with_grouping( + self, flatten_parameter_group: "_models.FlattenParameterGroup", **kwargs: Any + ) -> "_models.SimpleProduct": + """Put Simple Product with client flattening true on the model. + + :param flatten_parameter_group: Parameter group. + :type flatten_parameter_group: ~modelflattening.models.FlattenParameterGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimpleProduct, or the result of cls(response) + :rtype: ~modelflattening.models.SimpleProduct + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _name = None + _simple_body_product = None + _product_id = None + _description = None + _max_product_display_name = None + capacity = None + _generic_value = None + _odata_value = None + if flatten_parameter_group is not None: + _name = flatten_parameter_group.name + _simple_body_product = flatten_parameter_group.simple_body_product + _product_id = flatten_parameter_group.product_id + _description = flatten_parameter_group.description + _max_product_display_name = flatten_parameter_group.max_product_display_name + capacity = flatten_parameter_group.capacity + _generic_value = flatten_parameter_group.generic_value + _odata_value = flatten_parameter_group.odata_value + _simple_body_product = _models.SimpleProduct( + product_id=_product_id, + description=_description, + max_product_display_name=_max_product_display_name, + capacity=capacity, + generic_value=_generic_value, + odata_value=_odata_value, + ) + if _simple_body_product is not None: + json = self._serialize.body(_simple_body_product, "SimpleProduct") + else: + json = None + + request = rest.build_put_simple_product_with_grouping_request( + name=_name, + content_type=content_type, + json=json, + template_url=self.put_simple_product_with_grouping.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("SimpleProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_simple_product_with_grouping.metadata = {"url": "/model-flatten/customFlattening/parametergrouping/{name}/"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_auto_rest_resource_flattening_test_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_auto_rest_resource_flattening_test_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_auto_rest_resource_flattening_test_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_auto_rest_resource_flattening_test_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py new file mode 100644 index 00000000000..d992e1b568c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/_auto_rest_resource_flattening_test_service_operations.py @@ -0,0 +1,572 @@ +# 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 .. import _rest as rest, models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class AutoRestResourceFlatteningTestServiceOperationsMixin(object): + @distributed_trace + def put_array( + self, + resource_array=None, # type: Optional[List["_models.Resource"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put External Resource as an Array. + + :param resource_array: External Resource as an Array to put. + :type resource_array: list[~modelflattening.models.Resource] + :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/json") # type: Optional[str] + + if resource_array is not None: + json = self._serialize.body(resource_array, "[Resource]") + else: + json = None + + request = rest.build_put_array_request( + content_type=content_type, + json=json, + template_url=self.put_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_array.metadata = {"url": "/model-flatten/array"} # type: ignore + + @distributed_trace + def get_array( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.FlattenedProduct"] + """Get External Resource as an Array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of FlattenedProduct, or the result of cls(response) + :rtype: list[~modelflattening.models.FlattenedProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.FlattenedProduct"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_array_request( + template_url=self.get_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[FlattenedProduct]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array.metadata = {"url": "/model-flatten/array"} # type: ignore + + @distributed_trace + def put_wrapped_array( + self, + resource_array=None, # type: Optional[List["_models.WrappedProduct"]] + **kwargs # type: Any + ): + # type: (...) -> None + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + :param resource_array: External Resource as an Array to put. + :type resource_array: list[~modelflattening.models.WrappedProduct] + :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/json") # type: Optional[str] + + if resource_array is not None: + json = self._serialize.body(resource_array, "[WrappedProduct]") + else: + json = None + + request = rest.build_put_wrapped_array_request( + content_type=content_type, + json=json, + template_url=self.put_wrapped_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore + + @distributed_trace + def get_wrapped_array( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.ProductWrapper"] + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of ProductWrapper, or the result of cls(response) + :rtype: list[~modelflattening.models.ProductWrapper] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.ProductWrapper"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_wrapped_array_request( + template_url=self.get_wrapped_array.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("[ProductWrapper]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_wrapped_array.metadata = {"url": "/model-flatten/wrappedarray"} # type: ignore + + @distributed_trace + def put_dictionary( + self, + resource_dictionary=None, # type: Optional[Dict[str, "_models.FlattenedProduct"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Put External Resource as a Dictionary. + + :param resource_dictionary: External Resource as a Dictionary to put. + :type resource_dictionary: dict[str, ~modelflattening.models.FlattenedProduct] + :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/json") # type: Optional[str] + + if resource_dictionary is not None: + json = self._serialize.body(resource_dictionary, "{FlattenedProduct}") + else: + json = None + + request = rest.build_put_dictionary_request( + content_type=content_type, + json=json, + template_url=self.put_dictionary.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore + + @distributed_trace + def get_dictionary( + self, **kwargs # type: Any + ): + # type: (...) -> Dict[str, "_models.FlattenedProduct"] + """Get External Resource as a Dictionary. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to FlattenedProduct, or the result of cls(response) + :rtype: dict[str, ~modelflattening.models.FlattenedProduct] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, "_models.FlattenedProduct"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_dictionary_request( + template_url=self.get_dictionary.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{FlattenedProduct}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_dictionary.metadata = {"url": "/model-flatten/dictionary"} # type: ignore + + @distributed_trace + def put_resource_collection( + self, + resource_complex_object=None, # type: Optional["_models.ResourceCollection"] + **kwargs # type: Any + ): + # type: (...) -> None + """Put External Resource as a ResourceCollection. + + :param resource_complex_object: External Resource as a ResourceCollection to put. + :type resource_complex_object: ~modelflattening.models.ResourceCollection + :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/json") # type: Optional[str] + + if resource_complex_object is not None: + json = self._serialize.body(resource_complex_object, "ResourceCollection") + else: + json = None + + request = rest.build_put_resource_collection_request( + content_type=content_type, + json=json, + template_url=self.put_resource_collection.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore + + @distributed_trace + def get_resource_collection( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ResourceCollection" + """Get External Resource as a ResourceCollection. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceCollection, or the result of cls(response) + :rtype: ~modelflattening.models.ResourceCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ResourceCollection"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_resource_collection_request( + template_url=self.get_resource_collection.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ResourceCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_collection.metadata = {"url": "/model-flatten/resourcecollection"} # type: ignore + + @distributed_trace + def put_simple_product( + self, + simple_body_product=None, # type: Optional["_models.SimpleProduct"] + **kwargs # type: Any + ): + # type: (...) -> "_models.SimpleProduct" + """Put Simple Product with client flattening true on the model. + + :param simple_body_product: Simple body product to put. + :type simple_body_product: ~modelflattening.models.SimpleProduct + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimpleProduct, or the result of cls(response) + :rtype: ~modelflattening.models.SimpleProduct + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if simple_body_product is not None: + json = self._serialize.body(simple_body_product, "SimpleProduct") + else: + json = None + + request = rest.build_put_simple_product_request( + content_type=content_type, + json=json, + template_url=self.put_simple_product.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("SimpleProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore + + @distributed_trace + def post_flattened_simple_product( + self, + product_id, # type: str + description=None, # type: Optional[str] + max_product_display_name=None, # type: Optional[str] + capacity="Large", # type: Optional[str] + generic_value=None, # type: Optional[str] + odata_value=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.SimpleProduct" + """Put Flattened Simple Product with client flattening true on the parameter. + + :param product_id: Unique identifier representing a specific product for a given latitude & + longitude. For example, uberX in San Francisco will have a different product_id than uberX in + Los Angeles. + :type product_id: str + :param description: Description of product. + :type description: str + :param max_product_display_name: Display name of product. + :type max_product_display_name: str + :param capacity: Capacity of product. For example, 4 people. + :type capacity: str + :param generic_value: Generic URL value. + :type generic_value: str + :param odata_value: URL value. + :type odata_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimpleProduct, or the result of cls(response) + :rtype: ~modelflattening.models.SimpleProduct + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _simple_body_product = _models.SimpleProduct( + product_id=product_id, + description=description, + max_product_display_name=max_product_display_name, + capacity=capacity, + generic_value=generic_value, + odata_value=odata_value, + ) + if _simple_body_product is not None: + json = self._serialize.body(_simple_body_product, "SimpleProduct") + else: + json = None + + request = rest.build_post_flattened_simple_product_request( + content_type=content_type, + json=json, + template_url=self.post_flattened_simple_product.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("SimpleProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + post_flattened_simple_product.metadata = {"url": "/model-flatten/customFlattening"} # type: ignore + + @distributed_trace + def put_simple_product_with_grouping( + self, + flatten_parameter_group, # type: "_models.FlattenParameterGroup" + **kwargs # type: Any + ): + # type: (...) -> "_models.SimpleProduct" + """Put Simple Product with client flattening true on the model. + + :param flatten_parameter_group: Parameter group. + :type flatten_parameter_group: ~modelflattening.models.FlattenParameterGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SimpleProduct, or the result of cls(response) + :rtype: ~modelflattening.models.SimpleProduct + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.SimpleProduct"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _name = None + _simple_body_product = None + _product_id = None + _description = None + _max_product_display_name = None + capacity = None + _generic_value = None + _odata_value = None + if flatten_parameter_group is not None: + _name = flatten_parameter_group.name + _simple_body_product = flatten_parameter_group.simple_body_product + _product_id = flatten_parameter_group.product_id + _description = flatten_parameter_group.description + _max_product_display_name = flatten_parameter_group.max_product_display_name + capacity = flatten_parameter_group.capacity + _generic_value = flatten_parameter_group.generic_value + _odata_value = flatten_parameter_group.odata_value + _simple_body_product = _models.SimpleProduct( + product_id=_product_id, + description=_description, + max_product_display_name=_max_product_display_name, + capacity=capacity, + generic_value=_generic_value, + odata_value=_odata_value, + ) + if _simple_body_product is not None: + json = self._serialize.body(_simple_body_product, "SimpleProduct") + else: + json = None + + request = rest.build_put_simple_product_with_grouping_request( + name=_name, + content_type=content_type, + json=json, + template_url=self.put_simple_product_with_grouping.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("SimpleProduct", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_simple_product_with_grouping.metadata = {"url": "/model-flatten/customFlattening/parametergrouping/{name}/"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/setup.py new file mode 100644 index 00000000000..1fbc49db0c0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/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 = "autorestresourceflatteningtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestResourceFlatteningTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestResourceFlatteningTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Resource Flattening for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_multiple_inheritance_service_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_multiple_inheritance_service_client.py new file mode 100644 index 00000000000..e8b11eb3587 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_multiple_inheritance_service_client.py @@ -0,0 +1,93 @@ +# 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 MultipleInheritanceServiceClientConfiguration +from .operations import MultipleInheritanceServiceClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class MultipleInheritanceServiceClient(MultipleInheritanceServiceClientOperationsMixin): + """Service client for multiinheritance client testing. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = MultipleInheritanceServiceClientConfiguration(**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 + + 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 `multipleinheritance.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multipleinheritance._rest import build_get_horse_request + >>> request = build_get_horse_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> MultipleInheritanceServiceClient + 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/MultipleInheritance/multipleinheritance/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/__init__.py new file mode 100644 index 00000000000..007cd269e83 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/__init__.py @@ -0,0 +1,43 @@ +# 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_get_horse_request + from ._request_builders_py3 import build_put_horse_request + from ._request_builders_py3 import build_get_pet_request + from ._request_builders_py3 import build_put_pet_request + from ._request_builders_py3 import build_get_feline_request + from ._request_builders_py3 import build_put_feline_request + from ._request_builders_py3 import build_get_cat_request + from ._request_builders_py3 import build_put_cat_request + from ._request_builders_py3 import build_get_kitten_request + from ._request_builders_py3 import build_put_kitten_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_horse_request # type: ignore + from ._request_builders import build_put_horse_request # type: ignore + from ._request_builders import build_get_pet_request # type: ignore + from ._request_builders import build_put_pet_request # type: ignore + from ._request_builders import build_get_feline_request # type: ignore + from ._request_builders import build_put_feline_request # type: ignore + from ._request_builders import build_get_cat_request # type: ignore + from ._request_builders import build_put_cat_request # type: ignore + from ._request_builders import build_get_kitten_request # type: ignore + from ._request_builders import build_put_kitten_request # type: ignore + +__all__ = [ + "build_get_horse_request", + "build_put_horse_request", + "build_get_pet_request", + "build_put_pet_request", + "build_get_feline_request", + "build_put_feline_request", + "build_get_cat_request", + "build_put_cat_request", + "build_get_kitten_request", + "build_put_kitten_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/_request_builders.py new file mode 100644 index 00000000000..9f3c4110b9e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/_request_builders.py @@ -0,0 +1,384 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_horse_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a horse with name 'Fred' and isAShowHorse true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/horse') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_horse_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a horse with name 'General' and isAShowHorse false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a horse with name 'General' and isAShowHorse false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a horse with name 'General' and isAShowHorse false. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/horse') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_pet_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a pet with name 'Peanut'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/pet') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_pet_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a pet with name 'Butter'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a pet with name 'Butter'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a pet with name 'Butter'. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/pet') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_feline_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a feline where meows and hisses are true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/feline') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_feline_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a feline who hisses and doesn't meow. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a feline who hisses and doesn't meow. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a feline who hisses and doesn't meow. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/feline') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_cat_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/cat') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_cat_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/cat') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_kitten_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet + is false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/kitten') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_kitten_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is + true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a kitten with name 'Kitty' where likesMilk and hisses + is false, meows and eatsMiceYet is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a kitten with name 'Kitty' where likesMilk and hisses is + false, meows and eatsMiceYet is true. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/kitten') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..8b2016b3694 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_rest/_request_builders_py3.py @@ -0,0 +1,299 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_horse_request(**kwargs: Any) -> HttpRequest: + """Get a horse with name 'Fred' and isAShowHorse true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/horse") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_horse_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a horse with name 'General' and isAShowHorse false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a horse with name 'General' and isAShowHorse false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a horse with name 'General' and isAShowHorse false. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/horse") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_pet_request(**kwargs: Any) -> HttpRequest: + """Get a pet with name 'Peanut'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/pet") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_pet_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a pet with name 'Butter'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a pet with name 'Butter'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a pet with name 'Butter'. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/pet") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_feline_request(**kwargs: Any) -> HttpRequest: + """Get a feline where meows and hisses are true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/feline") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_feline_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a feline who hisses and doesn't meow. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a feline who hisses and doesn't meow. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a feline who hisses and doesn't meow. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/feline") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_cat_request(**kwargs: Any) -> HttpRequest: + """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/cat") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_cat_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/cat") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_kitten_request(**kwargs: Any) -> HttpRequest: + """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet + is false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/kitten") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_kitten_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is + true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a kitten with name 'Kitty' where likesMilk and hisses + is false, meows and eatsMiceYet is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a kitten with name 'Kitty' where likesMilk and hisses is + false, meows and eatsMiceYet is true. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/kitten") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_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/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_multiple_inheritance_service_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_multiple_inheritance_service_client.py new file mode 100644 index 00000000000..42294b53272 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/_multiple_inheritance_service_client.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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import MultipleInheritanceServiceClientConfiguration +from .operations import MultipleInheritanceServiceClientOperationsMixin + + +class MultipleInheritanceServiceClient(MultipleInheritanceServiceClientOperationsMixin): + """Service client for multiinheritance client testing. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = MultipleInheritanceServiceClientConfiguration(**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 + + 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 `multipleinheritance.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multipleinheritance._rest import build_get_horse_request + >>> request = build_get_horse_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "MultipleInheritanceServiceClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py new file mode 100644 index 00000000000..35d42104b40 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py @@ -0,0 +1,433 @@ +# 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 ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MultipleInheritanceServiceClientOperationsMixin: + @distributed_trace_async + async def get_horse(self, **kwargs: Any) -> "_models.Horse": + """Get a horse with name 'Fred' and isAShowHorse true. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Horse, or the result of cls(response) + :rtype: ~multipleinheritance.models.Horse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Horse"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_horse_request( + template_url=self.get_horse.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Horse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore + + @distributed_trace_async + async def put_horse(self, horse: "_models.Horse", **kwargs: Any) -> str: + """Put a horse with name 'General' and isAShowHorse false. + + :param horse: Put a horse with name 'General' and isAShowHorse false. + :type horse: ~multipleinheritance.models.Horse + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(horse, "Horse") + + request = rest.build_put_horse_request( + content_type=content_type, + json=json, + template_url=self.put_horse.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore + + @distributed_trace_async + async def get_pet(self, **kwargs: Any) -> "_models.Pet": + """Get a pet with name 'Peanut'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~multipleinheritance.models.Pet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_pet_request( + template_url=self.get_pet.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore + + @distributed_trace_async + async def put_pet(self, name: str, **kwargs: Any) -> str: + """Put a pet with name 'Butter'. + + :param name: + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _pet = _models.Pet(name=name) + json = self._serialize.body(_pet, "Pet") + + request = rest.build_put_pet_request( + content_type=content_type, + json=json, + template_url=self.put_pet.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore + + @distributed_trace_async + async def get_feline(self, **kwargs: Any) -> "_models.Feline": + """Get a feline where meows and hisses are true. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Feline, or the result of cls(response) + :rtype: ~multipleinheritance.models.Feline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Feline"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_feline_request( + template_url=self.get_feline.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Feline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore + + @distributed_trace_async + async def put_feline(self, feline: "_models.Feline", **kwargs: Any) -> str: + """Put a feline who hisses and doesn't meow. + + :param feline: Put a feline who hisses and doesn't meow. + :type feline: ~multipleinheritance.models.Feline + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(feline, "Feline") + + request = rest.build_put_feline_request( + content_type=content_type, + json=json, + template_url=self.put_feline.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore + + @distributed_trace_async + async def get_cat(self, **kwargs: Any) -> "_models.Cat": + """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cat, or the result of cls(response) + :rtype: ~multipleinheritance.models.Cat + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Cat"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_cat_request( + template_url=self.get_cat.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Cat", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore + + @distributed_trace_async + async def put_cat(self, cat: "_models.Cat", **kwargs: Any) -> str: + """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + + :param cat: Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + :type cat: ~multipleinheritance.models.Cat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(cat, "Cat") + + request = rest.build_put_cat_request( + content_type=content_type, + json=json, + template_url=self.put_cat.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore + + @distributed_trace_async + async def get_kitten(self, **kwargs: Any) -> "_models.Kitten": + """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet + is false. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Kitten, or the result of cls(response) + :rtype: ~multipleinheritance.models.Kitten + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Kitten"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_kitten_request( + template_url=self.get_kitten.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Kitten", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore + + @distributed_trace_async + async def put_kitten(self, kitten: "_models.Kitten", **kwargs: Any) -> str: + """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is + true. + + :param kitten: Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and + eatsMiceYet is true. + :type kitten: ~multipleinheritance.models.Kitten + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(kitten, "Kitten") + + request = rest.build_put_kitten_request( + content_type=content_type, + json=json, + template_url=self.put_kitten.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py new file mode 100644 index 00000000000..2b8d87fd58b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/_multiple_inheritance_service_client_operations.py @@ -0,0 +1,457 @@ +# 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 .. import _rest as rest, models as _models + +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]] + + +class MultipleInheritanceServiceClientOperationsMixin(object): + @distributed_trace + def get_horse( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Horse" + """Get a horse with name 'Fred' and isAShowHorse true. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Horse, or the result of cls(response) + :rtype: ~multipleinheritance.models.Horse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Horse"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_horse_request( + template_url=self.get_horse.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Horse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore + + @distributed_trace + def put_horse( + self, + horse, # type: "_models.Horse" + **kwargs # type: Any + ): + # type: (...) -> str + """Put a horse with name 'General' and isAShowHorse false. + + :param horse: Put a horse with name 'General' and isAShowHorse false. + :type horse: ~multipleinheritance.models.Horse + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(horse, "Horse") + + request = rest.build_put_horse_request( + content_type=content_type, + json=json, + template_url=self.put_horse.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_horse.metadata = {"url": "/multipleInheritance/horse"} # type: ignore + + @distributed_trace + def get_pet( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Pet" + """Get a pet with name 'Peanut'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~multipleinheritance.models.Pet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Pet"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_pet_request( + template_url=self.get_pet.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore + + @distributed_trace + def put_pet( + self, + name, # type: str + **kwargs # type: Any + ): + # type: (...) -> str + """Put a pet with name 'Butter'. + + :param name: + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + _pet = _models.Pet(name=name) + json = self._serialize.body(_pet, "Pet") + + request = rest.build_put_pet_request( + content_type=content_type, + json=json, + template_url=self.put_pet.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_pet.metadata = {"url": "/multipleInheritance/pet"} # type: ignore + + @distributed_trace + def get_feline( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Feline" + """Get a feline where meows and hisses are true. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Feline, or the result of cls(response) + :rtype: ~multipleinheritance.models.Feline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Feline"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_feline_request( + template_url=self.get_feline.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Feline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore + + @distributed_trace + def put_feline( + self, + feline, # type: "_models.Feline" + **kwargs # type: Any + ): + # type: (...) -> str + """Put a feline who hisses and doesn't meow. + + :param feline: Put a feline who hisses and doesn't meow. + :type feline: ~multipleinheritance.models.Feline + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(feline, "Feline") + + request = rest.build_put_feline_request( + content_type=content_type, + json=json, + template_url=self.put_feline.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_feline.metadata = {"url": "/multipleInheritance/feline"} # type: ignore + + @distributed_trace + def get_cat( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Cat" + """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cat, or the result of cls(response) + :rtype: ~multipleinheritance.models.Cat + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Cat"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_cat_request( + template_url=self.get_cat.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Cat", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore + + @distributed_trace + def put_cat( + self, + cat, # type: "_models.Cat" + **kwargs # type: Any + ): + # type: (...) -> str + """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + + :param cat: Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + :type cat: ~multipleinheritance.models.Cat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(cat, "Cat") + + request = rest.build_put_cat_request( + content_type=content_type, + json=json, + template_url=self.put_cat.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_cat.metadata = {"url": "/multipleInheritance/cat"} # type: ignore + + @distributed_trace + def get_kitten( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Kitten" + """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet + is false. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Kitten, or the result of cls(response) + :rtype: ~multipleinheritance.models.Kitten + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Kitten"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_kitten_request( + template_url=self.get_kitten.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Kitten", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore + + @distributed_trace + def put_kitten( + self, + kitten, # type: "_models.Kitten" + **kwargs # type: Any + ): + # type: (...) -> str + """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is + true. + + :param kitten: Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and + eatsMiceYet is true. + :type kitten: ~multipleinheritance.models.Kitten + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + json = self._serialize.body(kitten, "Kitten") + + request = rest.build_put_kitten_request( + content_type=content_type, + json=json, + template_url=self.put_kitten.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put_kitten.metadata = {"url": "/multipleInheritance/kitten"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/setup.py new file mode 100644 index 00000000000..22685bc333d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/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 = "multipleinheritanceserviceclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="MultipleInheritanceServiceClient", + author_email="", + url="", + keywords=["Swagger", "MultipleInheritanceServiceClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for multiinheritance client testing. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_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/Expected/AcceptanceTests/NoOperations/nooperations/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NoOperations/nooperations/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/models/_models_py3.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/setup.py new file mode 100644 index 00000000000..5371219ae09 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/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 = "nooperationsserviceclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="NoOperationsServiceClient", + author_email="", + url="", + keywords=["Swagger", "NoOperationsServiceClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client with no operations. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_non_string_enums_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_non_string_enums_client.py new file mode 100644 index 00000000000..e4366bdeda8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_non_string_enums_client.py @@ -0,0 +1,98 @@ +# 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 NonStringEnumsClientConfiguration +from .operations import FloatOperations, IntOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class NonStringEnumsClient(object): + """Testing non-string enums. + + :ivar int: IntOperations operations + :vartype int: nonstringenums.operations.IntOperations + :ivar float: FloatOperations operations + :vartype float: nonstringenums.operations.FloatOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = NonStringEnumsClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.int = IntOperations(self._client, self._config, self._serialize, self._deserialize) + self.float = FloatOperations(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. + + We have helper methods to create requests specific to this service in `nonstringenums.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from nonstringenums._rest import int + >>> request = int.build_put_request(json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> NonStringEnumsClient + 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/NonStringEnums/nonstringenums/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_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/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/__init__.py new file mode 100644 index 00000000000..caeb33f5416 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/__init__.py @@ -0,0 +1,19 @@ +# 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_put_request + from ._request_builders_py3 import build_get_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_request # type: ignore + from ._request_builders import build_get_request # type: ignore + +__all__ = [ + "build_put_request", + "build_get_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/_request_builders.py new file mode 100644 index 00000000000..7931da8c695 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/_request_builders.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 typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input float enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input float enum. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/float/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/float/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/_request_builders_py3.py new file mode 100644 index 00000000000..0567c85fedc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/float/_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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input float enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input float enum. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/float/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/float/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/__init__.py new file mode 100644 index 00000000000..caeb33f5416 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/__init__.py @@ -0,0 +1,19 @@ +# 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_put_request + from ._request_builders_py3 import build_get_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_request # type: ignore + from ._request_builders import build_get_request # type: ignore + +__all__ = [ + "build_put_request", + "build_get_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/_request_builders.py new file mode 100644 index 00000000000..5d4782f0d3a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/_request_builders.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 typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input int enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input int enum. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/int/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/int/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/_request_builders_py3.py new file mode 100644 index 00000000000..5bb75e12f4b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_rest/int/_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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input int enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input int enum. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/int/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/int/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_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/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_non_string_enums_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_non_string_enums_client.py new file mode 100644 index 00000000000..0c87fab8069 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/_non_string_enums_client.py @@ -0,0 +1,84 @@ +# 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 NonStringEnumsClientConfiguration +from .operations import FloatOperations, IntOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class NonStringEnumsClient: + """Testing non-string enums. + + :ivar int: IntOperations operations + :vartype int: nonstringenums.aio.operations.IntOperations + :ivar float: FloatOperations operations + :vartype float: nonstringenums.aio.operations.FloatOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = NonStringEnumsClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.int = IntOperations(self._client, self._config, self._serialize, self._deserialize) + self.float = FloatOperations(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. + + We have helper methods to create requests specific to this service in `nonstringenums.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from nonstringenums._rest import int + >>> request = int.build_put_request(json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "NonStringEnumsClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py new file mode 100644 index 00000000000..8fc46a6ca12 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_float_operations.py @@ -0,0 +1,129 @@ +# 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 ..._rest import float as rest_float + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FloatOperations: + """FloatOperations 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 put(self, input: Optional[Union[float, "_models.FloatEnum"]] = None, **kwargs: Any) -> str: + """Put a float enum. + + :param input: Input float enum. + :type input: str or ~nonstringenums.models.FloatEnum + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if input is not None: + json = self._serialize.body(input, "float") + else: + json = None + + request = rest_float.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/nonStringEnums/float/put"} # type: ignore + + @distributed_trace_async + async def get(self, **kwargs: Any) -> Union[float, "_models.FloatEnum"]: + """Get a float enum. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FloatEnum, or the result of cls(response) + :rtype: str or ~nonstringenums.models.FloatEnum + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[float, "_models.FloatEnum"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_float.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/nonStringEnums/float/get"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations.py new file mode 100644 index 00000000000..c42144af87b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations/_int_operations.py @@ -0,0 +1,129 @@ +# 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 ..._rest import int as rest_int + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IntOperations: + """IntOperations 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 put(self, input: Optional[Union[int, "_models.IntEnum"]] = None, **kwargs: Any) -> str: + """Put an int enum. + + :param input: Input int enum. + :type input: str or ~nonstringenums.models.IntEnum + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if input is not None: + json = self._serialize.body(input, "int") + else: + json = None + + request = rest_int.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/nonStringEnums/int/put"} # type: ignore + + @distributed_trace_async + async def get(self, **kwargs: Any) -> Union[int, "_models.IntEnum"]: + """Get an int enum. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntEnum, or the result of cls(response) + :rtype: str or ~nonstringenums.models.IntEnum + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[int, "_models.IntEnum"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/nonStringEnums/int/get"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/_non_string_enums_client_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/_non_string_enums_client_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/_non_string_enums_client_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/models/_non_string_enums_client_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py new file mode 100644 index 00000000000..7dc1d24eccb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py @@ -0,0 +1,137 @@ +# 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 .. import models as _models +from .._rest import float as rest_float + +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]] + + +class FloatOperations(object): + """FloatOperations 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 put( + self, + input=None, # type: Optional[Union[float, "_models.FloatEnum"]] + **kwargs # type: Any + ): + # type: (...) -> str + """Put a float enum. + + :param input: Input float enum. + :type input: str or ~nonstringenums.models.FloatEnum + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if input is not None: + json = self._serialize.body(input, "float") + else: + json = None + + request = rest_float.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/nonStringEnums/float/put"} # type: ignore + + @distributed_trace + def get( + self, **kwargs # type: Any + ): + # type: (...) -> Union[float, "_models.FloatEnum"] + """Get a float enum. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FloatEnum, or the result of cls(response) + :rtype: str or ~nonstringenums.models.FloatEnum + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[float, "_models.FloatEnum"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_float.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("float", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/nonStringEnums/float/get"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py new file mode 100644 index 00000000000..745f7577a3d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py @@ -0,0 +1,137 @@ +# 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 .. import models as _models +from .._rest import int as rest_int + +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]] + + +class IntOperations(object): + """IntOperations 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 put( + self, + input=None, # type: Optional[Union[int, "_models.IntEnum"]] + **kwargs # type: Any + ): + # type: (...) -> str + """Put an int enum. + + :param input: Input int enum. + :type input: str or ~nonstringenums.models.IntEnum + :keyword callable cls: A custom type or function that will be passed the direct response + :return: str, or the result of cls(response) + :rtype: str + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[str] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if input is not None: + json = self._serialize.body(input, "int") + else: + json = None + + request = rest_int.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("str", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/nonStringEnums/int/put"} # type: ignore + + @distributed_trace + def get( + self, **kwargs # type: Any + ): + # type: (...) -> Union[int, "_models.IntEnum"] + """Get an int enum. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntEnum, or the result of cls(response) + :rtype: str or ~nonstringenums.models.IntEnum + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Union[int, "_models.IntEnum"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_int.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("int", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/nonStringEnums/int/get"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/setup.py new file mode 100644 index 00000000000..2be14d7505b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/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 = "nonstringenumsclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="NonStringEnumsClient", + author_email="", + url="", + keywords=["Swagger", "NonStringEnumsClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Testing non-string enums. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_object_type_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_object_type_client.py new file mode 100644 index 00000000000..1e3f0135b92 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_object_type_client.py @@ -0,0 +1,92 @@ +# 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 ObjectTypeClientConfiguration +from .operations import ObjectTypeClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class ObjectTypeClient(ObjectTypeClientOperationsMixin): + """Service client for testing basic type: object swaggers. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = ObjectTypeClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `objecttype.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from objecttype._rest import build_get_request + >>> request = build_get_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> ObjectTypeClient + 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/ObjectType/objecttype/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/__init__.py new file mode 100644 index 00000000000..355267c5498 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_get_request + from ._request_builders_py3 import build_put_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_request # type: ignore + from ._request_builders import build_put_request # type: ignore + +__all__ = [ + "build_get_request", + "build_put_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/_request_builders.py new file mode 100644 index 00000000000..fd4d3ff630a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/_request_builders.py @@ -0,0 +1,94 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an object. Returns object { 'message': 'An object was successfully + returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/objectType/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an + object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/objectType/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..7f811a568bd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_rest/_request_builders_py3.py @@ -0,0 +1,73 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an object. Returns object { 'message': 'An object was successfully + returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/objectType/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an + object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/objectType/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_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/Expected/AcceptanceTests/ObjectType/objecttype/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_object_type_client.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_object_type_client.py new file mode 100644 index 00000000000..bdc8600607b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/_object_type_client.py @@ -0,0 +1,78 @@ +# 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 ObjectTypeClientConfiguration +from .operations import ObjectTypeClientOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class ObjectTypeClient(ObjectTypeClientOperationsMixin): + """Service client for testing basic type: object swaggers. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = ObjectTypeClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `objecttype.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from objecttype._rest import build_get_request + >>> request = build_get_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "ObjectTypeClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py new file mode 100644 index 00000000000..dd4a28fdfe8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py @@ -0,0 +1,108 @@ +# 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 ... import _rest as rest + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ObjectTypeClientOperationsMixin: + @distributed_trace_async + async def get(self, **kwargs: Any) -> Any: + """Basic get that returns an object. Returns object { 'message': 'An object was successfully + returned' }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize("object", response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/objectType/get"} # type: ignore + + @distributed_trace_async + async def put(self, put_object: Any, **kwargs: Any) -> None: + """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an + object error. + + :param put_object: Pass in {'foo': 'bar'} for a 200, anything else for an object error. + :type put_object: any + :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/json") # type: Optional[str] + + json = self._serialize.body(put_object, "object") + + request = rest.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize("object", response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put.metadata = {"url": "/objectType/put"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py new file mode 100644 index 00000000000..2283e92726d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py @@ -0,0 +1,116 @@ +# 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 .. import _rest as rest + +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]] + + +class ObjectTypeClientOperationsMixin(object): + @distributed_trace + def get( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an object. Returns object { 'message': 'An object was successfully + returned' }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_request( + template_url=self.get.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize("object", response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/objectType/get"} # type: ignore + + @distributed_trace + def put( + self, + put_object, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an + object error. + + :param put_object: Pass in {'foo': 'bar'} for a 200, anything else for an object error. + :type put_object: any + :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/json") # type: Optional[str] + + json = self._serialize.body(put_object, "object") + + request = rest.build_put_request( + content_type=content_type, + json=json, + template_url=self.put.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize("object", response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put.metadata = {"url": "/objectType/put"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/setup.py new file mode 100644 index 00000000000..af6035300ac --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/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 = "objecttypeclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="ObjectTypeClient", + author_email="", + url="", + keywords=["Swagger", "ObjectTypeClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for testing basic type: object swaggers. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_auto_rest_parameter_flattening.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_auto_rest_parameter_flattening.py new file mode 100644 index 00000000000..59ea85996a2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_auto_rest_parameter_flattening.py @@ -0,0 +1,98 @@ +# 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 AutoRestParameterFlatteningConfiguration +from .operations import AvailabilitySetsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterFlattening(object): + """Resource Flattening for AutoRest. + + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: parameterflattening.operations.AvailabilitySetsOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterFlatteningConfiguration(**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.availability_sets = AvailabilitySetsOperations( + 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. + + We have helper methods to create requests specific to this service in `parameterflattening.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from parameterflattening._rest import availability_sets + >>> request = availability_sets.build_update_request(resource_group_name, avset, json=json, content=content, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestParameterFlattening + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_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/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/__init__.py new file mode 100644 index 00000000000..0f9c14f9c76 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/__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_request +except (SyntaxError, ImportError): + from ._request_builders import build_update_request # type: ignore + +__all__ = [ + "build_update_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/_request_builders.py new file mode 100644 index 00000000000..8c49a035cc0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/_request_builders.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 TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_update_request( + resource_group_name, # type: str + avset, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Updates the tags for an availability set. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param avset: The name of the storage availability set. + :type avset: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The tags. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The tags. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/parameterFlattening/{resourceGroupName}/{availabilitySetName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'availabilitySetName': _SERIALIZER.url("avset", avset, 'str', max_length=80, min_length=0), + } + 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="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/_request_builders_py3.py new file mode 100644 index 00000000000..e434826145b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_rest/availability_sets/_request_builders_py3.py @@ -0,0 +1,56 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_update_request( + resource_group_name: str, avset: str, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Updates the tags for an availability set. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param avset: The name of the storage availability set. + :type avset: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The tags. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The tags. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/parameterFlattening/{resourceGroupName}/{availabilitySetName}") + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "availabilitySetName": _SERIALIZER.url("avset", avset, "str", max_length=80, min_length=0), + } + 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="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_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/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_auto_rest_parameter_flattening.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_auto_rest_parameter_flattening.py new file mode 100644 index 00000000000..8e10e9011ea --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_auto_rest_parameter_flattening.py @@ -0,0 +1,80 @@ +# 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 AutoRestParameterFlatteningConfiguration +from .operations import AvailabilitySetsOperations + + +class AutoRestParameterFlattening: + """Resource Flattening for AutoRest. + + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: parameterflattening.aio.operations.AvailabilitySetsOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterFlatteningConfiguration(**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.availability_sets = AvailabilitySetsOperations( + 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. + + We have helper methods to create requests specific to this service in `parameterflattening.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from parameterflattening._rest import availability_sets + >>> request = availability_sets.build_update_request(resource_group_name, avset, json=json, content=content, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestParameterFlattening": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py new file mode 100644 index 00000000000..7fe3c97f37b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/aio/operations/_availability_sets_operations.py @@ -0,0 +1,97 @@ +# 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 ... import models as _models +from ..._rest import availability_sets as rest_availability_sets + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AvailabilitySetsOperations: + """AvailabilitySetsOperations 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: ~parameterflattening.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(self, resource_group_name: str, avset: str, tags: Dict[str, str], **kwargs: Any) -> None: + """Updates the tags for an availability set. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param avset: The name of the storage availability set. + :type avset: str + :param tags: A description about the set of tags. + :type tags: dict[str, 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/json") # type: Optional[str] + + _tags = _models.AvailabilitySetUpdateParameters(tags=tags) + json = self._serialize.body(_tags, "AvailabilitySetUpdateParameters") + + request = rest_availability_sets.build_update_request( + resource_group_name=resource_group_name, + avset=avset, + content_type=content_type, + json=json, + template_url=self.update.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.metadata = {"url": "/parameterFlattening/{resourceGroupName}/{availabilitySetName}"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py new file mode 100644 index 00000000000..b5f4f21165f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/operations/_availability_sets_operations.py @@ -0,0 +1,106 @@ +# 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 .. import models as _models +from .._rest import availability_sets as rest_availability_sets + +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]] + + +class AvailabilitySetsOperations(object): + """AvailabilitySetsOperations 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: ~parameterflattening.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( + self, + resource_group_name, # type: str + avset, # type: str + tags, # type: Dict[str, str] + **kwargs # type: Any + ): + # type: (...) -> None + """Updates the tags for an availability set. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param avset: The name of the storage availability set. + :type avset: str + :param tags: A description about the set of tags. + :type tags: dict[str, 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/json") # type: Optional[str] + + _tags = _models.AvailabilitySetUpdateParameters(tags=tags) + json = self._serialize.body(_tags, "AvailabilitySetUpdateParameters") + + request = rest_availability_sets.build_update_request( + resource_group_name=resource_group_name, + avset=avset, + content_type=content_type, + json=json, + template_url=self.update.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.metadata = {"url": "/parameterFlattening/{resourceGroupName}/{availabilitySetName}"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/setup.py new file mode 100644 index 00000000000..cb58a52fd5c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/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 = "autorestparameterflattening" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterFlattening", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterFlattening"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Resource Flattening for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_auto_rest_report_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_auto_rest_report_service.py new file mode 100644 index 00000000000..8cb575e7ac2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_auto_rest_report_service.py @@ -0,0 +1,93 @@ +# 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 AutoRestReportServiceConfiguration +from .operations import AutoRestReportServiceOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestReportService(AutoRestReportServiceOperationsMixin): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceConfiguration(**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 + + 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 `report.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from report._rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestReportService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/__init__.py new file mode 100644 index 00000000000..7d62f26b1bd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/__init__.py @@ -0,0 +1,19 @@ +# 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_get_report_request + from ._request_builders_py3 import build_get_optional_report_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_report_request # type: ignore + from ._request_builders import build_get_optional_report_request # type: ignore + +__all__ = [ + "build_get_report_request", + "build_get_optional_report_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/_request_builders.py new file mode 100644 index 00000000000..ba1d5da92b7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/_request_builders.py @@ -0,0 +1,104 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_report_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + """ + + qualifier = kwargs.pop('qualifier', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/report') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters['qualifier'] = _SERIALIZER.query("qualifier", qualifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_optional_report_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get optional test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + """ + + qualifier = kwargs.pop('qualifier', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/report/optional') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters['qualifier'] = _SERIALIZER.query("qualifier", qualifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..dbaa4a1193b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_rest/_request_builders_py3.py @@ -0,0 +1,77 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_report_request(*, qualifier: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/report") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters["qualifier"] = _SERIALIZER.query("qualifier", qualifier, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_optional_report_request(*, qualifier: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get optional test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/report/optional") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters["qualifier"] = _SERIALIZER.query("qualifier", qualifier, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_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/Expected/AcceptanceTests/Report/report/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_auto_rest_report_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_auto_rest_report_service.py new file mode 100644 index 00000000000..0c22253146c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_auto_rest_report_service.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 + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutoRestReportServiceConfiguration +from .operations import AutoRestReportServiceOperationsMixin + + +class AutoRestReportService(AutoRestReportServiceOperationsMixin): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceConfiguration(**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 + + 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 `report.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from report._rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestReportService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py new file mode 100644 index 00000000000..d5615e0e2e5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py @@ -0,0 +1,113 @@ +# 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 ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutoRestReportServiceOperationsMixin: + @distributed_trace_async + async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str, int]: + """Get test coverage report. + + :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in + for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :type qualifier: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_report_request( + qualifier=qualifier, + template_url=self.get_report.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_report.metadata = {"url": "/report"} # type: ignore + + @distributed_trace_async + async def get_optional_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> Dict[str, int]: + """Get optional test coverage report. + + :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in + for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :type qualifier: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_optional_report_request( + qualifier=qualifier, + template_url=self.get_optional_report.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_optional_report.metadata = {"url": "/report/optional"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Report/report/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Report/report/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py new file mode 100644 index 00000000000..d9972afce93 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/operations/_auto_rest_report_service_operations.py @@ -0,0 +1,123 @@ +# 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 .. import _rest as rest, models as _models + +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]] + + +class AutoRestReportServiceOperationsMixin(object): + @distributed_trace + def get_report( + self, + qualifier=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get test coverage report. + + :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in + for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :type qualifier: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_report_request( + qualifier=qualifier, + template_url=self.get_report.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_report.metadata = {"url": "/report"} # type: ignore + + @distributed_trace + def get_optional_report( + self, + qualifier=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Dict[str, int] + """Get optional test coverage report. + + :param qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' in + for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :type qualifier: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: dict mapping str to int, or the result of cls(response) + :rtype: dict[str, int] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, int]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_get_optional_report_request( + qualifier=qualifier, + template_url=self.get_optional_report.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("{int}", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_optional_report.metadata = {"url": "/report/optional"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Report/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Report/setup.py new file mode 100644 index 00000000000..c8c36f71df3 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Report/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 = "autorestreportservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestReportService", + author_email="", + url="", + keywords=["Swagger", "AutoRestReportService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_auto_rest_required_optional_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_auto_rest_required_optional_test_service.py new file mode 100644 index 00000000000..3e17f3d6c04 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_auto_rest_required_optional_test_service.py @@ -0,0 +1,109 @@ +# 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 AutoRestRequiredOptionalTestServiceConfiguration +from .operations import ExplicitOperations, ImplicitOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestRequiredOptionalTestService(object): + """Test Infrastructure for AutoRest. + + :ivar implicit: ImplicitOperations operations + :vartype implicit: requiredoptional.operations.ImplicitOperations + :ivar explicit: ExplicitOperations operations + :vartype explicit: requiredoptional.operations.ExplicitOperations + :param required_global_path: number of items to skip. + :type required_global_path: str + :param required_global_query: number of items to skip. + :type required_global_query: str + :param optional_global_query: number of items to skip. + :type optional_global_query: int + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + required_global_path, # type: str + required_global_query, # type: str + optional_global_query=None, # type: Optional[int] + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRequiredOptionalTestServiceConfiguration( + required_global_path, required_global_query, optional_global_query, **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.implicit = ImplicitOperations(self._client, self._config, self._serialize, self._deserialize) + self.explicit = ExplicitOperations(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. + + We have helper methods to create requests specific to this service in `requiredoptional.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from requiredoptional._rest import implicit + >>> request = implicit.build_get_required_path_request(path_parameter, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestRequiredOptionalTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_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/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/__init__.py new file mode 100644 index 00000000000..573a6e28340 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_put_optional_binary_body_request + from ._request_builders_py3 import build_put_required_binary_body_request + from ._request_builders_py3 import build_post_required_integer_parameter_request + from ._request_builders_py3 import build_post_optional_integer_parameter_request + from ._request_builders_py3 import build_post_required_integer_property_request + from ._request_builders_py3 import build_post_optional_integer_property_request + from ._request_builders_py3 import build_post_required_integer_header_request + from ._request_builders_py3 import build_post_optional_integer_header_request + from ._request_builders_py3 import build_post_required_string_parameter_request + from ._request_builders_py3 import build_post_optional_string_parameter_request + from ._request_builders_py3 import build_post_required_string_property_request + from ._request_builders_py3 import build_post_optional_string_property_request + from ._request_builders_py3 import build_post_required_string_header_request + from ._request_builders_py3 import build_post_optional_string_header_request + from ._request_builders_py3 import build_post_required_class_parameter_request + from ._request_builders_py3 import build_post_optional_class_parameter_request + from ._request_builders_py3 import build_post_required_class_property_request + from ._request_builders_py3 import build_post_optional_class_property_request + from ._request_builders_py3 import build_post_required_array_parameter_request + from ._request_builders_py3 import build_post_optional_array_parameter_request + from ._request_builders_py3 import build_post_required_array_property_request + from ._request_builders_py3 import build_post_optional_array_property_request + from ._request_builders_py3 import build_post_required_array_header_request + from ._request_builders_py3 import build_post_optional_array_header_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_optional_binary_body_request # type: ignore + from ._request_builders import build_put_required_binary_body_request # type: ignore + from ._request_builders import build_post_required_integer_parameter_request # type: ignore + from ._request_builders import build_post_optional_integer_parameter_request # type: ignore + from ._request_builders import build_post_required_integer_property_request # type: ignore + from ._request_builders import build_post_optional_integer_property_request # type: ignore + from ._request_builders import build_post_required_integer_header_request # type: ignore + from ._request_builders import build_post_optional_integer_header_request # type: ignore + from ._request_builders import build_post_required_string_parameter_request # type: ignore + from ._request_builders import build_post_optional_string_parameter_request # type: ignore + from ._request_builders import build_post_required_string_property_request # type: ignore + from ._request_builders import build_post_optional_string_property_request # type: ignore + from ._request_builders import build_post_required_string_header_request # type: ignore + from ._request_builders import build_post_optional_string_header_request # type: ignore + from ._request_builders import build_post_required_class_parameter_request # type: ignore + from ._request_builders import build_post_optional_class_parameter_request # type: ignore + from ._request_builders import build_post_required_class_property_request # type: ignore + from ._request_builders import build_post_optional_class_property_request # type: ignore + from ._request_builders import build_post_required_array_parameter_request # type: ignore + from ._request_builders import build_post_optional_array_parameter_request # type: ignore + from ._request_builders import build_post_required_array_property_request # type: ignore + from ._request_builders import build_post_optional_array_property_request # type: ignore + from ._request_builders import build_post_required_array_header_request # type: ignore + from ._request_builders import build_post_optional_array_header_request # type: ignore + +__all__ = [ + "build_put_optional_binary_body_request", + "build_put_required_binary_body_request", + "build_post_required_integer_parameter_request", + "build_post_optional_integer_parameter_request", + "build_post_required_integer_property_request", + "build_post_optional_integer_property_request", + "build_post_required_integer_header_request", + "build_post_optional_integer_header_request", + "build_post_required_string_parameter_request", + "build_post_optional_string_parameter_request", + "build_post_required_string_property_request", + "build_post_optional_string_property_request", + "build_post_required_string_header_request", + "build_post_optional_string_header_request", + "build_post_required_class_parameter_request", + "build_post_optional_class_parameter_request", + "build_post_required_class_property_request", + "build_post_optional_class_property_request", + "build_post_required_array_parameter_request", + "build_post_optional_array_parameter_request", + "build_post_required_array_property_request", + "build_post_optional_array_property_request", + "build_post_required_array_header_request", + "build_post_optional_array_header_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/_request_builders.py new file mode 100644 index 00000000000..723df61888d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/_request_builders.py @@ -0,0 +1,981 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_optional_binary_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/explicit/optional/binary-body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_required_binary_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/explicit/required/binary-body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_integer_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required integer. Please put null and the client library should throw before + the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/integer/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_integer_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/integer/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_integer_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/integer/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_integer_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/integer/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_integer_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required integer. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + header_parameter = kwargs.pop('header_parameter') # type: int + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/integer/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_integer_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + header_parameter = kwargs.pop('header_parameter', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/integer/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_string_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required string. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/string/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_string_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional string. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/string/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_string_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/string/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_string_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/string/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_string_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required string. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: str + :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 + """ + + header_parameter = kwargs.pop('header_parameter') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/string/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_string_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional string. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword body_parameter: + :paramtype body_parameter: str + :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 + """ + + body_parameter = kwargs.pop('body_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/string/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if body_parameter is not None: + header_parameters['bodyParameter'] = _SERIALIZER.header("body_parameter", body_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_class_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required complex object. Please put null and the client library should throw + before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/class/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_class_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional complex object. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/class/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_class_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null + and the client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/class/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_class_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/class/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_array_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required array. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/array/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_array_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional array. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/array/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_array_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/array/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_array_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/array/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_array_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required array. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + header_parameter = kwargs.pop('header_parameter') # type: List[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/array/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, '[str]', div=',') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_array_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + header_parameter = kwargs.pop('header_parameter', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/array/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, '[str]', div=',') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/_request_builders_py3.py new file mode 100644 index 00000000000..da467d73abf --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/explicit/_request_builders_py3.py @@ -0,0 +1,788 @@ +# 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, IO, List, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_optional_binary_body_request(*, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/explicit/optional/binary-body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_put_required_binary_body_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Test explicitly required body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/explicit/required/binary-body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_post_required_integer_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly required integer. Please put null and the client library should throw before + the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/integer/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_integer_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional integer. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/integer/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_integer_property_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/integer/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_integer_property_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/integer/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_integer_header_request(*, header_parameter: int, **kwargs: Any) -> HttpRequest: + """Test explicitly required integer. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/integer/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_optional_integer_header_request(*, header_parameter: Optional[int] = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/integer/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_required_string_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly required string. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/string/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_string_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional string. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/string/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_string_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/string/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_string_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/string/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_string_header_request(*, header_parameter: str, **kwargs: Any) -> HttpRequest: + """Test explicitly required string. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/string/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_optional_string_header_request(*, body_parameter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional string. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword body_parameter: + :paramtype body_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/string/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if body_parameter is not None: + header_parameters["bodyParameter"] = _SERIALIZER.header("body_parameter", body_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_required_class_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required complex object. Please put null and the client library should throw + before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/class/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_class_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional complex object. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/class/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_class_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null + and the client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/class/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_class_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/class/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_array_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required array. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/array/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_array_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional array. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/array/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_array_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/array/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_array_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/array/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_array_header_request(*, header_parameter: List[str], **kwargs: Any) -> HttpRequest: + """Test explicitly required array. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/array/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "[str]", div=",") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_optional_array_header_request( + *, header_parameter: Optional[List[str]] = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/array/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters["headerParameter"] = _SERIALIZER.header( + "header_parameter", header_parameter, "[str]", div="," + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/__init__.py new file mode 100644 index 00000000000..7963f152b24 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_get_required_path_request + from ._request_builders_py3 import build_put_optional_query_request + from ._request_builders_py3 import build_put_optional_header_request + from ._request_builders_py3 import build_put_optional_body_request + from ._request_builders_py3 import build_put_optional_binary_body_request + from ._request_builders_py3 import build_get_required_global_path_request + from ._request_builders_py3 import build_get_required_global_query_request + from ._request_builders_py3 import build_get_optional_global_query_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_required_path_request # type: ignore + from ._request_builders import build_put_optional_query_request # type: ignore + from ._request_builders import build_put_optional_header_request # type: ignore + from ._request_builders import build_put_optional_body_request # type: ignore + from ._request_builders import build_put_optional_binary_body_request # type: ignore + from ._request_builders import build_get_required_global_path_request # type: ignore + from ._request_builders import build_get_required_global_query_request # type: ignore + from ._request_builders import build_get_optional_global_query_request # type: ignore + +__all__ = [ + "build_get_required_path_request", + "build_put_optional_query_request", + "build_put_optional_header_request", + "build_put_optional_body_request", + "build_put_optional_binary_body_request", + "build_get_required_global_path_request", + "build_get_required_global_query_request", + "build_get_optional_global_query_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/_request_builders.py new file mode 100644 index 00000000000..102491aea4d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/_request_builders.py @@ -0,0 +1,333 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_required_path_request( + path_parameter, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_parameter: + :type path_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/required/path/{pathParameter}') + path_format_arguments = { + 'pathParameter': _SERIALIZER.url("path_parameter", path_parameter, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_query_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + query_parameter = kwargs.pop('query_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/query') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_parameter is not None: + query_parameters['queryParameter'] = _SERIALIZER.query("query_parameter", query_parameter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional header parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + query_parameter = kwargs.pop('query_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if query_parameter is not None: + header_parameters['queryParameter'] = _SERIALIZER.header("query_parameter", query_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_binary_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/binary-body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_required_global_path_request( + required_global_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/global/required/path/{required-global-path}') + path_format_arguments = { + 'required-global-path': _SERIALIZER.url("required_global_path", required_global_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_required_global_query_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly required query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_global_query: number of items to skip. + :paramtype required_global_query: str + :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 + """ + + required_global_query = kwargs.pop('required_global_query') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/global/required/query') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['required-global-query'] = _SERIALIZER.query("required_global_query", required_global_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_optional_global_query_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword optional_global_query: number of items to skip. + :paramtype optional_global_query: int + :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 + """ + + optional_global_query = kwargs.pop('optional_global_query', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/global/optional/query') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if optional_global_query is not None: + query_parameters['optional-global-query'] = _SERIALIZER.query("optional_global_query", optional_global_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/_request_builders_py3.py new file mode 100644 index 00000000000..ca714ca0d86 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_rest/implicit/_request_builders_py3.py @@ -0,0 +1,255 @@ +# 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, IO, List, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_required_path_request(path_parameter: str, **kwargs: Any) -> HttpRequest: + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_parameter: + :type path_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/required/path/{pathParameter}") + path_format_arguments = { + "pathParameter": _SERIALIZER.url("path_parameter", path_parameter, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_optional_query_request(*, query_parameter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/query") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_parameter is not None: + query_parameters["queryParameter"] = _SERIALIZER.query("query_parameter", query_parameter, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_put_optional_header_request(*, query_parameter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional header parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if query_parameter is not None: + header_parameters["queryParameter"] = _SERIALIZER.header("query_parameter", query_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, **kwargs) + + +def build_put_optional_body_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_optional_binary_body_request(*, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/binary-body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_required_global_path_request(required_global_path: str, **kwargs: Any) -> HttpRequest: + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/global/required/path/{required-global-path}") + path_format_arguments = { + "required-global-path": _SERIALIZER.url("required_global_path", required_global_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_required_global_query_request(*, required_global_query: str, **kwargs: Any) -> HttpRequest: + """Test implicitly required query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_global_query: number of items to skip. + :paramtype required_global_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/global/required/query") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["required-global-query"] = _SERIALIZER.query("required_global_query", required_global_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_optional_global_query_request( + *, optional_global_query: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword optional_global_query: number of items to skip. + :paramtype optional_global_query: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/global/optional/query") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if optional_global_query is not None: + query_parameters["optional-global-query"] = _SERIALIZER.query( + "optional_global_query", optional_global_query, "int" + ) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/_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/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_auto_rest_required_optional_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_auto_rest_required_optional_test_service.py new file mode 100644 index 00000000000..ff0cc1fa76f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_auto_rest_required_optional_test_service.py @@ -0,0 +1,95 @@ +# 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 AutoRestRequiredOptionalTestServiceConfiguration +from .operations import ExplicitOperations, ImplicitOperations + + +class AutoRestRequiredOptionalTestService: + """Test Infrastructure for AutoRest. + + :ivar implicit: ImplicitOperations operations + :vartype implicit: requiredoptional.aio.operations.ImplicitOperations + :ivar explicit: ExplicitOperations operations + :vartype explicit: requiredoptional.aio.operations.ExplicitOperations + :param required_global_path: number of items to skip. + :type required_global_path: str + :param required_global_query: number of items to skip. + :type required_global_query: str + :param optional_global_query: number of items to skip. + :type optional_global_query: int + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + required_global_path: str, + required_global_query: str, + optional_global_query: Optional[int] = None, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRequiredOptionalTestServiceConfiguration( + required_global_path, required_global_query, optional_global_query, **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.implicit = ImplicitOperations(self._client, self._config, self._serialize, self._deserialize) + self.explicit = ExplicitOperations(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. + + We have helper methods to create requests specific to this service in `requiredoptional.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from requiredoptional._rest import implicit + >>> request = implicit.build_get_required_path_request(path_parameter, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestRequiredOptionalTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py new file mode 100644 index 00000000000..31d24dfdcb7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_explicit_operations.py @@ -0,0 +1,1032 @@ +# 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, IO, List, 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 ... import models as _models +from ..._rest import explicit as rest_explicit + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ExplicitOperations: + """ExplicitOperations 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: ~requiredoptional.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 put_optional_binary_body(self, body_parameter: Optional[IO] = None, **kwargs: Any) -> None: + """Test explicitly optional body parameter. + + :param body_parameter: + :type body_parameter: IO + :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/octet-stream") # type: Optional[str] + + content = body_parameter + + request = rest_explicit.build_put_optional_binary_body_request( + content_type=content_type, + content=content, + template_url=self.put_optional_binary_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_binary_body.metadata = {"url": "/reqopt/explicit/optional/binary-body"} # type: ignore + + @distributed_trace_async + async def put_required_binary_body(self, body_parameter: IO, **kwargs: Any) -> None: + """Test explicitly required body parameter. + + :param body_parameter: + :type body_parameter: IO + :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/octet-stream") # type: Optional[str] + + content = body_parameter + + request = rest_explicit.build_put_required_binary_body_request( + content_type=content_type, + content=content, + template_url=self.put_required_binary_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_required_binary_body.metadata = {"url": "/reqopt/explicit/required/binary-body"} # type: ignore + + @distributed_trace_async + async def post_required_integer_parameter(self, body_parameter: int, **kwargs: Any) -> None: + """Test explicitly required integer. Please put null and the client library should throw before + the request is sent. + + :param body_parameter: + :type body_parameter: int + :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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "int") + + request = rest_explicit.build_post_required_integer_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_integer_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_integer_parameter.metadata = {"url": "/reqopt/requied/integer/parameter"} # type: ignore + + @distributed_trace_async + async def post_optional_integer_parameter(self, body_parameter: Optional[int] = None, **kwargs: Any) -> None: + """Test explicitly optional integer. Please put null. + + :param body_parameter: + :type body_parameter: int + :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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "int") + else: + json = None + + request = rest_explicit.build_post_optional_integer_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_integer_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_integer_parameter.metadata = {"url": "/reqopt/optional/integer/parameter"} # type: ignore + + @distributed_trace_async + async def post_required_integer_property(self, value: int, **kwargs: Any) -> None: + """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the + client library should throw before the request is sent. + + :param value: + :type value: int + :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/json") # type: Optional[str] + + _body_parameter = _models.IntWrapper(value=value) + json = self._serialize.body(_body_parameter, "IntWrapper") + + request = rest_explicit.build_post_required_integer_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_integer_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_integer_property.metadata = {"url": "/reqopt/requied/integer/property"} # type: ignore + + @distributed_trace_async + async def post_optional_integer_property(self, value: Optional[int] = None, **kwargs: Any) -> None: + """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. + + :param value: + :type value: int + :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/json") # type: Optional[str] + + _body_parameter = _models.IntOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "IntOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_integer_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_integer_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_integer_property.metadata = {"url": "/reqopt/optional/integer/property"} # type: ignore + + @distributed_trace_async + async def post_required_integer_header(self, header_parameter: int, **kwargs: Any) -> None: + """Test explicitly required integer. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + :param header_parameter: + :type header_parameter: int + :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", {})) + + request = rest_explicit.build_post_required_integer_header_request( + header_parameter=header_parameter, + template_url=self.post_required_integer_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_integer_header.metadata = {"url": "/reqopt/requied/integer/header"} # type: ignore + + @distributed_trace_async + async def post_optional_integer_header(self, header_parameter: Optional[int] = None, **kwargs: Any) -> None: + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + :param header_parameter: + :type header_parameter: int + :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", {})) + + request = rest_explicit.build_post_optional_integer_header_request( + header_parameter=header_parameter, + template_url=self.post_optional_integer_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_integer_header.metadata = {"url": "/reqopt/optional/integer/header"} # type: ignore + + @distributed_trace_async + async def post_required_string_parameter(self, body_parameter: str, **kwargs: Any) -> None: + """Test explicitly required string. Please put null and the client library should throw before the + request is sent. + + :param body_parameter: + :type body_parameter: 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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "str") + + request = rest_explicit.build_post_required_string_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_string_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_string_parameter.metadata = {"url": "/reqopt/requied/string/parameter"} # type: ignore + + @distributed_trace_async + async def post_optional_string_parameter(self, body_parameter: Optional[str] = None, **kwargs: Any) -> None: + """Test explicitly optional string. Please put null. + + :param body_parameter: + :type body_parameter: 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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "str") + else: + json = None + + request = rest_explicit.build_post_optional_string_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_string_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_string_parameter.metadata = {"url": "/reqopt/optional/string/parameter"} # type: ignore + + @distributed_trace_async + async def post_required_string_property(self, value: str, **kwargs: Any) -> None: + """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the + client library should throw before the request is sent. + + :param value: + :type value: 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/json") # type: Optional[str] + + _body_parameter = _models.StringWrapper(value=value) + json = self._serialize.body(_body_parameter, "StringWrapper") + + request = rest_explicit.build_post_required_string_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_string_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_string_property.metadata = {"url": "/reqopt/requied/string/property"} # type: ignore + + @distributed_trace_async + async def post_optional_string_property(self, value: Optional[str] = None, **kwargs: Any) -> None: + """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. + + :param value: + :type value: 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/json") # type: Optional[str] + + _body_parameter = _models.StringOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "StringOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_string_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_string_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_string_property.metadata = {"url": "/reqopt/optional/string/property"} # type: ignore + + @distributed_trace_async + async def post_required_string_header(self, header_parameter: str, **kwargs: Any) -> None: + """Test explicitly required string. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + :param header_parameter: + :type header_parameter: 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", {})) + + request = rest_explicit.build_post_required_string_header_request( + header_parameter=header_parameter, + template_url=self.post_required_string_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_string_header.metadata = {"url": "/reqopt/requied/string/header"} # type: ignore + + @distributed_trace_async + async def post_optional_string_header(self, body_parameter: Optional[str] = None, **kwargs: Any) -> None: + """Test explicitly optional string. Please put a header 'headerParameter' => null. + + :param body_parameter: + :type body_parameter: 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", {})) + + request = rest_explicit.build_post_optional_string_header_request( + body_parameter=body_parameter, + template_url=self.post_optional_string_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_string_header.metadata = {"url": "/reqopt/optional/string/header"} # type: ignore + + @distributed_trace_async + async def post_required_class_parameter(self, body_parameter: "_models.Product", **kwargs: Any) -> None: + """Test explicitly required complex object. Please put null and the client library should throw + before the request is sent. + + :param body_parameter: + :type body_parameter: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "Product") + + request = rest_explicit.build_post_required_class_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_class_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_class_parameter.metadata = {"url": "/reqopt/requied/class/parameter"} # type: ignore + + @distributed_trace_async + async def post_optional_class_parameter( + self, body_parameter: Optional["_models.Product"] = None, **kwargs: Any + ) -> None: + """Test explicitly optional complex object. Please put null. + + :param body_parameter: + :type body_parameter: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "Product") + else: + json = None + + request = rest_explicit.build_post_optional_class_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_class_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_class_parameter.metadata = {"url": "/reqopt/optional/class/parameter"} # type: ignore + + @distributed_trace_async + async def post_required_class_property(self, value: "_models.Product", **kwargs: Any) -> None: + """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null + and the client library should throw before the request is sent. + + :param value: + :type value: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + _body_parameter = _models.ClassWrapper(value=value) + json = self._serialize.body(_body_parameter, "ClassWrapper") + + request = rest_explicit.build_post_required_class_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_class_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_class_property.metadata = {"url": "/reqopt/requied/class/property"} # type: ignore + + @distributed_trace_async + async def post_optional_class_property(self, value: Optional["_models.Product"] = None, **kwargs: Any) -> None: + """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. + + :param value: + :type value: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + _body_parameter = _models.ClassOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "ClassOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_class_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_class_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_class_property.metadata = {"url": "/reqopt/optional/class/property"} # type: ignore + + @distributed_trace_async + async def post_required_array_parameter(self, body_parameter: List[str], **kwargs: Any) -> None: + """Test explicitly required array. Please put null and the client library should throw before the + request is sent. + + :param body_parameter: + :type body_parameter: list[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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "[str]") + + request = rest_explicit.build_post_required_array_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_array_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_array_parameter.metadata = {"url": "/reqopt/requied/array/parameter"} # type: ignore + + @distributed_trace_async + async def post_optional_array_parameter(self, body_parameter: Optional[List[str]] = None, **kwargs: Any) -> None: + """Test explicitly optional array. Please put null. + + :param body_parameter: + :type body_parameter: list[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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "[str]") + else: + json = None + + request = rest_explicit.build_post_optional_array_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_array_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_array_parameter.metadata = {"url": "/reqopt/optional/array/parameter"} # type: ignore + + @distributed_trace_async + async def post_required_array_property(self, value: List[str], **kwargs: Any) -> None: + """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the + client library should throw before the request is sent. + + :param value: + :type value: list[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/json") # type: Optional[str] + + _body_parameter = _models.ArrayWrapper(value=value) + json = self._serialize.body(_body_parameter, "ArrayWrapper") + + request = rest_explicit.build_post_required_array_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_array_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_array_property.metadata = {"url": "/reqopt/requied/array/property"} # type: ignore + + @distributed_trace_async + async def post_optional_array_property(self, value: Optional[List[str]] = None, **kwargs: Any) -> None: + """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. + + :param value: + :type value: list[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/json") # type: Optional[str] + + _body_parameter = _models.ArrayOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "ArrayOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_array_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_array_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_array_property.metadata = {"url": "/reqopt/optional/array/property"} # type: ignore + + @distributed_trace_async + async def post_required_array_header(self, header_parameter: List[str], **kwargs: Any) -> None: + """Test explicitly required array. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + :param header_parameter: + :type header_parameter: list[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", {})) + + request = rest_explicit.build_post_required_array_header_request( + header_parameter=header_parameter, + template_url=self.post_required_array_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_array_header.metadata = {"url": "/reqopt/requied/array/header"} # type: ignore + + @distributed_trace_async + async def post_optional_array_header(self, header_parameter: Optional[List[str]] = None, **kwargs: Any) -> None: + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + :param header_parameter: + :type header_parameter: list[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", {})) + + request = rest_explicit.build_post_optional_array_header_request( + header_parameter=header_parameter, + template_url=self.post_optional_array_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_array_header.metadata = {"url": "/reqopt/optional/array/header"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py new file mode 100644 index 00000000000..821d0f6041e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/aio/operations/_implicit_operations.py @@ -0,0 +1,344 @@ +# 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, IO, 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 ... import models as _models +from ..._rest import implicit as rest_implicit + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ImplicitOperations: + """ImplicitOperations 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: ~requiredoptional.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 get_required_path(self, path_parameter: str, **kwargs: Any) -> None: + """Test implicitly required path parameter. + + :param path_parameter: + :type path_parameter: 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", {})) + + request = rest_implicit.build_get_required_path_request( + path_parameter=path_parameter, + template_url=self.get_required_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_required_path.metadata = {"url": "/reqopt/implicit/required/path/{pathParameter}"} # type: ignore + + @distributed_trace_async + async def put_optional_query(self, query_parameter: Optional[str] = None, **kwargs: Any) -> None: + """Test implicitly optional query parameter. + + :param query_parameter: + :type query_parameter: 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", {})) + + request = rest_implicit.build_put_optional_query_request( + query_parameter=query_parameter, + template_url=self.put_optional_query.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_query.metadata = {"url": "/reqopt/implicit/optional/query"} # type: ignore + + @distributed_trace_async + async def put_optional_header(self, query_parameter: Optional[str] = None, **kwargs: Any) -> None: + """Test implicitly optional header parameter. + + :param query_parameter: + :type query_parameter: 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", {})) + + request = rest_implicit.build_put_optional_header_request( + query_parameter=query_parameter, + template_url=self.put_optional_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_header.metadata = {"url": "/reqopt/implicit/optional/header"} # type: ignore + + @distributed_trace_async + async def put_optional_body(self, body_parameter: Optional[str] = None, **kwargs: Any) -> None: + """Test implicitly optional body parameter. + + :param body_parameter: + :type body_parameter: 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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "str") + else: + json = None + + request = rest_implicit.build_put_optional_body_request( + content_type=content_type, + json=json, + template_url=self.put_optional_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_body.metadata = {"url": "/reqopt/implicit/optional/body"} # type: ignore + + @distributed_trace_async + async def put_optional_binary_body(self, body_parameter: Optional[IO] = None, **kwargs: Any) -> None: + """Test implicitly optional body parameter. + + :param body_parameter: + :type body_parameter: IO + :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/octet-stream") # type: Optional[str] + + content = body_parameter + + request = rest_implicit.build_put_optional_binary_body_request( + content_type=content_type, + content=content, + template_url=self.put_optional_binary_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_binary_body.metadata = {"url": "/reqopt/implicit/optional/binary-body"} # type: ignore + + @distributed_trace_async + async def get_required_global_path(self, **kwargs: Any) -> None: + """Test implicitly required path parameter. + + :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", {})) + + request = rest_implicit.build_get_required_global_path_request( + required_global_path=self._config.required_global_path, + template_url=self.get_required_global_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_required_global_path.metadata = {"url": "/reqopt/global/required/path/{required-global-path}"} # type: ignore + + @distributed_trace_async + async def get_required_global_query(self, **kwargs: Any) -> None: + """Test implicitly required query parameter. + + :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", {})) + + request = rest_implicit.build_get_required_global_query_request( + required_global_query=self._config.required_global_query, + template_url=self.get_required_global_query.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_required_global_query.metadata = {"url": "/reqopt/global/required/query"} # type: ignore + + @distributed_trace_async + async def get_optional_global_query(self, **kwargs: Any) -> None: + """Test implicitly optional query parameter. + + :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", {})) + + request = rest_implicit.build_get_optional_global_query_request( + optional_global_query=self._config.optional_global_query, + template_url=self.get_optional_global_query.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_optional_global_query.metadata = {"url": "/reqopt/global/optional/query"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py new file mode 100644 index 00000000000..fbc348d9655 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_explicit_operations.py @@ -0,0 +1,1106 @@ +# 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 .. import models as _models +from .._rest import explicit as rest_explicit + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class ExplicitOperations(object): + """ExplicitOperations 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: ~requiredoptional.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 put_optional_binary_body( + self, + body_parameter=None, # type: Optional[IO] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional body parameter. + + :param body_parameter: + :type body_parameter: IO + :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/octet-stream") # type: Optional[str] + + content = body_parameter + + request = rest_explicit.build_put_optional_binary_body_request( + content_type=content_type, + content=content, + template_url=self.put_optional_binary_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_binary_body.metadata = {"url": "/reqopt/explicit/optional/binary-body"} # type: ignore + + @distributed_trace + def put_required_binary_body( + self, + body_parameter, # type: IO + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required body parameter. + + :param body_parameter: + :type body_parameter: IO + :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/octet-stream") # type: Optional[str] + + content = body_parameter + + request = rest_explicit.build_put_required_binary_body_request( + content_type=content_type, + content=content, + template_url=self.put_required_binary_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_required_binary_body.metadata = {"url": "/reqopt/explicit/required/binary-body"} # type: ignore + + @distributed_trace + def post_required_integer_parameter( + self, + body_parameter, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required integer. Please put null and the client library should throw before + the request is sent. + + :param body_parameter: + :type body_parameter: int + :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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "int") + + request = rest_explicit.build_post_required_integer_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_integer_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_integer_parameter.metadata = {"url": "/reqopt/requied/integer/parameter"} # type: ignore + + @distributed_trace + def post_optional_integer_parameter( + self, + body_parameter=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional integer. Please put null. + + :param body_parameter: + :type body_parameter: int + :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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "int") + else: + json = None + + request = rest_explicit.build_post_optional_integer_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_integer_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_integer_parameter.metadata = {"url": "/reqopt/optional/integer/parameter"} # type: ignore + + @distributed_trace + def post_required_integer_property( + self, + value, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the + client library should throw before the request is sent. + + :param value: + :type value: int + :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/json") # type: Optional[str] + + _body_parameter = _models.IntWrapper(value=value) + json = self._serialize.body(_body_parameter, "IntWrapper") + + request = rest_explicit.build_post_required_integer_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_integer_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_integer_property.metadata = {"url": "/reqopt/requied/integer/property"} # type: ignore + + @distributed_trace + def post_optional_integer_property( + self, + value=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. + + :param value: + :type value: int + :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/json") # type: Optional[str] + + _body_parameter = _models.IntOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "IntOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_integer_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_integer_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_integer_property.metadata = {"url": "/reqopt/optional/integer/property"} # type: ignore + + @distributed_trace + def post_required_integer_header( + self, + header_parameter, # type: int + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required integer. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + :param header_parameter: + :type header_parameter: int + :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", {})) + + request = rest_explicit.build_post_required_integer_header_request( + header_parameter=header_parameter, + template_url=self.post_required_integer_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_integer_header.metadata = {"url": "/reqopt/requied/integer/header"} # type: ignore + + @distributed_trace + def post_optional_integer_header( + self, + header_parameter=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + :param header_parameter: + :type header_parameter: int + :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", {})) + + request = rest_explicit.build_post_optional_integer_header_request( + header_parameter=header_parameter, + template_url=self.post_optional_integer_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_integer_header.metadata = {"url": "/reqopt/optional/integer/header"} # type: ignore + + @distributed_trace + def post_required_string_parameter( + self, + body_parameter, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required string. Please put null and the client library should throw before the + request is sent. + + :param body_parameter: + :type body_parameter: 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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "str") + + request = rest_explicit.build_post_required_string_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_string_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_string_parameter.metadata = {"url": "/reqopt/requied/string/parameter"} # type: ignore + + @distributed_trace + def post_optional_string_parameter( + self, + body_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional string. Please put null. + + :param body_parameter: + :type body_parameter: 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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "str") + else: + json = None + + request = rest_explicit.build_post_optional_string_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_string_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_string_parameter.metadata = {"url": "/reqopt/optional/string/parameter"} # type: ignore + + @distributed_trace + def post_required_string_property( + self, + value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the + client library should throw before the request is sent. + + :param value: + :type value: 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/json") # type: Optional[str] + + _body_parameter = _models.StringWrapper(value=value) + json = self._serialize.body(_body_parameter, "StringWrapper") + + request = rest_explicit.build_post_required_string_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_string_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_string_property.metadata = {"url": "/reqopt/requied/string/property"} # type: ignore + + @distributed_trace + def post_optional_string_property( + self, + value=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. + + :param value: + :type value: 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/json") # type: Optional[str] + + _body_parameter = _models.StringOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "StringOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_string_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_string_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_string_property.metadata = {"url": "/reqopt/optional/string/property"} # type: ignore + + @distributed_trace + def post_required_string_header( + self, + header_parameter, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required string. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + :param header_parameter: + :type header_parameter: 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", {})) + + request = rest_explicit.build_post_required_string_header_request( + header_parameter=header_parameter, + template_url=self.post_required_string_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_string_header.metadata = {"url": "/reqopt/requied/string/header"} # type: ignore + + @distributed_trace + def post_optional_string_header( + self, + body_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional string. Please put a header 'headerParameter' => null. + + :param body_parameter: + :type body_parameter: 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", {})) + + request = rest_explicit.build_post_optional_string_header_request( + body_parameter=body_parameter, + template_url=self.post_optional_string_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_string_header.metadata = {"url": "/reqopt/optional/string/header"} # type: ignore + + @distributed_trace + def post_required_class_parameter( + self, + body_parameter, # type: "_models.Product" + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required complex object. Please put null and the client library should throw + before the request is sent. + + :param body_parameter: + :type body_parameter: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "Product") + + request = rest_explicit.build_post_required_class_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_class_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_class_parameter.metadata = {"url": "/reqopt/requied/class/parameter"} # type: ignore + + @distributed_trace + def post_optional_class_parameter( + self, + body_parameter=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional complex object. Please put null. + + :param body_parameter: + :type body_parameter: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "Product") + else: + json = None + + request = rest_explicit.build_post_optional_class_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_class_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_class_parameter.metadata = {"url": "/reqopt/optional/class/parameter"} # type: ignore + + @distributed_trace + def post_required_class_property( + self, + value, # type: "_models.Product" + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null + and the client library should throw before the request is sent. + + :param value: + :type value: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + _body_parameter = _models.ClassWrapper(value=value) + json = self._serialize.body(_body_parameter, "ClassWrapper") + + request = rest_explicit.build_post_required_class_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_class_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_class_property.metadata = {"url": "/reqopt/requied/class/property"} # type: ignore + + @distributed_trace + def post_optional_class_property( + self, + value=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. + + :param value: + :type value: ~requiredoptional.models.Product + :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/json") # type: Optional[str] + + _body_parameter = _models.ClassOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "ClassOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_class_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_class_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_class_property.metadata = {"url": "/reqopt/optional/class/property"} # type: ignore + + @distributed_trace + def post_required_array_parameter( + self, + body_parameter, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required array. Please put null and the client library should throw before the + request is sent. + + :param body_parameter: + :type body_parameter: list[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/json") # type: Optional[str] + + json = self._serialize.body(body_parameter, "[str]") + + request = rest_explicit.build_post_required_array_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_required_array_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_array_parameter.metadata = {"url": "/reqopt/requied/array/parameter"} # type: ignore + + @distributed_trace + def post_optional_array_parameter( + self, + body_parameter=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional array. Please put null. + + :param body_parameter: + :type body_parameter: list[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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "[str]") + else: + json = None + + request = rest_explicit.build_post_optional_array_parameter_request( + content_type=content_type, + json=json, + template_url=self.post_optional_array_parameter.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_array_parameter.metadata = {"url": "/reqopt/optional/array/parameter"} # type: ignore + + @distributed_trace + def post_required_array_property( + self, + value, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the + client library should throw before the request is sent. + + :param value: + :type value: list[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/json") # type: Optional[str] + + _body_parameter = _models.ArrayWrapper(value=value) + json = self._serialize.body(_body_parameter, "ArrayWrapper") + + request = rest_explicit.build_post_required_array_property_request( + content_type=content_type, + json=json, + template_url=self.post_required_array_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_array_property.metadata = {"url": "/reqopt/requied/array/property"} # type: ignore + + @distributed_trace + def post_optional_array_property( + self, + value=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. + + :param value: + :type value: list[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/json") # type: Optional[str] + + _body_parameter = _models.ArrayOptionalWrapper(value=value) + if _body_parameter is not None: + json = self._serialize.body(_body_parameter, "ArrayOptionalWrapper") + else: + json = None + + request = rest_explicit.build_post_optional_array_property_request( + content_type=content_type, + json=json, + template_url=self.post_optional_array_property.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_array_property.metadata = {"url": "/reqopt/optional/array/property"} # type: ignore + + @distributed_trace + def post_required_array_header( + self, + header_parameter, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly required array. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + :param header_parameter: + :type header_parameter: list[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", {})) + + request = rest_explicit.build_post_required_array_header_request( + header_parameter=header_parameter, + template_url=self.post_required_array_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_required_array_header.metadata = {"url": "/reqopt/requied/array/header"} # type: ignore + + @distributed_trace + def post_optional_array_header( + self, + header_parameter=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + :param header_parameter: + :type header_parameter: list[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", {})) + + request = rest_explicit.build_post_optional_array_header_request( + header_parameter=header_parameter, + template_url=self.post_optional_array_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + post_optional_array_header.metadata = {"url": "/reqopt/optional/array/header"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py new file mode 100644 index 00000000000..bc17bc8e863 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/operations/_implicit_operations.py @@ -0,0 +1,366 @@ +# 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 .. import models as _models +from .._rest import implicit as rest_implicit + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class ImplicitOperations(object): + """ImplicitOperations 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: ~requiredoptional.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 get_required_path( + self, + path_parameter, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly required path parameter. + + :param path_parameter: + :type path_parameter: 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", {})) + + request = rest_implicit.build_get_required_path_request( + path_parameter=path_parameter, + template_url=self.get_required_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_required_path.metadata = {"url": "/reqopt/implicit/required/path/{pathParameter}"} # type: ignore + + @distributed_trace + def put_optional_query( + self, + query_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly optional query parameter. + + :param query_parameter: + :type query_parameter: 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", {})) + + request = rest_implicit.build_put_optional_query_request( + query_parameter=query_parameter, + template_url=self.put_optional_query.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_query.metadata = {"url": "/reqopt/implicit/optional/query"} # type: ignore + + @distributed_trace + def put_optional_header( + self, + query_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly optional header parameter. + + :param query_parameter: + :type query_parameter: 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", {})) + + request = rest_implicit.build_put_optional_header_request( + query_parameter=query_parameter, + template_url=self.put_optional_header.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_header.metadata = {"url": "/reqopt/implicit/optional/header"} # type: ignore + + @distributed_trace + def put_optional_body( + self, + body_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly optional body parameter. + + :param body_parameter: + :type body_parameter: 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/json") # type: Optional[str] + + if body_parameter is not None: + json = self._serialize.body(body_parameter, "str") + else: + json = None + + request = rest_implicit.build_put_optional_body_request( + content_type=content_type, + json=json, + template_url=self.put_optional_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_body.metadata = {"url": "/reqopt/implicit/optional/body"} # type: ignore + + @distributed_trace + def put_optional_binary_body( + self, + body_parameter=None, # type: Optional[IO] + **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly optional body parameter. + + :param body_parameter: + :type body_parameter: IO + :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/octet-stream") # type: Optional[str] + + content = body_parameter + + request = rest_implicit.build_put_optional_binary_body_request( + content_type=content_type, + content=content, + template_url=self.put_optional_binary_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_optional_binary_body.metadata = {"url": "/reqopt/implicit/optional/binary-body"} # type: ignore + + @distributed_trace + def get_required_global_path( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly required path parameter. + + :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", {})) + + request = rest_implicit.build_get_required_global_path_request( + required_global_path=self._config.required_global_path, + template_url=self.get_required_global_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_required_global_path.metadata = {"url": "/reqopt/global/required/path/{required-global-path}"} # type: ignore + + @distributed_trace + def get_required_global_query( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly required query parameter. + + :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", {})) + + request = rest_implicit.build_get_required_global_query_request( + required_global_query=self._config.required_global_query, + template_url=self.get_required_global_query.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_required_global_query.metadata = {"url": "/reqopt/global/required/query"} # type: ignore + + @distributed_trace + def get_optional_global_query( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Test implicitly optional query parameter. + + :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", {})) + + request = rest_implicit.build_get_optional_global_query_request( + optional_global_query=self._config.optional_global_query, + template_url=self.get_optional_global_query.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_optional_global_query.metadata = {"url": "/reqopt/global/optional/query"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/requiredoptional/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/setup.py new file mode 100644 index 00000000000..50394544490 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/RequiredOptional/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 = "autorestrequiredoptionaltestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestRequiredOptionalTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestRequiredOptionalTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/setup.py new file mode 100644 index 00000000000..e4d0aa34330 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/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 = "autoresturltestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestUrlTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestUrlTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_auto_rest_url_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_auto_rest_url_test_service.py new file mode 100644 index 00000000000..babe343288a --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_auto_rest_url_test_service.py @@ -0,0 +1,107 @@ +# 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 AutoRestUrlTestServiceConfiguration +from .operations import PathItemsOperations, PathsOperations, QueriesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestUrlTestService(object): + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: url.operations.PathsOperations + :ivar queries: QueriesOperations operations + :vartype queries: url.operations.QueriesOperations + :ivar path_items: PathItemsOperations operations + :vartype path_items: url.operations.PathItemsOperations + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param global_string_query: should contain value null. + :type global_string_query: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + global_string_path, # type: str + global_string_query=None, # type: Optional[str] + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.path_items = PathItemsOperations(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. + + We have helper methods to create requests specific to this service in `url.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from url._rest import paths + >>> request = paths.build_get_boolean_true_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestUrlTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_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/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/__init__.py new file mode 100644 index 00000000000..cd604938f2c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/__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 ._request_builders_py3 import build_get_all_with_values_request + from ._request_builders_py3 import build_get_global_query_null_request + from ._request_builders_py3 import build_get_global_and_local_query_null_request + from ._request_builders_py3 import build_get_local_path_item_query_null_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_all_with_values_request # type: ignore + from ._request_builders import build_get_global_query_null_request # type: ignore + from ._request_builders import build_get_global_and_local_query_null_request # type: ignore + from ._request_builders import build_get_local_path_item_query_null_request # type: ignore + +__all__ = [ + "build_get_all_with_values_request", + "build_get_global_query_null_request", + "build_get_global_and_local_query_null_request", + "build_get_local_path_item_query_null_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/_request_builders.py new file mode 100644 index 00000000000..49fd305be47 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/_request_builders.py @@ -0,0 +1,295 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_all_with_values_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_global_query_null_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_global_and_local_query_null_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain null value. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_path_item_query_null_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery=null, localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: should contain value null. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value null. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/_request_builders_py3.py new file mode 100644 index 00000000000..99c7aa52b74 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/path_items/_request_builders_py3.py @@ -0,0 +1,282 @@ +# 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 datetime +from typing import Any, List, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_all_with_values_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_global_query_null_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_global_and_local_query_null_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain null value. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_local_path_item_query_null_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery=null, localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: should contain value null. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value null. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/__init__.py new file mode 100644 index 00000000000..5f24a088959 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/__init__.py @@ -0,0 +1,94 @@ +# 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_get_boolean_true_request + from ._request_builders_py3 import build_get_boolean_false_request + from ._request_builders_py3 import build_get_int_one_million_request + from ._request_builders_py3 import build_get_int_negative_one_million_request + from ._request_builders_py3 import build_get_ten_billion_request + from ._request_builders_py3 import build_get_negative_ten_billion_request + from ._request_builders_py3 import build_float_scientific_positive_request + from ._request_builders_py3 import build_float_scientific_negative_request + from ._request_builders_py3 import build_double_decimal_positive_request + from ._request_builders_py3 import build_double_decimal_negative_request + from ._request_builders_py3 import build_string_unicode_request + from ._request_builders_py3 import build_string_url_encoded_request + from ._request_builders_py3 import build_string_url_non_encoded_request + from ._request_builders_py3 import build_string_empty_request + from ._request_builders_py3 import build_string_null_request + from ._request_builders_py3 import build_enum_valid_request + from ._request_builders_py3 import build_enum_null_request + from ._request_builders_py3 import build_byte_multi_byte_request + from ._request_builders_py3 import build_byte_empty_request + from ._request_builders_py3 import build_byte_null_request + from ._request_builders_py3 import build_date_valid_request + from ._request_builders_py3 import build_date_null_request + from ._request_builders_py3 import build_date_time_valid_request + from ._request_builders_py3 import build_date_time_null_request + from ._request_builders_py3 import build_base64_url_request + from ._request_builders_py3 import build_array_csv_in_path_request + from ._request_builders_py3 import build_unix_time_url_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_boolean_true_request # type: ignore + from ._request_builders import build_get_boolean_false_request # type: ignore + from ._request_builders import build_get_int_one_million_request # type: ignore + from ._request_builders import build_get_int_negative_one_million_request # type: ignore + from ._request_builders import build_get_ten_billion_request # type: ignore + from ._request_builders import build_get_negative_ten_billion_request # type: ignore + from ._request_builders import build_float_scientific_positive_request # type: ignore + from ._request_builders import build_float_scientific_negative_request # type: ignore + from ._request_builders import build_double_decimal_positive_request # type: ignore + from ._request_builders import build_double_decimal_negative_request # type: ignore + from ._request_builders import build_string_unicode_request # type: ignore + from ._request_builders import build_string_url_encoded_request # type: ignore + from ._request_builders import build_string_url_non_encoded_request # type: ignore + from ._request_builders import build_string_empty_request # type: ignore + from ._request_builders import build_string_null_request # type: ignore + from ._request_builders import build_enum_valid_request # type: ignore + from ._request_builders import build_enum_null_request # type: ignore + from ._request_builders import build_byte_multi_byte_request # type: ignore + from ._request_builders import build_byte_empty_request # type: ignore + from ._request_builders import build_byte_null_request # type: ignore + from ._request_builders import build_date_valid_request # type: ignore + from ._request_builders import build_date_null_request # type: ignore + from ._request_builders import build_date_time_valid_request # type: ignore + from ._request_builders import build_date_time_null_request # type: ignore + from ._request_builders import build_base64_url_request # type: ignore + from ._request_builders import build_array_csv_in_path_request # type: ignore + from ._request_builders import build_unix_time_url_request # type: ignore + +__all__ = [ + "build_get_boolean_true_request", + "build_get_boolean_false_request", + "build_get_int_one_million_request", + "build_get_int_negative_one_million_request", + "build_get_ten_billion_request", + "build_get_negative_ten_billion_request", + "build_float_scientific_positive_request", + "build_float_scientific_negative_request", + "build_double_decimal_positive_request", + "build_double_decimal_negative_request", + "build_string_unicode_request", + "build_string_url_encoded_request", + "build_string_url_non_encoded_request", + "build_string_empty_request", + "build_string_null_request", + "build_enum_valid_request", + "build_enum_null_request", + "build_byte_multi_byte_request", + "build_byte_empty_request", + "build_byte_null_request", + "build_date_valid_request", + "build_date_null_request", + "build_date_time_valid_request", + "build_date_time_null_request", + "build_base64_url_request", + "build_array_csv_in_path_request", + "build_unix_time_url_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/_request_builders.py new file mode 100644 index 00000000000..d15d5cd3db0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/_request_builders.py @@ -0,0 +1,1017 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_boolean_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/bool/true/{boolPath}') + path_format_arguments = { + 'boolPath': _SERIALIZER.url("bool_path", bool_path, 'bool'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/bool/false/{boolPath}') + path_format_arguments = { + 'boolPath': _SERIALIZER.url("bool_path", bool_path, 'bool'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/int/1000000/{intPath}') + path_format_arguments = { + 'intPath': _SERIALIZER.url("int_path", int_path, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_negative_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/int/-1000000/{intPath}') + path_format_arguments = { + 'intPath': _SERIALIZER.url("int_path", int_path, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/long/10000000000/{longPath}') + path_format_arguments = { + 'longPath': _SERIALIZER.url("long_path", long_path, 'long'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_negative_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/long/-10000000000/{longPath}') + path_format_arguments = { + 'longPath': _SERIALIZER.url("long_path", long_path, 'long'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/float/1.034E+20/{floatPath}') + path_format_arguments = { + 'floatPath': _SERIALIZER.url("float_path", float_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/float/-1.034E-20/{floatPath}') + path_format_arguments = { + 'floatPath': _SERIALIZER.url("float_path", float_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/double/9999999.999/{doublePath}') + path_format_arguments = { + 'doublePath': _SERIALIZER.url("double_path", double_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/double/-9999999.999/{doublePath}') + path_format_arguments = { + 'doublePath': _SERIALIZER.url("double_path", double_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_unicode_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/unicode/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_url_non_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'begin!*'();:@&=+$,end. + + https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@&=+$,end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/begin!*\'();:@&=+$,end/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/empty/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_null_request( + string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param string_path: null string value. + :type string_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/null/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_enum_valid_request( + enum_path, # type: Union[str, "_models.UriColor"] + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get using uri with 'green color' in path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send the value green. + :type enum_path: str or ~url.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/enum/green%20color/{enumPath}') + path_format_arguments = { + 'enumPath': _SERIALIZER.url("enum_path", enum_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_enum_null_request( + enum_path, # type: Union[str, "_models.UriColor"] + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (should throw on the client before the request is sent on wire). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send null should throw. + :type enum_path: str or ~url.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/null/{enumPath}') + path_format_arguments = { + 'enumPath': _SERIALIZER.url("enum_path", enum_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_byte_multi_byte_request( + byte_path, # type: bytearray + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/byte/multibyte/{bytePath}') + path_format_arguments = { + 'bytePath': _SERIALIZER.url("byte_path", byte_path, 'bytearray'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_byte_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_path = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/byte/empty/{bytePath}') + path_format_arguments = { + 'bytePath': _SERIALIZER.url("byte_path", byte_path, 'bytearray'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_byte_null_request( + byte_path, # type: bytearray + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as byte array (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: null as byte array (should throw). + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/byte/null/{bytePath}') + path_format_arguments = { + 'bytePath': _SERIALIZER.url("byte_path", byte_path, 'bytearray'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_path = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/date/2012-01-01/{datePath}') + path_format_arguments = { + 'datePath': _SERIALIZER.url("date_path", date_path, 'date'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_null_request( + date_path, # type: datetime.date + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date - this should throw or be unusable on the client side, depending on date + representation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_path: null as date (should throw). + :type date_path: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/date/null/{datePath}') + path_format_arguments = { + 'datePath': _SERIALIZER.url("date_path", date_path, 'date'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_path = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}') + path_format_arguments = { + 'dateTimePath': _SERIALIZER.url("date_time_path", date_time_path, 'iso-8601'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_null_request( + date_time_path, # type: datetime.datetime + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date-time, should be disallowed or throw depending on representation of date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_time_path: null as date-time. + :type date_time_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/datetime/null/{dateTimePath}') + path_format_arguments = { + 'dateTimePath': _SERIALIZER.url("date_time_path", date_time_path, 'iso-8601'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_base64_url_request( + base64_url_path, # type: bytes + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'lorem' encoded value as 'bG9yZW0' (base64url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param base64_url_path: base64url encoded value. + :type base64_url_path: bytes + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/bG9yZW0/{base64UrlPath}') + path_format_arguments = { + 'base64UrlPath': _SERIALIZER.url("base64_url_path", base64_url_path, 'base64'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_array_csv_in_path_request( + array_path, # type: List[str] + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] + using the csv-array format. + :type array_path: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}') + path_format_arguments = { + 'arrayPath': _SERIALIZER.url("array_path", array_path, '[str]', div=','), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_unix_time_url_request( + unix_time_url_path, # type: datetime.datetime + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unix_time_url_path: Unix time encoded value. + :type unix_time_url_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/int/1460505600/{unixTimeUrlPath}') + path_format_arguments = { + 'unixTimeUrlPath': _SERIALIZER.url("unix_time_url_path", unix_time_url_path, 'unix-time'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..28c8d4304e8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/paths/_request_builders_py3.py @@ -0,0 +1,791 @@ +# 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 datetime +from typing import Any, List, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_boolean_true_request(**kwargs: Any) -> HttpRequest: + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/bool/true/{boolPath}") + path_format_arguments = { + "boolPath": _SERIALIZER.url("bool_path", bool_path, "bool"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_false_request(**kwargs: Any) -> HttpRequest: + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/bool/false/{boolPath}") + path_format_arguments = { + "boolPath": _SERIALIZER.url("bool_path", bool_path, "bool"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/int/1000000/{intPath}") + path_format_arguments = { + "intPath": _SERIALIZER.url("int_path", int_path, "int"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_negative_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/int/-1000000/{intPath}") + path_format_arguments = { + "intPath": _SERIALIZER.url("int_path", int_path, "int"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/long/10000000000/{longPath}") + path_format_arguments = { + "longPath": _SERIALIZER.url("long_path", long_path, "long"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_negative_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/long/-10000000000/{longPath}") + path_format_arguments = { + "longPath": _SERIALIZER.url("long_path", long_path, "long"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_float_scientific_positive_request(**kwargs: Any) -> HttpRequest: + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/float/1.034E+20/{floatPath}") + path_format_arguments = { + "floatPath": _SERIALIZER.url("float_path", float_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_float_scientific_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/float/-1.034E-20/{floatPath}") + path_format_arguments = { + "floatPath": _SERIALIZER.url("float_path", float_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_double_decimal_positive_request(**kwargs: Any) -> HttpRequest: + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/double/9999999.999/{doublePath}") + path_format_arguments = { + "doublePath": _SERIALIZER.url("double_path", double_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_double_decimal_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/double/-9999999.999/{doublePath}") + path_format_arguments = { + "doublePath": _SERIALIZER.url("double_path", double_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_unicode_request(**kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/unicode/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}" + ) + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_url_non_encoded_request(**kwargs: Any) -> HttpRequest: + """Get 'begin!*'();:@&=+$,end. + + https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@&=+$,end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/begin!*'();:@&=+$,end/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_empty_request(**kwargs: Any) -> HttpRequest: + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/empty/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_null_request(string_path: str, **kwargs: Any) -> HttpRequest: + """Get null (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param string_path: null string value. + :type string_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/null/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_enum_valid_request(enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> HttpRequest: + """Get using uri with 'green color' in path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send the value green. + :type enum_path: str or ~url.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/enum/green%20color/{enumPath}") + path_format_arguments = { + "enumPath": _SERIALIZER.url("enum_path", enum_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_enum_null_request(enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> HttpRequest: + """Get null (should throw on the client before the request is sent on wire). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send null should throw. + :type enum_path: str or ~url.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/null/{enumPath}") + path_format_arguments = { + "enumPath": _SERIALIZER.url("enum_path", enum_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_byte_multi_byte_request(byte_path: bytearray, **kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/byte/multibyte/{bytePath}") + path_format_arguments = { + "bytePath": _SERIALIZER.url("byte_path", byte_path, "bytearray"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_byte_empty_request(**kwargs: Any) -> HttpRequest: + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_path = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/byte/empty/{bytePath}") + path_format_arguments = { + "bytePath": _SERIALIZER.url("byte_path", byte_path, "bytearray"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_byte_null_request(byte_path: bytearray, **kwargs: Any) -> HttpRequest: + """Get null as byte array (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: null as byte array (should throw). + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/byte/null/{bytePath}") + path_format_arguments = { + "bytePath": _SERIALIZER.url("byte_path", byte_path, "bytearray"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_path = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/date/2012-01-01/{datePath}") + path_format_arguments = { + "datePath": _SERIALIZER.url("date_path", date_path, "date"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_null_request(date_path: datetime.date, **kwargs: Any) -> HttpRequest: + """Get null as date - this should throw or be unusable on the client side, depending on date + representation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_path: null as date (should throw). + :type date_path: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/date/null/{datePath}") + path_format_arguments = { + "datePath": _SERIALIZER.url("date_path", date_path, "date"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_path = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}") + path_format_arguments = { + "dateTimePath": _SERIALIZER.url("date_time_path", date_time_path, "iso-8601"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_time_null_request(date_time_path: datetime.datetime, **kwargs: Any) -> HttpRequest: + """Get null as date-time, should be disallowed or throw depending on representation of date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_time_path: null as date-time. + :type date_time_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/datetime/null/{dateTimePath}") + path_format_arguments = { + "dateTimePath": _SERIALIZER.url("date_time_path", date_time_path, "iso-8601"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_base64_url_request(base64_url_path: bytes, **kwargs: Any) -> HttpRequest: + """Get 'lorem' encoded value as 'bG9yZW0' (base64url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param base64_url_path: base64url encoded value. + :type base64_url_path: bytes + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/bG9yZW0/{base64UrlPath}") + path_format_arguments = { + "base64UrlPath": _SERIALIZER.url("base64_url_path", base64_url_path, "base64"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_array_csv_in_path_request(array_path: List[str], **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] + using the csv-array format. + :type array_path: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}", + ) + path_format_arguments = { + "arrayPath": _SERIALIZER.url("array_path", array_path, "[str]", div=","), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_unix_time_url_request(unix_time_url_path: datetime.datetime, **kwargs: Any) -> HttpRequest: + """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unix_time_url_path: Unix time encoded value. + :type unix_time_url_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/int/1460505600/{unixTimeUrlPath}") + path_format_arguments = { + "unixTimeUrlPath": _SERIALIZER.url("unix_time_url_path", unix_time_url_path, "unix-time"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/__init__.py new file mode 100644 index 00000000000..3017ee4219d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/__init__.py @@ -0,0 +1,118 @@ +# 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_get_boolean_true_request + from ._request_builders_py3 import build_get_boolean_false_request + from ._request_builders_py3 import build_get_boolean_null_request + from ._request_builders_py3 import build_get_int_one_million_request + from ._request_builders_py3 import build_get_int_negative_one_million_request + from ._request_builders_py3 import build_get_int_null_request + from ._request_builders_py3 import build_get_ten_billion_request + from ._request_builders_py3 import build_get_negative_ten_billion_request + from ._request_builders_py3 import build_get_long_null_request + from ._request_builders_py3 import build_float_scientific_positive_request + from ._request_builders_py3 import build_float_scientific_negative_request + from ._request_builders_py3 import build_float_null_request + from ._request_builders_py3 import build_double_decimal_positive_request + from ._request_builders_py3 import build_double_decimal_negative_request + from ._request_builders_py3 import build_double_null_request + from ._request_builders_py3 import build_string_unicode_request + from ._request_builders_py3 import build_string_url_encoded_request + from ._request_builders_py3 import build_string_empty_request + from ._request_builders_py3 import build_string_null_request + from ._request_builders_py3 import build_enum_valid_request + from ._request_builders_py3 import build_enum_null_request + from ._request_builders_py3 import build_byte_multi_byte_request + from ._request_builders_py3 import build_byte_empty_request + from ._request_builders_py3 import build_byte_null_request + from ._request_builders_py3 import build_date_valid_request + from ._request_builders_py3 import build_date_null_request + from ._request_builders_py3 import build_date_time_valid_request + from ._request_builders_py3 import build_date_time_null_request + from ._request_builders_py3 import build_array_string_csv_valid_request + from ._request_builders_py3 import build_array_string_csv_null_request + from ._request_builders_py3 import build_array_string_csv_empty_request + from ._request_builders_py3 import build_array_string_no_collection_format_empty_request + from ._request_builders_py3 import build_array_string_ssv_valid_request + from ._request_builders_py3 import build_array_string_tsv_valid_request + from ._request_builders_py3 import build_array_string_pipes_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_boolean_true_request # type: ignore + from ._request_builders import build_get_boolean_false_request # type: ignore + from ._request_builders import build_get_boolean_null_request # type: ignore + from ._request_builders import build_get_int_one_million_request # type: ignore + from ._request_builders import build_get_int_negative_one_million_request # type: ignore + from ._request_builders import build_get_int_null_request # type: ignore + from ._request_builders import build_get_ten_billion_request # type: ignore + from ._request_builders import build_get_negative_ten_billion_request # type: ignore + from ._request_builders import build_get_long_null_request # type: ignore + from ._request_builders import build_float_scientific_positive_request # type: ignore + from ._request_builders import build_float_scientific_negative_request # type: ignore + from ._request_builders import build_float_null_request # type: ignore + from ._request_builders import build_double_decimal_positive_request # type: ignore + from ._request_builders import build_double_decimal_negative_request # type: ignore + from ._request_builders import build_double_null_request # type: ignore + from ._request_builders import build_string_unicode_request # type: ignore + from ._request_builders import build_string_url_encoded_request # type: ignore + from ._request_builders import build_string_empty_request # type: ignore + from ._request_builders import build_string_null_request # type: ignore + from ._request_builders import build_enum_valid_request # type: ignore + from ._request_builders import build_enum_null_request # type: ignore + from ._request_builders import build_byte_multi_byte_request # type: ignore + from ._request_builders import build_byte_empty_request # type: ignore + from ._request_builders import build_byte_null_request # type: ignore + from ._request_builders import build_date_valid_request # type: ignore + from ._request_builders import build_date_null_request # type: ignore + from ._request_builders import build_date_time_valid_request # type: ignore + from ._request_builders import build_date_time_null_request # type: ignore + from ._request_builders import build_array_string_csv_valid_request # type: ignore + from ._request_builders import build_array_string_csv_null_request # type: ignore + from ._request_builders import build_array_string_csv_empty_request # type: ignore + from ._request_builders import build_array_string_no_collection_format_empty_request # type: ignore + from ._request_builders import build_array_string_ssv_valid_request # type: ignore + from ._request_builders import build_array_string_tsv_valid_request # type: ignore + from ._request_builders import build_array_string_pipes_valid_request # type: ignore + +__all__ = [ + "build_get_boolean_true_request", + "build_get_boolean_false_request", + "build_get_boolean_null_request", + "build_get_int_one_million_request", + "build_get_int_negative_one_million_request", + "build_get_int_null_request", + "build_get_ten_billion_request", + "build_get_negative_ten_billion_request", + "build_get_long_null_request", + "build_float_scientific_positive_request", + "build_float_scientific_negative_request", + "build_float_null_request", + "build_double_decimal_positive_request", + "build_double_decimal_negative_request", + "build_double_null_request", + "build_string_unicode_request", + "build_string_url_encoded_request", + "build_string_empty_request", + "build_string_null_request", + "build_enum_valid_request", + "build_enum_null_request", + "build_byte_multi_byte_request", + "build_byte_empty_request", + "build_byte_null_request", + "build_date_valid_request", + "build_date_null_request", + "build_date_time_valid_request", + "build_date_time_null_request", + "build_array_string_csv_valid_request", + "build_array_string_csv_null_request", + "build_array_string_csv_empty_request", + "build_array_string_no_collection_format_empty_request", + "build_array_string_ssv_valid_request", + "build_array_string_tsv_valid_request", + "build_array_string_pipes_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/_request_builders.py new file mode 100644 index 00000000000..2d5c65e2012 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/_request_builders.py @@ -0,0 +1,1400 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_boolean_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/bool/true') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['boolQuery'] = _SERIALIZER.query("bool_query", bool_query, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/bool/false') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['boolQuery'] = _SERIALIZER.query("bool_query", bool_query, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Boolean value on query (query string should be absent). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword bool_query: null boolean value. + :paramtype bool_query: bool + :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 + """ + + bool_query = kwargs.pop('bool_query', None) # type: Optional[bool] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/bool/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if bool_query is not None: + query_parameters['boolQuery'] = _SERIALIZER.query("bool_query", bool_query, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/int/1000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['intQuery'] = _SERIALIZER.query("int_query", int_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_negative_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/int/-1000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['intQuery'] = _SERIALIZER.query("int_query", int_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null integer value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword int_query: null integer value. + :paramtype int_query: int + :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 + """ + + int_query = kwargs.pop('int_query', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/int/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if int_query is not None: + query_parameters['intQuery'] = _SERIALIZER.query("int_query", int_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/long/10000000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['longQuery'] = _SERIALIZER.query("long_query", long_query, 'long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_negative_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/long/-10000000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['longQuery'] = _SERIALIZER.query("long_query", long_query, 'long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'null 64 bit integer value (no query param in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword long_query: null 64 bit integer value. + :paramtype long_query: long + :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 + """ + + long_query = kwargs.pop('long_query', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/long/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if long_query is not None: + query_parameters['longQuery'] = _SERIALIZER.query("long_query", long_query, 'long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/float/1.034E+20') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['floatQuery'] = _SERIALIZER.query("float_query", float_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/float/-1.034E-20') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['floatQuery'] = _SERIALIZER.query("float_query", float_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_float_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword float_query: null numeric value. + :paramtype float_query: float + :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 + """ + + float_query = kwargs.pop('float_query', None) # type: Optional[float] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/float/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if float_query is not None: + query_parameters['floatQuery'] = _SERIALIZER.query("float_query", float_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/double/9999999.999') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['doubleQuery'] = _SERIALIZER.query("double_query", double_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/double/-9999999.999') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['doubleQuery'] = _SERIALIZER.query("double_query", double_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_double_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword double_query: null numeric value. + :paramtype double_query: float + :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 + """ + + double_query = kwargs.pop('double_query', None) # type: Optional[float] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/double/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if double_query is not None: + query_parameters['doubleQuery'] = _SERIALIZER.query("double_query", double_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_unicode_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/unicode/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword string_query: null string value. + :paramtype string_query: str + :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 + """ + + string_query = kwargs.pop('string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if string_query is not None: + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get using uri with query parameter 'green color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: 'green color' enum value. + :paramtype enum_query: str or ~url.models.UriColor + :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 + """ + + enum_query = kwargs.pop('enum_query', None) # type: Optional[Union[str, "_models.UriColor"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/enum/green%20color') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters['enumQuery'] = _SERIALIZER.query("enum_query", enum_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_enum_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: null string value. + :paramtype enum_query: str or ~url.models.UriColor + :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 + """ + + enum_query = kwargs.pop('enum_query', None) # type: Optional[Union[str, "_models.UriColor"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/enum/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters['enumQuery'] = _SERIALIZER.query("enum_query", enum_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_byte_multi_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :paramtype byte_query: bytearray + :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 + """ + + byte_query = kwargs.pop('byte_query', None) # type: Optional[bytearray] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/byte/multibyte') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters['byteQuery'] = _SERIALIZER.query("byte_query", byte_query, 'bytearray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_byte_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_query = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/byte/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['byteQuery'] = _SERIALIZER.query("byte_query", byte_query, 'bytearray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_byte_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as byte array (no query parameters in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: null as byte array (no query parameters in uri). + :paramtype byte_query: bytearray + :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 + """ + + byte_query = kwargs.pop('byte_query', None) # type: Optional[bytearray] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/byte/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters['byteQuery'] = _SERIALIZER.query("byte_query", byte_query, 'bytearray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_query = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/date/2012-01-01') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['dateQuery'] = _SERIALIZER.query("date_query", date_query, 'date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date - this should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_query: null as date (no query parameters in uri). + :paramtype date_query: ~datetime.date + :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 + """ + + date_query = kwargs.pop('date_query', None) # type: Optional[datetime.date] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/date/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_query is not None: + query_parameters['dateQuery'] = _SERIALIZER.query("date_query", date_query, 'date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_query = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/datetime/2012-01-01T01%3A01%3A01Z') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['dateTimeQuery'] = _SERIALIZER.query("date_time_query", date_time_query, 'iso-8601') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date-time, should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_time_query: null as date-time (no query parameters). + :paramtype date_time_query: ~datetime.datetime + :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 + """ + + date_time_query = kwargs.pop('date_time_query', None) # type: Optional[datetime.datetime] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/datetime/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_time_query is not None: + query_parameters['dateTimeQuery'] = _SERIALIZER.query("date_time_query", date_time_query, 'iso-8601') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_csv_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/csv/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_csv_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/csv/string/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_csv_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array [] of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/csv/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_no_collection_format_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', + 'bonjour'] for the 'arrayQuery' parameter to the service. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/none/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_ssv_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + ssv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the ssv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/ssv/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=' ') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_tsv_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + tsv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the tsv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/tsv/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=' ') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_pipes_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + pipes-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the pipes-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/pipes/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div='|') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/_request_builders_py3.py new file mode 100644 index 00000000000..9d94d65aa54 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_rest/queries/_request_builders_py3.py @@ -0,0 +1,1050 @@ +# 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 datetime +from typing import Any, List, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_boolean_true_request(**kwargs: Any) -> HttpRequest: + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/bool/true") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["boolQuery"] = _SERIALIZER.query("bool_query", bool_query, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_boolean_false_request(**kwargs: Any) -> HttpRequest: + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/bool/false") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["boolQuery"] = _SERIALIZER.query("bool_query", bool_query, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_boolean_null_request(*, bool_query: Optional[bool] = None, **kwargs: Any) -> HttpRequest: + """Get null Boolean value on query (query string should be absent). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword bool_query: null boolean value. + :paramtype bool_query: bool + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/bool/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if bool_query is not None: + query_parameters["boolQuery"] = _SERIALIZER.query("bool_query", bool_query, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_int_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/int/1000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["intQuery"] = _SERIALIZER.query("int_query", int_query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_int_negative_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/int/-1000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["intQuery"] = _SERIALIZER.query("int_query", int_query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_int_null_request(*, int_query: Optional[int] = None, **kwargs: Any) -> HttpRequest: + """Get null integer value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword int_query: null integer value. + :paramtype int_query: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/int/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if int_query is not None: + query_parameters["intQuery"] = _SERIALIZER.query("int_query", int_query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/long/10000000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["longQuery"] = _SERIALIZER.query("long_query", long_query, "long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_negative_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/long/-10000000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["longQuery"] = _SERIALIZER.query("long_query", long_query, "long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_long_null_request(*, long_query: Optional[int] = None, **kwargs: Any) -> HttpRequest: + """Get 'null 64 bit integer value (no query param in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword long_query: null 64 bit integer value. + :paramtype long_query: long + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/long/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if long_query is not None: + query_parameters["longQuery"] = _SERIALIZER.query("long_query", long_query, "long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_float_scientific_positive_request(**kwargs: Any) -> HttpRequest: + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/float/1.034E+20") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["floatQuery"] = _SERIALIZER.query("float_query", float_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_float_scientific_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/float/-1.034E-20") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["floatQuery"] = _SERIALIZER.query("float_query", float_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_float_null_request(*, float_query: Optional[float] = None, **kwargs: Any) -> HttpRequest: + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword float_query: null numeric value. + :paramtype float_query: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/float/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if float_query is not None: + query_parameters["floatQuery"] = _SERIALIZER.query("float_query", float_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_double_decimal_positive_request(**kwargs: Any) -> HttpRequest: + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/double/9999999.999") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["doubleQuery"] = _SERIALIZER.query("double_query", double_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_double_decimal_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/double/-9999999.999") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["doubleQuery"] = _SERIALIZER.query("double_query", double_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_double_null_request(*, double_query: Optional[float] = None, **kwargs: Any) -> HttpRequest: + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword double_query: null numeric value. + :paramtype double_query: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/double/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if double_query is not None: + query_parameters["doubleQuery"] = _SERIALIZER.query("double_query", double_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_unicode_request(**kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/string/unicode/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend" + ) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_empty_request(**kwargs: Any) -> HttpRequest: + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_null_request(*, string_query: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword string_query: null string value. + :paramtype string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/string/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if string_query is not None: + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_enum_valid_request( + *, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any +) -> HttpRequest: + """Get using uri with query parameter 'green color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: 'green color' enum value. + :paramtype enum_query: str or ~url.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/enum/green%20color") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters["enumQuery"] = _SERIALIZER.query("enum_query", enum_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_enum_null_request( + *, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any +) -> HttpRequest: + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: null string value. + :paramtype enum_query: str or ~url.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/enum/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters["enumQuery"] = _SERIALIZER.query("enum_query", enum_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_byte_multi_byte_request(*, byte_query: Optional[bytearray] = None, **kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :paramtype byte_query: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/byte/multibyte") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters["byteQuery"] = _SERIALIZER.query("byte_query", byte_query, "bytearray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_byte_empty_request(**kwargs: Any) -> HttpRequest: + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_query = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/byte/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["byteQuery"] = _SERIALIZER.query("byte_query", byte_query, "bytearray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_byte_null_request(*, byte_query: Optional[bytearray] = None, **kwargs: Any) -> HttpRequest: + """Get null as byte array (no query parameters in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: null as byte array (no query parameters in uri). + :paramtype byte_query: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/byte/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters["byteQuery"] = _SERIALIZER.query("byte_query", byte_query, "bytearray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_query = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/date/2012-01-01") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["dateQuery"] = _SERIALIZER.query("date_query", date_query, "date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_null_request(*, date_query: Optional[datetime.date] = None, **kwargs: Any) -> HttpRequest: + """Get null as date - this should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_query: null as date (no query parameters in uri). + :paramtype date_query: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/date/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_query is not None: + query_parameters["dateQuery"] = _SERIALIZER.query("date_query", date_query, "date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_query = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/datetime/2012-01-01T01%3A01%3A01Z") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["dateTimeQuery"] = _SERIALIZER.query("date_time_query", date_time_query, "iso-8601") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_time_null_request(*, date_time_query: Optional[datetime.datetime] = None, **kwargs: Any) -> HttpRequest: + """Get null as date-time, should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_time_query: null as date-time (no query parameters). + :paramtype date_time_query: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/datetime/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_time_query is not None: + query_parameters["dateTimeQuery"] = _SERIALIZER.query("date_time_query", date_time_query, "iso-8601") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_csv_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/csv/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_csv_null_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get a null array of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/csv/string/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_csv_empty_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an empty array [] of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/csv/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_no_collection_format_empty_request( + *, array_query: Optional[List[str]] = None, **kwargs: Any +) -> HttpRequest: + """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', + 'bonjour'] for the 'arrayQuery' parameter to the service. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/none/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_ssv_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + ssv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the ssv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/ssv/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=" ") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_tsv_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + tsv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the tsv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/tsv/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=" ") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_pipes_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + pipes-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the pipes-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/pipes/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div="|") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/_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/Expected/AcceptanceTests/Url/url/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/_auto_rest_url_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/_auto_rest_url_test_service.py new file mode 100644 index 00000000000..70dde1d7e85 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/_auto_rest_url_test_service.py @@ -0,0 +1,93 @@ +# 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 AutoRestUrlTestServiceConfiguration +from .operations import PathItemsOperations, PathsOperations, QueriesOperations + + +class AutoRestUrlTestService: + """Test Infrastructure for AutoRest. + + :ivar paths: PathsOperations operations + :vartype paths: url.aio.operations.PathsOperations + :ivar queries: QueriesOperations operations + :vartype queries: url.aio.operations.QueriesOperations + :ivar path_items: PathItemsOperations operations + :vartype path_items: url.aio.operations.PathItemsOperations + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param global_string_query: should contain value null. + :type global_string_query: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + global_string_path: str, + global_string_query: Optional[str] = None, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, **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.paths = PathsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.path_items = PathItemsOperations(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. + + We have helper methods to create requests specific to this service in `url.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from url._rest import paths + >>> request = paths.build_get_boolean_true_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestUrlTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py new file mode 100644 index 00000000000..88e3f57c786 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_path_items_operations.py @@ -0,0 +1,278 @@ +# 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 ... import models as _models +from ..._rest import path_items as rest_path_items + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PathItemsOperations: + """PathItemsOperations 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: ~url.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 get_all_with_values( + self, + path_item_string_path: str, + local_string_path: str, + path_item_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any + ) -> None: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :type path_item_string_query: str + :param local_string_query: should contain value 'localStringQuery'. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_all_with_values_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_all_with_values.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_all_with_values.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery"} # type: ignore + + @distributed_trace_async + async def get_global_query_null( + self, + path_item_string_path: str, + local_string_path: str, + path_item_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any + ) -> None: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :type path_item_string_query: str + :param local_string_query: should contain value 'localStringQuery'. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_global_query_null_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_global_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_global_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery"} # type: ignore + + @distributed_trace_async + async def get_global_and_local_query_null( + self, + path_item_string_path: str, + local_string_path: str, + path_item_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any + ) -> None: + """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery=null. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :type path_item_string_query: str + :param local_string_query: should contain null value. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_global_and_local_query_null_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_global_and_local_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_global_and_local_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null"} # type: ignore + + @distributed_trace_async + async def get_local_path_item_query_null( + self, + path_item_string_path: str, + local_string_path: str, + path_item_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any + ) -> None: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery=null, localStringQuery=null. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: should contain value null. + :type path_item_string_query: str + :param local_string_query: should contain value null. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_local_path_item_query_null_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_local_path_item_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_local_path_item_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py new file mode 100644 index 00000000000..92e8e272d9e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_paths_operations.py @@ -0,0 +1,978 @@ +# 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 datetime +import functools +from typing import Any, Callable, Dict, Generic, List, 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 ..._rest import paths as rest_paths + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PathsOperations: + """PathsOperations 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: ~url.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 get_boolean_true(self, **kwargs: Any) -> None: + """Get true Boolean value on path. + + :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", {})) + + request = rest_paths.build_get_boolean_true_request( + template_url=self.get_boolean_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_true.metadata = {"url": "/paths/bool/true/{boolPath}"} # type: ignore + + @distributed_trace_async + async def get_boolean_false(self, **kwargs: Any) -> None: + """Get false Boolean value on path. + + :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", {})) + + request = rest_paths.build_get_boolean_false_request( + template_url=self.get_boolean_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_false.metadata = {"url": "/paths/bool/false/{boolPath}"} # type: ignore + + @distributed_trace_async + async def get_int_one_million(self, **kwargs: Any) -> None: + """Get '1000000' integer value. + + :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", {})) + + request = rest_paths.build_get_int_one_million_request( + template_url=self.get_int_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_one_million.metadata = {"url": "/paths/int/1000000/{intPath}"} # type: ignore + + @distributed_trace_async + async def get_int_negative_one_million(self, **kwargs: Any) -> None: + """Get '-1000000' integer value. + + :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", {})) + + request = rest_paths.build_get_int_negative_one_million_request( + template_url=self.get_int_negative_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_negative_one_million.metadata = {"url": "/paths/int/-1000000/{intPath}"} # type: ignore + + @distributed_trace_async + async def get_ten_billion(self, **kwargs: Any) -> None: + """Get '10000000000' 64 bit integer value. + + :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", {})) + + request = rest_paths.build_get_ten_billion_request( + template_url=self.get_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_ten_billion.metadata = {"url": "/paths/long/10000000000/{longPath}"} # type: ignore + + @distributed_trace_async + async def get_negative_ten_billion(self, **kwargs: Any) -> None: + """Get '-10000000000' 64 bit integer value. + + :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", {})) + + request = rest_paths.build_get_negative_ten_billion_request( + template_url=self.get_negative_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_negative_ten_billion.metadata = {"url": "/paths/long/-10000000000/{longPath}"} # type: ignore + + @distributed_trace_async + async def float_scientific_positive(self, **kwargs: Any) -> None: + """Get '1.034E+20' numeric value. + + :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", {})) + + request = rest_paths.build_float_scientific_positive_request( + template_url=self.float_scientific_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_positive.metadata = {"url": "/paths/float/1.034E+20/{floatPath}"} # type: ignore + + @distributed_trace_async + async def float_scientific_negative(self, **kwargs: Any) -> None: + """Get '-1.034E-20' numeric value. + + :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", {})) + + request = rest_paths.build_float_scientific_negative_request( + template_url=self.float_scientific_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_negative.metadata = {"url": "/paths/float/-1.034E-20/{floatPath}"} # type: ignore + + @distributed_trace_async + async def double_decimal_positive(self, **kwargs: Any) -> None: + """Get '9999999.999' numeric value. + + :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", {})) + + request = rest_paths.build_double_decimal_positive_request( + template_url=self.double_decimal_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_positive.metadata = {"url": "/paths/double/9999999.999/{doublePath}"} # type: ignore + + @distributed_trace_async + async def double_decimal_negative(self, **kwargs: Any) -> None: + """Get '-9999999.999' numeric value. + + :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", {})) + + request = rest_paths.build_double_decimal_negative_request( + template_url=self.double_decimal_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_negative.metadata = {"url": "/paths/double/-9999999.999/{doublePath}"} # type: ignore + + @distributed_trace_async + async def string_unicode(self, **kwargs: Any) -> None: + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + :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", {})) + + request = rest_paths.build_string_unicode_request( + template_url=self.string_unicode.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_unicode.metadata = {"url": "/paths/string/unicode/{stringPath}"} # type: ignore + + @distributed_trace_async + async def string_url_encoded(self, **kwargs: Any) -> None: + """Get 'begin!*'();:@ &=+$,/?#[]end. + + :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", {})) + + request = rest_paths.build_string_url_encoded_request( + template_url=self.string_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_url_encoded.metadata = {"url": "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}"} # type: ignore + + @distributed_trace_async + async def string_url_non_encoded(self, **kwargs: Any) -> None: + """Get 'begin!*'();:@&=+$,end. + + https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. + + :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", {})) + + request = rest_paths.build_string_url_non_encoded_request( + template_url=self.string_url_non_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_url_non_encoded.metadata = {"url": "/paths/string/begin!*'();:@&=+$,end/{stringPath}"} # type: ignore + + @distributed_trace_async + async def string_empty(self, **kwargs: Any) -> None: + """Get ''. + + :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", {})) + + request = rest_paths.build_string_empty_request( + template_url=self.string_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_empty.metadata = {"url": "/paths/string/empty/{stringPath}"} # type: ignore + + @distributed_trace_async + async def string_null(self, string_path: str, **kwargs: Any) -> None: + """Get null (should throw). + + :param string_path: null string value. + :type string_path: 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", {})) + + request = rest_paths.build_string_null_request( + string_path=string_path, + template_url=self.string_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_null.metadata = {"url": "/paths/string/null/{stringPath}"} # type: ignore + + @distributed_trace_async + async def enum_valid(self, enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> None: + """Get using uri with 'green color' in path parameter. + + :param enum_path: send the value green. + :type enum_path: str or ~url.models.UriColor + :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", {})) + + request = rest_paths.build_enum_valid_request( + enum_path=enum_path, + template_url=self.enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_valid.metadata = {"url": "/paths/enum/green%20color/{enumPath}"} # type: ignore + + @distributed_trace_async + async def enum_null(self, enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> None: + """Get null (should throw on the client before the request is sent on wire). + + :param enum_path: send null should throw. + :type enum_path: str or ~url.models.UriColor + :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", {})) + + request = rest_paths.build_enum_null_request( + enum_path=enum_path, + template_url=self.enum_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_null.metadata = {"url": "/paths/string/null/{enumPath}"} # type: ignore + + @distributed_trace_async + async def byte_multi_byte(self, byte_path: bytearray, **kwargs: Any) -> None: + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_path: bytearray + :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", {})) + + request = rest_paths.build_byte_multi_byte_request( + byte_path=byte_path, + template_url=self.byte_multi_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_multi_byte.metadata = {"url": "/paths/byte/multibyte/{bytePath}"} # type: ignore + + @distributed_trace_async + async def byte_empty(self, **kwargs: Any) -> None: + """Get '' as byte array. + + :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", {})) + + request = rest_paths.build_byte_empty_request( + template_url=self.byte_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_empty.metadata = {"url": "/paths/byte/empty/{bytePath}"} # type: ignore + + @distributed_trace_async + async def byte_null(self, byte_path: bytearray, **kwargs: Any) -> None: + """Get null as byte array (should throw). + + :param byte_path: null as byte array (should throw). + :type byte_path: bytearray + :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", {})) + + request = rest_paths.build_byte_null_request( + byte_path=byte_path, + template_url=self.byte_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_null.metadata = {"url": "/paths/byte/null/{bytePath}"} # type: ignore + + @distributed_trace_async + async def date_valid(self, **kwargs: Any) -> None: + """Get '2012-01-01' as date. + + :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", {})) + + request = rest_paths.build_date_valid_request( + template_url=self.date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_valid.metadata = {"url": "/paths/date/2012-01-01/{datePath}"} # type: ignore + + @distributed_trace_async + async def date_null(self, date_path: datetime.date, **kwargs: Any) -> None: + """Get null as date - this should throw or be unusable on the client side, depending on date + representation. + + :param date_path: null as date (should throw). + :type date_path: ~datetime.date + :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", {})) + + request = rest_paths.build_date_null_request( + date_path=date_path, + template_url=self.date_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_null.metadata = {"url": "/paths/date/null/{datePath}"} # type: ignore + + @distributed_trace_async + async def date_time_valid(self, **kwargs: Any) -> None: + """Get '2012-01-01T01:01:01Z' as date-time. + + :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", {})) + + request = rest_paths.build_date_time_valid_request( + template_url=self.date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_valid.metadata = {"url": "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}"} # type: ignore + + @distributed_trace_async + async def date_time_null(self, date_time_path: datetime.datetime, **kwargs: Any) -> None: + """Get null as date-time, should be disallowed or throw depending on representation of date-time. + + :param date_time_path: null as date-time. + :type date_time_path: ~datetime.datetime + :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", {})) + + request = rest_paths.build_date_time_null_request( + date_time_path=date_time_path, + template_url=self.date_time_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_null.metadata = {"url": "/paths/datetime/null/{dateTimePath}"} # type: ignore + + @distributed_trace_async + async def base64_url(self, base64_url_path: bytes, **kwargs: Any) -> None: + """Get 'lorem' encoded value as 'bG9yZW0' (base64url). + + :param base64_url_path: base64url encoded value. + :type base64_url_path: bytes + :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", {})) + + request = rest_paths.build_base64_url_request( + base64_url_path=base64_url_path, + template_url=self.base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + base64_url.metadata = {"url": "/paths/string/bG9yZW0/{base64UrlPath}"} # type: ignore + + @distributed_trace_async + async def array_csv_in_path(self, array_path: List[str], **kwargs: Any) -> None: + """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] + using the csv-array format. + :type array_path: list[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", {})) + + request = rest_paths.build_array_csv_in_path_request( + array_path=array_path, + template_url=self.array_csv_in_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_csv_in_path.metadata = {"url": "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}"} # type: ignore + + @distributed_trace_async + async def unix_time_url(self, unix_time_url_path: datetime.datetime, **kwargs: Any) -> None: + """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). + + :param unix_time_url_path: Unix time encoded value. + :type unix_time_url_path: ~datetime.datetime + :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", {})) + + request = rest_paths.build_unix_time_url_request( + unix_time_url_path=unix_time_url_path, + template_url=self.unix_time_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + unix_time_url.metadata = {"url": "/paths/int/1460505600/{unixTimeUrlPath}"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py new file mode 100644 index 00000000000..ffd013f8bdd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/aio/operations/_queries_operations.py @@ -0,0 +1,1275 @@ +# 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 datetime +import functools +from typing import Any, Callable, Dict, Generic, List, 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 ..._rest import queries as rest_queries + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class QueriesOperations: + """QueriesOperations 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: ~url.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 get_boolean_true(self, **kwargs: Any) -> None: + """Get true Boolean value on path. + + :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", {})) + + request = rest_queries.build_get_boolean_true_request( + template_url=self.get_boolean_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_true.metadata = {"url": "/queries/bool/true"} # type: ignore + + @distributed_trace_async + async def get_boolean_false(self, **kwargs: Any) -> None: + """Get false Boolean value on path. + + :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", {})) + + request = rest_queries.build_get_boolean_false_request( + template_url=self.get_boolean_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_false.metadata = {"url": "/queries/bool/false"} # type: ignore + + @distributed_trace_async + async def get_boolean_null(self, bool_query: Optional[bool] = None, **kwargs: Any) -> None: + """Get null Boolean value on query (query string should be absent). + + :param bool_query: null boolean value. + :type bool_query: bool + :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", {})) + + request = rest_queries.build_get_boolean_null_request( + bool_query=bool_query, + template_url=self.get_boolean_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_null.metadata = {"url": "/queries/bool/null"} # type: ignore + + @distributed_trace_async + async def get_int_one_million(self, **kwargs: Any) -> None: + """Get '1000000' integer value. + + :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", {})) + + request = rest_queries.build_get_int_one_million_request( + template_url=self.get_int_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_one_million.metadata = {"url": "/queries/int/1000000"} # type: ignore + + @distributed_trace_async + async def get_int_negative_one_million(self, **kwargs: Any) -> None: + """Get '-1000000' integer value. + + :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", {})) + + request = rest_queries.build_get_int_negative_one_million_request( + template_url=self.get_int_negative_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_negative_one_million.metadata = {"url": "/queries/int/-1000000"} # type: ignore + + @distributed_trace_async + async def get_int_null(self, int_query: Optional[int] = None, **kwargs: Any) -> None: + """Get null integer value (no query parameter). + + :param int_query: null integer value. + :type int_query: int + :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", {})) + + request = rest_queries.build_get_int_null_request( + int_query=int_query, + template_url=self.get_int_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_null.metadata = {"url": "/queries/int/null"} # type: ignore + + @distributed_trace_async + async def get_ten_billion(self, **kwargs: Any) -> None: + """Get '10000000000' 64 bit integer value. + + :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", {})) + + request = rest_queries.build_get_ten_billion_request( + template_url=self.get_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_ten_billion.metadata = {"url": "/queries/long/10000000000"} # type: ignore + + @distributed_trace_async + async def get_negative_ten_billion(self, **kwargs: Any) -> None: + """Get '-10000000000' 64 bit integer value. + + :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", {})) + + request = rest_queries.build_get_negative_ten_billion_request( + template_url=self.get_negative_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_negative_ten_billion.metadata = {"url": "/queries/long/-10000000000"} # type: ignore + + @distributed_trace_async + async def get_long_null(self, long_query: Optional[int] = None, **kwargs: Any) -> None: + """Get 'null 64 bit integer value (no query param in uri). + + :param long_query: null 64 bit integer value. + :type long_query: long + :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", {})) + + request = rest_queries.build_get_long_null_request( + long_query=long_query, + template_url=self.get_long_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_long_null.metadata = {"url": "/queries/long/null"} # type: ignore + + @distributed_trace_async + async def float_scientific_positive(self, **kwargs: Any) -> None: + """Get '1.034E+20' numeric value. + + :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", {})) + + request = rest_queries.build_float_scientific_positive_request( + template_url=self.float_scientific_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_positive.metadata = {"url": "/queries/float/1.034E+20"} # type: ignore + + @distributed_trace_async + async def float_scientific_negative(self, **kwargs: Any) -> None: + """Get '-1.034E-20' numeric value. + + :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", {})) + + request = rest_queries.build_float_scientific_negative_request( + template_url=self.float_scientific_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_negative.metadata = {"url": "/queries/float/-1.034E-20"} # type: ignore + + @distributed_trace_async + async def float_null(self, float_query: Optional[float] = None, **kwargs: Any) -> None: + """Get null numeric value (no query parameter). + + :param float_query: null numeric value. + :type float_query: float + :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", {})) + + request = rest_queries.build_float_null_request( + float_query=float_query, + template_url=self.float_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_null.metadata = {"url": "/queries/float/null"} # type: ignore + + @distributed_trace_async + async def double_decimal_positive(self, **kwargs: Any) -> None: + """Get '9999999.999' numeric value. + + :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", {})) + + request = rest_queries.build_double_decimal_positive_request( + template_url=self.double_decimal_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_positive.metadata = {"url": "/queries/double/9999999.999"} # type: ignore + + @distributed_trace_async + async def double_decimal_negative(self, **kwargs: Any) -> None: + """Get '-9999999.999' numeric value. + + :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", {})) + + request = rest_queries.build_double_decimal_negative_request( + template_url=self.double_decimal_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_negative.metadata = {"url": "/queries/double/-9999999.999"} # type: ignore + + @distributed_trace_async + async def double_null(self, double_query: Optional[float] = None, **kwargs: Any) -> None: + """Get null numeric value (no query parameter). + + :param double_query: null numeric value. + :type double_query: float + :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", {})) + + request = rest_queries.build_double_null_request( + double_query=double_query, + template_url=self.double_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_null.metadata = {"url": "/queries/double/null"} # type: ignore + + @distributed_trace_async + async def string_unicode(self, **kwargs: Any) -> None: + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + :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", {})) + + request = rest_queries.build_string_unicode_request( + template_url=self.string_unicode.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_unicode.metadata = {"url": "/queries/string/unicode/"} # type: ignore + + @distributed_trace_async + async def string_url_encoded(self, **kwargs: Any) -> None: + """Get 'begin!*'();:@ &=+$,/?#[]end. + + :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", {})) + + request = rest_queries.build_string_url_encoded_request( + template_url=self.string_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_url_encoded.metadata = {"url": "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend"} # type: ignore + + @distributed_trace_async + async def string_empty(self, **kwargs: Any) -> None: + """Get ''. + + :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", {})) + + request = rest_queries.build_string_empty_request( + template_url=self.string_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_empty.metadata = {"url": "/queries/string/empty"} # type: ignore + + @distributed_trace_async + async def string_null(self, string_query: Optional[str] = None, **kwargs: Any) -> None: + """Get null (no query parameter in url). + + :param string_query: null string value. + :type string_query: 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", {})) + + request = rest_queries.build_string_null_request( + string_query=string_query, + template_url=self.string_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_null.metadata = {"url": "/queries/string/null"} # type: ignore + + @distributed_trace_async + async def enum_valid(self, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any) -> None: + """Get using uri with query parameter 'green color'. + + :param enum_query: 'green color' enum value. + :type enum_query: str or ~url.models.UriColor + :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", {})) + + request = rest_queries.build_enum_valid_request( + enum_query=enum_query, + template_url=self.enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_valid.metadata = {"url": "/queries/enum/green%20color"} # type: ignore + + @distributed_trace_async + async def enum_null(self, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any) -> None: + """Get null (no query parameter in url). + + :param enum_query: null string value. + :type enum_query: str or ~url.models.UriColor + :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", {})) + + request = rest_queries.build_enum_null_request( + enum_query=enum_query, + template_url=self.enum_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_null.metadata = {"url": "/queries/enum/null"} # type: ignore + + @distributed_trace_async + async def byte_multi_byte(self, byte_query: Optional[bytearray] = None, **kwargs: Any) -> None: + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + :param byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_query: bytearray + :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", {})) + + request = rest_queries.build_byte_multi_byte_request( + byte_query=byte_query, + template_url=self.byte_multi_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_multi_byte.metadata = {"url": "/queries/byte/multibyte"} # type: ignore + + @distributed_trace_async + async def byte_empty(self, **kwargs: Any) -> None: + """Get '' as byte array. + + :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", {})) + + request = rest_queries.build_byte_empty_request( + template_url=self.byte_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_empty.metadata = {"url": "/queries/byte/empty"} # type: ignore + + @distributed_trace_async + async def byte_null(self, byte_query: Optional[bytearray] = None, **kwargs: Any) -> None: + """Get null as byte array (no query parameters in uri). + + :param byte_query: null as byte array (no query parameters in uri). + :type byte_query: bytearray + :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", {})) + + request = rest_queries.build_byte_null_request( + byte_query=byte_query, + template_url=self.byte_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_null.metadata = {"url": "/queries/byte/null"} # type: ignore + + @distributed_trace_async + async def date_valid(self, **kwargs: Any) -> None: + """Get '2012-01-01' as date. + + :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", {})) + + request = rest_queries.build_date_valid_request( + template_url=self.date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_valid.metadata = {"url": "/queries/date/2012-01-01"} # type: ignore + + @distributed_trace_async + async def date_null(self, date_query: Optional[datetime.date] = None, **kwargs: Any) -> None: + """Get null as date - this should result in no query parameters in uri. + + :param date_query: null as date (no query parameters in uri). + :type date_query: ~datetime.date + :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", {})) + + request = rest_queries.build_date_null_request( + date_query=date_query, + template_url=self.date_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_null.metadata = {"url": "/queries/date/null"} # type: ignore + + @distributed_trace_async + async def date_time_valid(self, **kwargs: Any) -> None: + """Get '2012-01-01T01:01:01Z' as date-time. + + :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", {})) + + request = rest_queries.build_date_time_valid_request( + template_url=self.date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_valid.metadata = {"url": "/queries/datetime/2012-01-01T01%3A01%3A01Z"} # type: ignore + + @distributed_trace_async + async def date_time_null(self, date_time_query: Optional[datetime.datetime] = None, **kwargs: Any) -> None: + """Get null as date-time, should result in no query parameters in uri. + + :param date_time_query: null as date-time (no query parameters). + :type date_time_query: ~datetime.datetime + :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", {})) + + request = rest_queries.build_date_time_null_request( + date_time_query=date_time_query, + template_url=self.date_time_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_null.metadata = {"url": "/queries/datetime/null"} # type: ignore + + @distributed_trace_async + async def array_string_csv_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the csv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_csv_valid_request( + array_query=array_query, + template_url=self.array_string_csv_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_csv_valid.metadata = {"url": "/queries/array/csv/string/valid"} # type: ignore + + @distributed_trace_async + async def array_string_csv_null(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get a null array of string using the csv-array format. + + :param array_query: a null array of string using the csv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_csv_null_request( + array_query=array_query, + template_url=self.array_string_csv_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_csv_null.metadata = {"url": "/queries/array/csv/string/null"} # type: ignore + + @distributed_trace_async + async def array_string_csv_empty(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an empty array [] of string using the csv-array format. + + :param array_query: an empty array [] of string using the csv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_csv_empty_request( + array_query=array_query, + template_url=self.array_string_csv_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_csv_empty.metadata = {"url": "/queries/array/csv/string/empty"} # type: ignore + + @distributed_trace_async + async def array_string_no_collection_format_empty( + self, array_query: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', + 'bonjour'] for the 'arrayQuery' parameter to the service. + + :param array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_no_collection_format_empty_request( + array_query=array_query, + template_url=self.array_string_no_collection_format_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_no_collection_format_empty.metadata = {"url": "/queries/array/none/string/empty"} # type: ignore + + @distributed_trace_async + async def array_string_ssv_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + ssv-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the ssv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_ssv_valid_request( + array_query=array_query, + template_url=self.array_string_ssv_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_ssv_valid.metadata = {"url": "/queries/array/ssv/string/valid"} # type: ignore + + @distributed_trace_async + async def array_string_tsv_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + tsv-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the tsv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_tsv_valid_request( + array_query=array_query, + template_url=self.array_string_tsv_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_tsv_valid.metadata = {"url": "/queries/array/tsv/string/valid"} # type: ignore + + @distributed_trace_async + async def array_string_pipes_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + pipes-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the pipes-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_pipes_valid_request( + array_query=array_query, + template_url=self.array_string_pipes_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_pipes_valid.metadata = {"url": "/queries/array/pipes/string/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/models/_auto_rest_url_test_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/_auto_rest_url_test_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/models/_auto_rest_url_test_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/_auto_rest_url_test_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Url/url/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Url/url/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py new file mode 100644 index 00000000000..807788e99f3 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py @@ -0,0 +1,278 @@ +# 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 .. import models as _models +from .._rest import path_items as rest_path_items + +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]] + + +class PathItemsOperations(object): + """PathItemsOperations 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: ~url.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 get_all_with_values( + self, + path_item_string_path, # type: str + local_string_path, # type: str + path_item_string_query=None, # type: Optional[str] + local_string_query=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :type path_item_string_query: str + :param local_string_query: should contain value 'localStringQuery'. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_all_with_values_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_all_with_values.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_all_with_values.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery"} # type: ignore + + @distributed_trace + def get_global_query_null( + self, + path_item_string_path, # type: str + local_string_path, # type: str + path_item_string_query=None, # type: Optional[str] + local_string_query=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :type path_item_string_query: str + :param local_string_query: should contain value 'localStringQuery'. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_global_query_null_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_global_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_global_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery"} # type: ignore + + @distributed_trace + def get_global_and_local_query_null( + self, + path_item_string_path, # type: str + local_string_path, # type: str + path_item_string_query=None, # type: Optional[str] + local_string_query=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery=null. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :type path_item_string_query: str + :param local_string_query: should contain null value. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_global_and_local_query_null_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_global_and_local_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_global_and_local_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null"} # type: ignore + + @distributed_trace + def get_local_path_item_query_null( + self, + path_item_string_path, # type: str + local_string_path, # type: str + path_item_string_query=None, # type: Optional[str] + local_string_query=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery=null, localStringQuery=null. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :param path_item_string_query: should contain value null. + :type path_item_string_query: str + :param local_string_query: should contain value null. + :type local_string_query: 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", {})) + + request = rest_path_items.build_get_local_path_item_query_null_request( + path_item_string_path=path_item_string_path, + global_string_path=self._config.global_string_path, + local_string_path=local_string_path, + path_item_string_query=path_item_string_query, + global_string_query=self._config.global_string_query, + local_string_query=local_string_query, + template_url=self.get_local_path_item_query_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_local_path_item_query_null.metadata = {"url": "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py new file mode 100644 index 00000000000..08c81dcaffe --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py @@ -0,0 +1,1029 @@ +# 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 datetime +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 .. import models as _models +from .._rest import paths as rest_paths + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class PathsOperations(object): + """PathsOperations 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: ~url.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 get_boolean_true( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get true Boolean value on path. + + :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", {})) + + request = rest_paths.build_get_boolean_true_request( + template_url=self.get_boolean_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_true.metadata = {"url": "/paths/bool/true/{boolPath}"} # type: ignore + + @distributed_trace + def get_boolean_false( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get false Boolean value on path. + + :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", {})) + + request = rest_paths.build_get_boolean_false_request( + template_url=self.get_boolean_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_false.metadata = {"url": "/paths/bool/false/{boolPath}"} # type: ignore + + @distributed_trace + def get_int_one_million( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '1000000' integer value. + + :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", {})) + + request = rest_paths.build_get_int_one_million_request( + template_url=self.get_int_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_one_million.metadata = {"url": "/paths/int/1000000/{intPath}"} # type: ignore + + @distributed_trace + def get_int_negative_one_million( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-1000000' integer value. + + :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", {})) + + request = rest_paths.build_get_int_negative_one_million_request( + template_url=self.get_int_negative_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_negative_one_million.metadata = {"url": "/paths/int/-1000000/{intPath}"} # type: ignore + + @distributed_trace + def get_ten_billion( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '10000000000' 64 bit integer value. + + :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", {})) + + request = rest_paths.build_get_ten_billion_request( + template_url=self.get_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_ten_billion.metadata = {"url": "/paths/long/10000000000/{longPath}"} # type: ignore + + @distributed_trace + def get_negative_ten_billion( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-10000000000' 64 bit integer value. + + :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", {})) + + request = rest_paths.build_get_negative_ten_billion_request( + template_url=self.get_negative_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_negative_ten_billion.metadata = {"url": "/paths/long/-10000000000/{longPath}"} # type: ignore + + @distributed_trace + def float_scientific_positive( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '1.034E+20' numeric value. + + :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", {})) + + request = rest_paths.build_float_scientific_positive_request( + template_url=self.float_scientific_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_positive.metadata = {"url": "/paths/float/1.034E+20/{floatPath}"} # type: ignore + + @distributed_trace + def float_scientific_negative( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-1.034E-20' numeric value. + + :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", {})) + + request = rest_paths.build_float_scientific_negative_request( + template_url=self.float_scientific_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_negative.metadata = {"url": "/paths/float/-1.034E-20/{floatPath}"} # type: ignore + + @distributed_trace + def double_decimal_positive( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '9999999.999' numeric value. + + :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", {})) + + request = rest_paths.build_double_decimal_positive_request( + template_url=self.double_decimal_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_positive.metadata = {"url": "/paths/double/9999999.999/{doublePath}"} # type: ignore + + @distributed_trace + def double_decimal_negative( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-9999999.999' numeric value. + + :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", {})) + + request = rest_paths.build_double_decimal_negative_request( + template_url=self.double_decimal_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_negative.metadata = {"url": "/paths/double/-9999999.999/{doublePath}"} # type: ignore + + @distributed_trace + def string_unicode( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + :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", {})) + + request = rest_paths.build_string_unicode_request( + template_url=self.string_unicode.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_unicode.metadata = {"url": "/paths/string/unicode/{stringPath}"} # type: ignore + + @distributed_trace + def string_url_encoded( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get 'begin!*'();:@ &=+$,/?#[]end. + + :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", {})) + + request = rest_paths.build_string_url_encoded_request( + template_url=self.string_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_url_encoded.metadata = {"url": "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}"} # type: ignore + + @distributed_trace + def string_url_non_encoded( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get 'begin!*'();:@&=+$,end. + + https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. + + :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", {})) + + request = rest_paths.build_string_url_non_encoded_request( + template_url=self.string_url_non_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_url_non_encoded.metadata = {"url": "/paths/string/begin!*'();:@&=+$,end/{stringPath}"} # type: ignore + + @distributed_trace + def string_empty( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get ''. + + :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", {})) + + request = rest_paths.build_string_empty_request( + template_url=self.string_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_empty.metadata = {"url": "/paths/string/empty/{stringPath}"} # type: ignore + + @distributed_trace + def string_null( + self, + string_path, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Get null (should throw). + + :param string_path: null string value. + :type string_path: 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", {})) + + request = rest_paths.build_string_null_request( + string_path=string_path, + template_url=self.string_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_null.metadata = {"url": "/paths/string/null/{stringPath}"} # type: ignore + + @distributed_trace + def enum_valid( + self, + enum_path, # type: Union[str, "_models.UriColor"] + **kwargs # type: Any + ): + # type: (...) -> None + """Get using uri with 'green color' in path parameter. + + :param enum_path: send the value green. + :type enum_path: str or ~url.models.UriColor + :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", {})) + + request = rest_paths.build_enum_valid_request( + enum_path=enum_path, + template_url=self.enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_valid.metadata = {"url": "/paths/enum/green%20color/{enumPath}"} # type: ignore + + @distributed_trace + def enum_null( + self, + enum_path, # type: Union[str, "_models.UriColor"] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null (should throw on the client before the request is sent on wire). + + :param enum_path: send null should throw. + :type enum_path: str or ~url.models.UriColor + :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", {})) + + request = rest_paths.build_enum_null_request( + enum_path=enum_path, + template_url=self.enum_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_null.metadata = {"url": "/paths/string/null/{enumPath}"} # type: ignore + + @distributed_trace + def byte_multi_byte( + self, + byte_path, # type: bytearray + **kwargs # type: Any + ): + # type: (...) -> None + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_path: bytearray + :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", {})) + + request = rest_paths.build_byte_multi_byte_request( + byte_path=byte_path, + template_url=self.byte_multi_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_multi_byte.metadata = {"url": "/paths/byte/multibyte/{bytePath}"} # type: ignore + + @distributed_trace + def byte_empty( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '' as byte array. + + :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", {})) + + request = rest_paths.build_byte_empty_request( + template_url=self.byte_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_empty.metadata = {"url": "/paths/byte/empty/{bytePath}"} # type: ignore + + @distributed_trace + def byte_null( + self, + byte_path, # type: bytearray + **kwargs # type: Any + ): + # type: (...) -> None + """Get null as byte array (should throw). + + :param byte_path: null as byte array (should throw). + :type byte_path: bytearray + :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", {})) + + request = rest_paths.build_byte_null_request( + byte_path=byte_path, + template_url=self.byte_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_null.metadata = {"url": "/paths/byte/null/{bytePath}"} # type: ignore + + @distributed_trace + def date_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '2012-01-01' as date. + + :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", {})) + + request = rest_paths.build_date_valid_request( + template_url=self.date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_valid.metadata = {"url": "/paths/date/2012-01-01/{datePath}"} # type: ignore + + @distributed_trace + def date_null( + self, + date_path, # type: datetime.date + **kwargs # type: Any + ): + # type: (...) -> None + """Get null as date - this should throw or be unusable on the client side, depending on date + representation. + + :param date_path: null as date (should throw). + :type date_path: ~datetime.date + :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", {})) + + request = rest_paths.build_date_null_request( + date_path=date_path, + template_url=self.date_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_null.metadata = {"url": "/paths/date/null/{datePath}"} # type: ignore + + @distributed_trace + def date_time_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '2012-01-01T01:01:01Z' as date-time. + + :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", {})) + + request = rest_paths.build_date_time_valid_request( + template_url=self.date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_valid.metadata = {"url": "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}"} # type: ignore + + @distributed_trace + def date_time_null( + self, + date_time_path, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Get null as date-time, should be disallowed or throw depending on representation of date-time. + + :param date_time_path: null as date-time. + :type date_time_path: ~datetime.datetime + :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", {})) + + request = rest_paths.build_date_time_null_request( + date_time_path=date_time_path, + template_url=self.date_time_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_null.metadata = {"url": "/paths/datetime/null/{dateTimePath}"} # type: ignore + + @distributed_trace + def base64_url( + self, + base64_url_path, # type: bytes + **kwargs # type: Any + ): + # type: (...) -> None + """Get 'lorem' encoded value as 'bG9yZW0' (base64url). + + :param base64_url_path: base64url encoded value. + :type base64_url_path: bytes + :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", {})) + + request = rest_paths.build_base64_url_request( + base64_url_path=base64_url_path, + template_url=self.base64_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + base64_url.metadata = {"url": "/paths/string/bG9yZW0/{base64UrlPath}"} # type: ignore + + @distributed_trace + def array_csv_in_path( + self, + array_path, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] + using the csv-array format. + :type array_path: list[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", {})) + + request = rest_paths.build_array_csv_in_path_request( + array_path=array_path, + template_url=self.array_csv_in_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_csv_in_path.metadata = {"url": "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}"} # type: ignore + + @distributed_trace + def unix_time_url( + self, + unix_time_url_path, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> None + """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). + + :param unix_time_url_path: Unix time encoded value. + :type unix_time_url_path: ~datetime.datetime + :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", {})) + + request = rest_paths.build_unix_time_url_request( + unix_time_url_path=unix_time_url_path, + template_url=self.unix_time_url.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + unix_time_url.metadata = {"url": "/paths/int/1460505600/{unixTimeUrlPath}"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py new file mode 100644 index 00000000000..d99c2fa9f85 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py @@ -0,0 +1,1350 @@ +# 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 datetime +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 .. import models as _models +from .._rest import queries as rest_queries + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class QueriesOperations(object): + """QueriesOperations 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: ~url.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 get_boolean_true( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get true Boolean value on path. + + :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", {})) + + request = rest_queries.build_get_boolean_true_request( + template_url=self.get_boolean_true.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_true.metadata = {"url": "/queries/bool/true"} # type: ignore + + @distributed_trace + def get_boolean_false( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get false Boolean value on path. + + :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", {})) + + request = rest_queries.build_get_boolean_false_request( + template_url=self.get_boolean_false.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_false.metadata = {"url": "/queries/bool/false"} # type: ignore + + @distributed_trace + def get_boolean_null( + self, + bool_query=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null Boolean value on query (query string should be absent). + + :param bool_query: null boolean value. + :type bool_query: bool + :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", {})) + + request = rest_queries.build_get_boolean_null_request( + bool_query=bool_query, + template_url=self.get_boolean_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_boolean_null.metadata = {"url": "/queries/bool/null"} # type: ignore + + @distributed_trace + def get_int_one_million( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '1000000' integer value. + + :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", {})) + + request = rest_queries.build_get_int_one_million_request( + template_url=self.get_int_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_one_million.metadata = {"url": "/queries/int/1000000"} # type: ignore + + @distributed_trace + def get_int_negative_one_million( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-1000000' integer value. + + :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", {})) + + request = rest_queries.build_get_int_negative_one_million_request( + template_url=self.get_int_negative_one_million.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_negative_one_million.metadata = {"url": "/queries/int/-1000000"} # type: ignore + + @distributed_trace + def get_int_null( + self, + int_query=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null integer value (no query parameter). + + :param int_query: null integer value. + :type int_query: int + :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", {})) + + request = rest_queries.build_get_int_null_request( + int_query=int_query, + template_url=self.get_int_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_int_null.metadata = {"url": "/queries/int/null"} # type: ignore + + @distributed_trace + def get_ten_billion( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '10000000000' 64 bit integer value. + + :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", {})) + + request = rest_queries.build_get_ten_billion_request( + template_url=self.get_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_ten_billion.metadata = {"url": "/queries/long/10000000000"} # type: ignore + + @distributed_trace + def get_negative_ten_billion( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-10000000000' 64 bit integer value. + + :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", {})) + + request = rest_queries.build_get_negative_ten_billion_request( + template_url=self.get_negative_ten_billion.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_negative_ten_billion.metadata = {"url": "/queries/long/-10000000000"} # type: ignore + + @distributed_trace + def get_long_null( + self, + long_query=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """Get 'null 64 bit integer value (no query param in uri). + + :param long_query: null 64 bit integer value. + :type long_query: long + :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", {})) + + request = rest_queries.build_get_long_null_request( + long_query=long_query, + template_url=self.get_long_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + get_long_null.metadata = {"url": "/queries/long/null"} # type: ignore + + @distributed_trace + def float_scientific_positive( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '1.034E+20' numeric value. + + :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", {})) + + request = rest_queries.build_float_scientific_positive_request( + template_url=self.float_scientific_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_positive.metadata = {"url": "/queries/float/1.034E+20"} # type: ignore + + @distributed_trace + def float_scientific_negative( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-1.034E-20' numeric value. + + :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", {})) + + request = rest_queries.build_float_scientific_negative_request( + template_url=self.float_scientific_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_scientific_negative.metadata = {"url": "/queries/float/-1.034E-20"} # type: ignore + + @distributed_trace + def float_null( + self, + float_query=None, # type: Optional[float] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null numeric value (no query parameter). + + :param float_query: null numeric value. + :type float_query: float + :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", {})) + + request = rest_queries.build_float_null_request( + float_query=float_query, + template_url=self.float_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + float_null.metadata = {"url": "/queries/float/null"} # type: ignore + + @distributed_trace + def double_decimal_positive( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '9999999.999' numeric value. + + :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", {})) + + request = rest_queries.build_double_decimal_positive_request( + template_url=self.double_decimal_positive.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_positive.metadata = {"url": "/queries/double/9999999.999"} # type: ignore + + @distributed_trace + def double_decimal_negative( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '-9999999.999' numeric value. + + :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", {})) + + request = rest_queries.build_double_decimal_negative_request( + template_url=self.double_decimal_negative.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_decimal_negative.metadata = {"url": "/queries/double/-9999999.999"} # type: ignore + + @distributed_trace + def double_null( + self, + double_query=None, # type: Optional[float] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null numeric value (no query parameter). + + :param double_query: null numeric value. + :type double_query: float + :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", {})) + + request = rest_queries.build_double_null_request( + double_query=double_query, + template_url=self.double_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + double_null.metadata = {"url": "/queries/double/null"} # type: ignore + + @distributed_trace + def string_unicode( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + :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", {})) + + request = rest_queries.build_string_unicode_request( + template_url=self.string_unicode.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_unicode.metadata = {"url": "/queries/string/unicode/"} # type: ignore + + @distributed_trace + def string_url_encoded( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get 'begin!*'();:@ &=+$,/?#[]end. + + :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", {})) + + request = rest_queries.build_string_url_encoded_request( + template_url=self.string_url_encoded.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_url_encoded.metadata = {"url": "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend"} # type: ignore + + @distributed_trace + def string_empty( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get ''. + + :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", {})) + + request = rest_queries.build_string_empty_request( + template_url=self.string_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_empty.metadata = {"url": "/queries/string/empty"} # type: ignore + + @distributed_trace + def string_null( + self, + string_query=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null (no query parameter in url). + + :param string_query: null string value. + :type string_query: 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", {})) + + request = rest_queries.build_string_null_request( + string_query=string_query, + template_url=self.string_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + string_null.metadata = {"url": "/queries/string/null"} # type: ignore + + @distributed_trace + def enum_valid( + self, + enum_query=None, # type: Optional[Union[str, "_models.UriColor"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get using uri with query parameter 'green color'. + + :param enum_query: 'green color' enum value. + :type enum_query: str or ~url.models.UriColor + :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", {})) + + request = rest_queries.build_enum_valid_request( + enum_query=enum_query, + template_url=self.enum_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_valid.metadata = {"url": "/queries/enum/green%20color"} # type: ignore + + @distributed_trace + def enum_null( + self, + enum_query=None, # type: Optional[Union[str, "_models.UriColor"]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null (no query parameter in url). + + :param enum_query: null string value. + :type enum_query: str or ~url.models.UriColor + :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", {})) + + request = rest_queries.build_enum_null_request( + enum_query=enum_query, + template_url=self.enum_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + enum_null.metadata = {"url": "/queries/enum/null"} # type: ignore + + @distributed_trace + def byte_multi_byte( + self, + byte_query=None, # type: Optional[bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + :param byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_query: bytearray + :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", {})) + + request = rest_queries.build_byte_multi_byte_request( + byte_query=byte_query, + template_url=self.byte_multi_byte.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_multi_byte.metadata = {"url": "/queries/byte/multibyte"} # type: ignore + + @distributed_trace + def byte_empty( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '' as byte array. + + :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", {})) + + request = rest_queries.build_byte_empty_request( + template_url=self.byte_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_empty.metadata = {"url": "/queries/byte/empty"} # type: ignore + + @distributed_trace + def byte_null( + self, + byte_query=None, # type: Optional[bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null as byte array (no query parameters in uri). + + :param byte_query: null as byte array (no query parameters in uri). + :type byte_query: bytearray + :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", {})) + + request = rest_queries.build_byte_null_request( + byte_query=byte_query, + template_url=self.byte_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + byte_null.metadata = {"url": "/queries/byte/null"} # type: ignore + + @distributed_trace + def date_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '2012-01-01' as date. + + :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", {})) + + request = rest_queries.build_date_valid_request( + template_url=self.date_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_valid.metadata = {"url": "/queries/date/2012-01-01"} # type: ignore + + @distributed_trace + def date_null( + self, + date_query=None, # type: Optional[datetime.date] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null as date - this should result in no query parameters in uri. + + :param date_query: null as date (no query parameters in uri). + :type date_query: ~datetime.date + :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", {})) + + request = rest_queries.build_date_null_request( + date_query=date_query, + template_url=self.date_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_null.metadata = {"url": "/queries/date/null"} # type: ignore + + @distributed_trace + def date_time_valid( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get '2012-01-01T01:01:01Z' as date-time. + + :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", {})) + + request = rest_queries.build_date_time_valid_request( + template_url=self.date_time_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_valid.metadata = {"url": "/queries/datetime/2012-01-01T01%3A01%3A01Z"} # type: ignore + + @distributed_trace + def date_time_null( + self, + date_time_query=None, # type: Optional[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Get null as date-time, should result in no query parameters in uri. + + :param date_time_query: null as date-time (no query parameters). + :type date_time_query: ~datetime.datetime + :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", {})) + + request = rest_queries.build_date_time_null_request( + date_time_query=date_time_query, + template_url=self.date_time_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + date_time_null.metadata = {"url": "/queries/datetime/null"} # type: ignore + + @distributed_trace + def array_string_csv_valid( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the csv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_csv_valid_request( + array_query=array_query, + template_url=self.array_string_csv_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_csv_valid.metadata = {"url": "/queries/array/csv/string/valid"} # type: ignore + + @distributed_trace + def array_string_csv_null( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get a null array of string using the csv-array format. + + :param array_query: a null array of string using the csv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_csv_null_request( + array_query=array_query, + template_url=self.array_string_csv_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_csv_null.metadata = {"url": "/queries/array/csv/string/null"} # type: ignore + + @distributed_trace + def array_string_csv_empty( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an empty array [] of string using the csv-array format. + + :param array_query: an empty array [] of string using the csv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_csv_empty_request( + array_query=array_query, + template_url=self.array_string_csv_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_csv_empty.metadata = {"url": "/queries/array/csv/string/empty"} # type: ignore + + @distributed_trace + def array_string_no_collection_format_empty( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', + 'bonjour'] for the 'arrayQuery' parameter to the service. + + :param array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_no_collection_format_empty_request( + array_query=array_query, + template_url=self.array_string_no_collection_format_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_no_collection_format_empty.metadata = {"url": "/queries/array/none/string/empty"} # type: ignore + + @distributed_trace + def array_string_ssv_valid( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + ssv-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the ssv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_ssv_valid_request( + array_query=array_query, + template_url=self.array_string_ssv_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_ssv_valid.metadata = {"url": "/queries/array/ssv/string/valid"} # type: ignore + + @distributed_trace + def array_string_tsv_valid( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + tsv-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the tsv-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_tsv_valid_request( + array_query=array_query, + template_url=self.array_string_tsv_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_tsv_valid.metadata = {"url": "/queries/array/tsv/string/valid"} # type: ignore + + @distributed_trace + def array_string_pipes_valid( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + pipes-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the pipes-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_pipes_valid_request( + array_query=array_query, + template_url=self.array_string_pipes_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_pipes_valid.metadata = {"url": "/queries/array/pipes/string/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/setup.py new file mode 100644 index 00000000000..915d4facbe0 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/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 = "autoresturlmutlicollectionformattestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestUrlMutliCollectionFormatTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestUrlMutliCollectionFormatTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_auto_rest_url_mutli_collection_format_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_auto_rest_url_mutli_collection_format_test_service.py new file mode 100644 index 00000000000..146a46e044f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_auto_rest_url_mutli_collection_format_test_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestUrlMutliCollectionFormatTestServiceConfiguration +from .operations import QueriesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestUrlMutliCollectionFormatTestService(object): + """Test Infrastructure for AutoRest. + + :ivar queries: QueriesOperations operations + :vartype queries: urlmulticollectionformat.operations.QueriesOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlMutliCollectionFormatTestServiceConfiguration(**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.queries = QueriesOperations(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. + + We have helper methods to create requests specific to this service in `urlmulticollectionformat.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from urlmulticollectionformat._rest import queries + >>> request = queries.build_array_string_multi_null_request(array_query=array_query, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestUrlMutliCollectionFormatTestService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_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/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/__init__.py new file mode 100644 index 00000000000..deed18c33fd --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/__init__.py @@ -0,0 +1,22 @@ +# 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_array_string_multi_null_request + from ._request_builders_py3 import build_array_string_multi_empty_request + from ._request_builders_py3 import build_array_string_multi_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_array_string_multi_null_request # type: ignore + from ._request_builders import build_array_string_multi_empty_request # type: ignore + from ._request_builders import build_array_string_multi_valid_request # type: ignore + +__all__ = [ + "build_array_string_multi_null_request", + "build_array_string_multi_empty_request", + "build_array_string_multi_valid_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/_request_builders.py new file mode 100644 index 00000000000..c353b6fa18d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/_request_builders.py @@ -0,0 +1,143 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_array_string_multi_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/multi/string/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = [_SERIALIZER.query("array_query", q, 'str') if q is not None else '' for q in array_query] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_multi_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array [] of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/multi/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = [_SERIALIZER.query("array_query", q, 'str') if q is not None else '' for q in array_query] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_multi_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + mult-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the mult-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/multi/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = [_SERIALIZER.query("array_query", q, 'str') if q is not None else '' for q in array_query] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/_request_builders_py3.py new file mode 100644 index 00000000000..6a7aba129ec --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_rest/queries/_request_builders_py3.py @@ -0,0 +1,111 @@ +# 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, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_array_string_multi_null_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get a null array of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/multi/string/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = [ + _SERIALIZER.query("array_query", q, "str") if q is not None else "" for q in array_query + ] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_multi_empty_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an empty array [] of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/multi/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = [ + _SERIALIZER.query("array_query", q, "str") if q is not None else "" for q in array_query + ] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_multi_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + mult-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the mult-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/multi/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = [ + _SERIALIZER.query("array_query", q, "str") if q is not None else "" for q in array_query + ] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_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/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_auto_rest_url_mutli_collection_format_test_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_auto_rest_url_mutli_collection_format_test_service.py new file mode 100644 index 00000000000..7dae57b9aae --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_auto_rest_url_mutli_collection_format_test_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestUrlMutliCollectionFormatTestServiceConfiguration +from .operations import QueriesOperations + + +class AutoRestUrlMutliCollectionFormatTestService: + """Test Infrastructure for AutoRest. + + :ivar queries: QueriesOperations operations + :vartype queries: urlmulticollectionformat.aio.operations.QueriesOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlMutliCollectionFormatTestServiceConfiguration(**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.queries = QueriesOperations(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. + + We have helper methods to create requests specific to this service in `urlmulticollectionformat.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from urlmulticollectionformat._rest import queries + >>> request = queries.build_array_string_multi_null_request(array_query=array_query, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestUrlMutliCollectionFormatTestService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py new file mode 100644 index 00000000000..3e480495c7f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/operations/_queries_operations.py @@ -0,0 +1,161 @@ +# 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, List, 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 ... import models as _models +from ..._rest import queries as rest_queries + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class QueriesOperations: + """QueriesOperations 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: ~urlmulticollectionformat.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 array_string_multi_null(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get a null array of string using the multi-array format. + + :param array_query: a null array of string using the multi-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_multi_null_request( + array_query=array_query, + template_url=self.array_string_multi_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_multi_null.metadata = {"url": "/queries/array/multi/string/null"} # type: ignore + + @distributed_trace_async + async def array_string_multi_empty(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an empty array [] of string using the multi-array format. + + :param array_query: an empty array [] of string using the multi-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_multi_empty_request( + array_query=array_query, + template_url=self.array_string_multi_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_multi_empty.metadata = {"url": "/queries/array/multi/string/empty"} # type: ignore + + @distributed_trace_async + async def array_string_multi_valid(self, array_query: Optional[List[str]] = None, **kwargs: Any) -> None: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + mult-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the mult-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_multi_valid_request( + array_query=array_query, + template_url=self.array_string_multi_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_multi_valid.metadata = {"url": "/queries/array/multi/string/valid"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py new file mode 100644 index 00000000000..1c010b50a64 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/operations/_queries_operations.py @@ -0,0 +1,174 @@ +# 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 .. import models as _models +from .._rest import queries as rest_queries + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class QueriesOperations(object): + """QueriesOperations 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: ~urlmulticollectionformat.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 array_string_multi_null( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get a null array of string using the multi-array format. + + :param array_query: a null array of string using the multi-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_multi_null_request( + array_query=array_query, + template_url=self.array_string_multi_null.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_multi_null.metadata = {"url": "/queries/array/multi/string/null"} # type: ignore + + @distributed_trace + def array_string_multi_empty( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an empty array [] of string using the multi-array format. + + :param array_query: an empty array [] of string using the multi-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_multi_empty_request( + array_query=array_query, + template_url=self.array_string_multi_empty.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_multi_empty.metadata = {"url": "/queries/array/multi/string/empty"} # type: ignore + + @distributed_trace + def array_string_multi_valid( + self, + array_query=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + mult-array format. + + :param array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the mult-array format. + :type array_query: list[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", {})) + + request = rest_queries.build_array_string_multi_valid_request( + array_query=array_query, + template_url=self.array_string_multi_valid.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + array_string_multi_valid.metadata = {"url": "/queries/array/multi/string/valid"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/setup.py new file mode 100644 index 00000000000..f909ccf3776 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/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 = "autorestvalidationtest" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestValidationTest", + author_email="", + url="", + keywords=["Swagger", "AutoRestValidationTest"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. No server backend exists for these tests. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_auto_rest_validation_test.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_auto_rest_validation_test.py new file mode 100644 index 00000000000..9f61cc59bde --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_auto_rest_validation_test.py @@ -0,0 +1,95 @@ +# 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 AutoRestValidationTestConfiguration +from .operations import AutoRestValidationTestOperationsMixin + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestValidationTest(AutoRestValidationTestOperationsMixin): + """Test Infrastructure for AutoRest. No server backend exists for these tests. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestValidationTestConfiguration(subscription_id, **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) + + 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 `validation.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from validation._rest import build_validation_of_method_parameters_request + >>> request = build_validation_of_method_parameters_request(subscription_id, resource_group_name, id, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestValidationTest + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/__init__.py new file mode 100644 index 00000000000..3d6cfc6b060 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/__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 ._request_builders_py3 import build_validation_of_method_parameters_request + from ._request_builders_py3 import build_validation_of_body_request + from ._request_builders_py3 import build_get_with_constant_in_path_request + from ._request_builders_py3 import build_post_with_constant_in_body_request +except (SyntaxError, ImportError): + from ._request_builders import build_validation_of_method_parameters_request # type: ignore + from ._request_builders import build_validation_of_body_request # type: ignore + from ._request_builders import build_get_with_constant_in_path_request # type: ignore + from ._request_builders import build_post_with_constant_in_body_request # type: ignore + +__all__ = [ + "build_validation_of_method_parameters_request", + "build_validation_of_body_request", + "build_get_with_constant_in_path_request", + "build_post_with_constant_in_body_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/_request_builders.py new file mode 100644 index 00000000000..52c5c9d4549 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/_request_builders.py @@ -0,0 +1,209 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_validation_of_method_parameters_request( + subscription_id, # type: str + resource_group_name, # type: str + id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Validates input parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/fakepath/{subscriptionId}/{resourceGroupName}/{id}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9\']+'), + 'id': _SERIALIZER.url("id", id, 'int', maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['apiVersion'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validation_of_body_request( + subscription_id, # type: str + resource_group_name, # type: str + id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Validates body parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/fakepath/{subscriptionId}/{resourceGroupName}/{id}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'), + 'id': _SERIALIZER.url("id", id, 'int', maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['apiVersion'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_with_constant_in_path_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """get_with_constant_in_path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + constant_param = "constant" + # Construct URL + url = kwargs.pop("template_url", '/validation/constantsInPath/{constantParam}/value') + path_format_arguments = { + 'constantParam': _SERIALIZER.url("constant_param", constant_param, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_post_with_constant_in_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """post_with_constant_in_body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + constant_param = "constant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/validation/constantsInPath/{constantParam}/value') + path_format_arguments = { + 'constantParam': _SERIALIZER.url("constant_param", constant_param, 'str'), + } + 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/_request_builders_py3.py new file mode 100644 index 00000000000..f2495f92e85 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_rest/_request_builders_py3.py @@ -0,0 +1,175 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_validation_of_method_parameters_request( + subscription_id: str, resource_group_name: str, id: int, **kwargs: Any +) -> HttpRequest: + """Validates input parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :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 + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/fakepath/{subscriptionId}/{resourceGroupName}/{id}") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=10, min_length=3, pattern=r"[a-zA-Z0-9\']+" + ), + "id": _SERIALIZER.url("id", id, "int", maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["apiVersion"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_validation_of_body_request( + subscription_id: str, resource_group_name: str, id: int, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Validates body parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/fakepath/{subscriptionId}/{resourceGroupName}/{id}") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=10, min_length=3, pattern=r"[a-zA-Z0-9]+" + ), + "id": _SERIALIZER.url("id", id, "int", maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["apiVersion"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_get_with_constant_in_path_request(**kwargs: Any) -> HttpRequest: + """get_with_constant_in_path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + constant_param = "constant" + # Construct URL + url = kwargs.pop("template_url", "/validation/constantsInPath/{constantParam}/value") + path_format_arguments = { + "constantParam": _SERIALIZER.url("constant_param", constant_param, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_post_with_constant_in_body_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """post_with_constant_in_body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + constant_param = "constant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/validation/constantsInPath/{constantParam}/value") + path_format_arguments = { + "constantParam": _SERIALIZER.url("constant_param", constant_param, "str"), + } + 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/_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/Expected/AcceptanceTests/Validation/validation/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_auto_rest_validation_test.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_auto_rest_validation_test.py new file mode 100644 index 00000000000..ef67f00f69b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_auto_rest_validation_test.py @@ -0,0 +1,76 @@ +# 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 AutoRestValidationTestConfiguration +from .operations import AutoRestValidationTestOperationsMixin + + +class AutoRestValidationTest(AutoRestValidationTestOperationsMixin): + """Test Infrastructure for AutoRest. No server backend exists for these tests. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, subscription_id: str, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestValidationTestConfiguration(subscription_id, **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) + + 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 `validation.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from validation._rest import build_validation_of_method_parameters_request + >>> request = build_validation_of_method_parameters_request(subscription_id, resource_group_name, id, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestValidationTest": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py new file mode 100644 index 00000000000..03f96b9c50c --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py @@ -0,0 +1,211 @@ +# 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 ... import _rest as rest, models as _models + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutoRestValidationTestOperationsMixin: + @distributed_trace_async + async def validation_of_method_parameters( + self, resource_group_name: str, id: int, **kwargs: Any + ) -> "_models.Product": + """Validates input parameters on the method. See swagger for details. + + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~validation.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_validation_of_method_parameters_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + id=id, + template_url=self.validation_of_method_parameters.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validation_of_method_parameters.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore + + @distributed_trace_async + async def validation_of_body( + self, resource_group_name: str, id: int, body: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + """Validates body parameters on the method. See swagger for details. + + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :param body: + :type body: ~validation.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~validation.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if body is not None: + json = self._serialize.body(body, "Product") + else: + json = None + + request = rest.build_validation_of_body_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + id=id, + content_type=content_type, + json=json, + template_url=self.validation_of_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validation_of_body.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore + + @distributed_trace_async + async def get_with_constant_in_path(self, **kwargs: Any) -> None: + """get_with_constant_in_path. + + :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", {})) + + request = rest.build_get_with_constant_in_path_request( + template_url=self.get_with_constant_in_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_with_constant_in_path.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore + + @distributed_trace_async + async def post_with_constant_in_body( + self, body: Optional["_models.Product"] = None, **kwargs: Any + ) -> "_models.Product": + """post_with_constant_in_body. + + :param body: + :type body: ~validation.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~validation.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if body is not None: + json = self._serialize.body(body, "Product") + else: + json = None + + request = rest.build_post_with_constant_in_body_request( + content_type=content_type, + json=json, + template_url=self.post_with_constant_in_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + post_with_constant_in_body.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Validation/validation/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py new file mode 100644 index 00000000000..660dfa1cc05 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/operations/_auto_rest_validation_test_operations.py @@ -0,0 +1,222 @@ +# 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 .. import _rest as rest, models as _models + +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]] + + +class AutoRestValidationTestOperationsMixin(object): + @distributed_trace + def validation_of_method_parameters( + self, + resource_group_name, # type: str + id, # type: int + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + """Validates input parameters on the method. See swagger for details. + + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~validation.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest.build_validation_of_method_parameters_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + id=id, + template_url=self.validation_of_method_parameters.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validation_of_method_parameters.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore + + @distributed_trace + def validation_of_body( + self, + resource_group_name, # type: str + id, # type: int + body=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + """Validates body parameters on the method. See swagger for details. + + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :param body: + :type body: ~validation.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~validation.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if body is not None: + json = self._serialize.body(body, "Product") + else: + json = None + + request = rest.build_validation_of_body_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + id=id, + content_type=content_type, + json=json, + template_url=self.validation_of_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validation_of_body.metadata = {"url": "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"} # type: ignore + + @distributed_trace + def get_with_constant_in_path( + self, **kwargs # type: Any + ): + # type: (...) -> None + """get_with_constant_in_path. + + :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", {})) + + request = rest.build_get_with_constant_in_path_request( + template_url=self.get_with_constant_in_path.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + get_with_constant_in_path.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore + + @distributed_trace + def post_with_constant_in_body( + self, + body=None, # type: Optional["_models.Product"] + **kwargs # type: Any + ): + # type: (...) -> "_models.Product" + """post_with_constant_in_body. + + :param body: + :type body: ~validation.models.Product + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Product, or the result of cls(response) + :rtype: ~validation.models.Product + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Product"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] + + if body is not None: + json = self._serialize.body(body, "Product") + else: + json = None + + request = rest.build_post_with_constant_in_body_request( + content_type=content_type, + json=json, + template_url=self.post_with_constant_in_body.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Product", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + post_with_constant_in_body.metadata = {"url": "/validation/constantsInPath/{constantParam}/value"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/setup.py new file mode 100644 index 00000000000..f66bb3ada67 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/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 = "autorestswaggerbatxmlservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATXMLService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATXMLService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_auto_rest_swagger_batxml_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_auto_rest_swagger_batxml_service.py new file mode 100644 index 00000000000..f6d84a09bd8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_auto_rest_swagger_batxml_service.py @@ -0,0 +1,96 @@ +# 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 AutoRestSwaggerBATXMLServiceConfiguration +from .operations import XmlOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATXMLService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar xml: XmlOperations operations + :vartype xml: xmlservice.operations.XmlOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATXMLServiceConfiguration(**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.xml = XmlOperations(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. + + We have helper methods to create requests specific to this service in `xmlservice.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmlservice._rest import xml + >>> request = xml.build_get_complex_type_ref_no_meta_request(**kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATXMLService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_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/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/__init__.py new file mode 100644 index 00000000000..b64de561abc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/__init__.py @@ -0,0 +1,115 @@ +# 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_get_complex_type_ref_no_meta_request + from ._request_builders_py3 import build_put_complex_type_ref_no_meta_request + from ._request_builders_py3 import build_get_complex_type_ref_with_meta_request + from ._request_builders_py3 import build_put_complex_type_ref_with_meta_request + from ._request_builders_py3 import build_get_simple_request + from ._request_builders_py3 import build_put_simple_request + from ._request_builders_py3 import build_get_wrapped_lists_request + from ._request_builders_py3 import build_put_wrapped_lists_request + from ._request_builders_py3 import build_get_headers_request + from ._request_builders_py3 import build_get_empty_list_request + from ._request_builders_py3 import build_put_empty_list_request + from ._request_builders_py3 import build_get_empty_wrapped_lists_request + from ._request_builders_py3 import build_put_empty_wrapped_lists_request + from ._request_builders_py3 import build_get_root_list_request + from ._request_builders_py3 import build_put_root_list_request + from ._request_builders_py3 import build_get_root_list_single_item_request + from ._request_builders_py3 import build_put_root_list_single_item_request + from ._request_builders_py3 import build_get_empty_root_list_request + from ._request_builders_py3 import build_put_empty_root_list_request + from ._request_builders_py3 import build_get_empty_child_element_request + from ._request_builders_py3 import build_put_empty_child_element_request + from ._request_builders_py3 import build_list_containers_request + from ._request_builders_py3 import build_get_service_properties_request + from ._request_builders_py3 import build_put_service_properties_request + from ._request_builders_py3 import build_get_acls_request + from ._request_builders_py3 import build_put_acls_request + from ._request_builders_py3 import build_list_blobs_request + from ._request_builders_py3 import build_json_input_request + from ._request_builders_py3 import build_json_output_request + from ._request_builders_py3 import build_get_xms_text_request + from ._request_builders_py3 import build_get_bytes_request + from ._request_builders_py3 import build_put_binary_request + from ._request_builders_py3 import build_get_uri_request + from ._request_builders_py3 import build_put_uri_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_complex_type_ref_no_meta_request # type: ignore + from ._request_builders import build_put_complex_type_ref_no_meta_request # type: ignore + from ._request_builders import build_get_complex_type_ref_with_meta_request # type: ignore + from ._request_builders import build_put_complex_type_ref_with_meta_request # type: ignore + from ._request_builders import build_get_simple_request # type: ignore + from ._request_builders import build_put_simple_request # type: ignore + from ._request_builders import build_get_wrapped_lists_request # type: ignore + from ._request_builders import build_put_wrapped_lists_request # type: ignore + from ._request_builders import build_get_headers_request # type: ignore + from ._request_builders import build_get_empty_list_request # type: ignore + from ._request_builders import build_put_empty_list_request # type: ignore + from ._request_builders import build_get_empty_wrapped_lists_request # type: ignore + from ._request_builders import build_put_empty_wrapped_lists_request # type: ignore + from ._request_builders import build_get_root_list_request # type: ignore + from ._request_builders import build_put_root_list_request # type: ignore + from ._request_builders import build_get_root_list_single_item_request # type: ignore + from ._request_builders import build_put_root_list_single_item_request # type: ignore + from ._request_builders import build_get_empty_root_list_request # type: ignore + from ._request_builders import build_put_empty_root_list_request # type: ignore + from ._request_builders import build_get_empty_child_element_request # type: ignore + from ._request_builders import build_put_empty_child_element_request # type: ignore + from ._request_builders import build_list_containers_request # type: ignore + from ._request_builders import build_get_service_properties_request # type: ignore + from ._request_builders import build_put_service_properties_request # type: ignore + from ._request_builders import build_get_acls_request # type: ignore + from ._request_builders import build_put_acls_request # type: ignore + from ._request_builders import build_list_blobs_request # type: ignore + from ._request_builders import build_json_input_request # type: ignore + from ._request_builders import build_json_output_request # type: ignore + from ._request_builders import build_get_xms_text_request # type: ignore + from ._request_builders import build_get_bytes_request # type: ignore + from ._request_builders import build_put_binary_request # type: ignore + from ._request_builders import build_get_uri_request # type: ignore + from ._request_builders import build_put_uri_request # type: ignore + +__all__ = [ + "build_get_complex_type_ref_no_meta_request", + "build_put_complex_type_ref_no_meta_request", + "build_get_complex_type_ref_with_meta_request", + "build_put_complex_type_ref_with_meta_request", + "build_get_simple_request", + "build_put_simple_request", + "build_get_wrapped_lists_request", + "build_put_wrapped_lists_request", + "build_get_headers_request", + "build_get_empty_list_request", + "build_put_empty_list_request", + "build_get_empty_wrapped_lists_request", + "build_put_empty_wrapped_lists_request", + "build_get_root_list_request", + "build_put_root_list_request", + "build_get_root_list_single_item_request", + "build_put_root_list_single_item_request", + "build_get_empty_root_list_request", + "build_put_empty_root_list_request", + "build_get_empty_child_element_request", + "build_put_empty_child_element_request", + "build_list_containers_request", + "build_get_service_properties_request", + "build_put_service_properties_request", + "build_get_acls_request", + "build_put_acls_request", + "build_list_blobs_request", + "build_json_input_request", + "build_json_output_request", + "build_get_xms_text_request", + "build_get_bytes_request", + "build_put_binary_request", + "build_get_uri_request", + "build_put_uri_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/_request_builders.py new file mode 100644 index 00000000000..3634507c9aa --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/_request_builders.py @@ -0,0 +1,1200 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_complex_type_ref_no_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-no-meta') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_type_ref_no_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-no-meta') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_type_ref_with_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-with-meta') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_type_ref_with_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-with-meta') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_simple_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/simple') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_simple_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/simple') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/wrapped-lists') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/wrapped-lists') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_headers_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get strongly-typed response headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/xml/headers') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_empty_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-list') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-wrapped-lists') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-wrapped-lists') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_root_list_single_item_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list-single-item') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_root_list_single_item_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list-single-item') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-root-list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-root-list') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_child_element_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets an XML document with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-child-element') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_child_element_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a value with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-child-element') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_list_containers_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists containers in a storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "list" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_service_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "properties" + restype = "service" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_service_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + comp = "properties" + restype = "service" + # Construct URL + url = kwargs.pop("template_url", '/xml/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # 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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_acls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "acl" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/mycontainer') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_acls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + comp = "acl" + restype = "container" + # Construct URL + url = kwargs.pop("template_url", '/xml/mycontainer') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # 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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_blobs_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists blobs in a storage container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "list" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/mycontainer') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_json_input_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID + number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/jsoninput') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_json_output_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A Swagger with XML that has one operation that returns JSON. ID number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/xml/jsonoutput') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_xms_text_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get back an XML object with an x-ms-text property, which should translate to the returned + object's 'language' property being 'english' and its 'content' property being 'I am text'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/x-ms-text') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_bytes_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/bytes') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_binary_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/bytes') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/url') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/url') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/_request_builders_py3.py new file mode 100644 index 00000000000..a894cac9876 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_rest/xml/_request_builders_py3.py @@ -0,0 +1,922 @@ +# 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, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_complex_type_ref_no_meta_request(**kwargs: Any) -> HttpRequest: + """Get a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-no-meta") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_type_ref_no_meta_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-no-meta") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_complex_type_ref_with_meta_request(**kwargs: Any) -> HttpRequest: + """Get a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-with-meta") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_type_ref_with_meta_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-with-meta") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_simple_request(**kwargs: Any) -> HttpRequest: + """Get a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/simple") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_simple_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/simple") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_wrapped_lists_request(**kwargs: Any) -> HttpRequest: + """Get an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/wrapped-lists") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_wrapped_lists_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/wrapped-lists") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_headers_request(**kwargs: Any) -> HttpRequest: + """Get strongly-typed response headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/xml/headers") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_empty_list_request(**kwargs: Any) -> HttpRequest: + """Get an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_list_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-list") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_empty_wrapped_lists_request(**kwargs: Any) -> HttpRequest: + """Gets some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-wrapped-lists") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_wrapped_lists_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-wrapped-lists") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_root_list_request(**kwargs: Any) -> HttpRequest: + """Gets a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_root_list_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_root_list_single_item_request(**kwargs: Any) -> HttpRequest: + """Gets a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list-single-item") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_root_list_single_item_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list-single-item") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_empty_root_list_request(**kwargs: Any) -> HttpRequest: + """Gets an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-root-list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_root_list_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-root-list") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_empty_child_element_request(**kwargs: Any) -> HttpRequest: + """Gets an XML document with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-child-element") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_child_element_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a value with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-child-element") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_list_containers_request(**kwargs: Any) -> HttpRequest: + """Lists containers in a storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "list" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_service_properties_request(**kwargs: Any) -> HttpRequest: + """Gets storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "properties" + restype = "service" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_put_service_properties_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + comp = "properties" + restype = "service" + # Construct URL + url = kwargs.pop("template_url", "/xml/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # 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="PUT", url=url, params=query_parameters, headers=header_parameters, content=content, **kwargs + ) + + +def build_get_acls_request(**kwargs: Any) -> HttpRequest: + """Gets storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "acl" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/mycontainer") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_put_acls_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + comp = "acl" + restype = "container" + # Construct URL + url = kwargs.pop("template_url", "/xml/mycontainer") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # 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="PUT", url=url, params=query_parameters, headers=header_parameters, content=content, **kwargs + ) + + +def build_list_blobs_request(**kwargs: Any) -> HttpRequest: + """Lists blobs in a storage container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + comp = "list" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/mycontainer") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_json_input_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID + number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/jsoninput") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_json_output_request(**kwargs: Any) -> HttpRequest: + """A Swagger with XML that has one operation that returns JSON. ID number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/xml/jsonoutput") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_xms_text_request(**kwargs: Any) -> HttpRequest: + """Get back an XML object with an x-ms-text property, which should translate to the returned + object's 'language' property being 'english' and its 'content' property being 'I am text'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/x-ms-text") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_bytes_request(**kwargs: Any) -> HttpRequest: + """Get an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/bytes") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_binary_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/bytes") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_uri_request(**kwargs: Any) -> HttpRequest: + """Get an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/url") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_uri_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/url") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_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/Expected/AcceptanceTests/Xml/xmlservice/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/_auto_rest_swagger_batxml_service.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/_auto_rest_swagger_batxml_service.py new file mode 100644 index 00000000000..8ffb98a9245 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/_auto_rest_swagger_batxml_service.py @@ -0,0 +1,78 @@ +# 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 AutoRestSwaggerBATXMLServiceConfiguration +from .operations import XmlOperations + + +class AutoRestSwaggerBATXMLService: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar xml: XmlOperations operations + :vartype xml: xmlservice.aio.operations.XmlOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATXMLServiceConfiguration(**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.xml = XmlOperations(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. + + We have helper methods to create requests specific to this service in `xmlservice.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmlservice._rest import xml + >>> request = xml.build_get_complex_type_ref_no_meta_request(**kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATXMLService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/_configuration.py diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py new file mode 100644 index 00000000000..4ed1b4fe876 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/aio/operations/_xml_operations.py @@ -0,0 +1,1337 @@ +# 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, List, 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 ... import models as _models +from ..._rest import xml as rest_xml + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class XmlOperations: + """XmlOperations 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: ~xmlservice.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 get_complex_type_ref_no_meta(self, **kwargs: Any) -> "_models.RootWithRefAndNoMeta": + """Get a complex type that has a ref to a complex type with no XML node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RootWithRefAndNoMeta, or the result of cls(response) + :rtype: ~xmlservice.models.RootWithRefAndNoMeta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndNoMeta"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_complex_type_ref_no_meta_request( + template_url=self.get_complex_type_ref_no_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("RootWithRefAndNoMeta", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore + + @distributed_trace_async + async def put_complex_type_ref_no_meta(self, model: "_models.RootWithRefAndNoMeta", **kwargs: Any) -> None: + """Puts a complex type that has a ref to a complex type with no XML node. + + :param model: + :type model: ~xmlservice.models.RootWithRefAndNoMeta + :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/xml") # type: Optional[str] + + content = self._serialize.body(model, "RootWithRefAndNoMeta", is_xml=True) + + request = rest_xml.build_put_complex_type_ref_no_meta_request( + content_type=content_type, + content=content, + template_url=self.put_complex_type_ref_no_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore + + @distributed_trace_async + async def get_complex_type_ref_with_meta(self, **kwargs: Any) -> "_models.RootWithRefAndMeta": + """Get a complex type that has a ref to a complex type with XML node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RootWithRefAndMeta, or the result of cls(response) + :rtype: ~xmlservice.models.RootWithRefAndMeta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndMeta"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_complex_type_ref_with_meta_request( + template_url=self.get_complex_type_ref_with_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("RootWithRefAndMeta", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore + + @distributed_trace_async + async def put_complex_type_ref_with_meta(self, model: "_models.RootWithRefAndMeta", **kwargs: Any) -> None: + """Puts a complex type that has a ref to a complex type with XML node. + + :param model: + :type model: ~xmlservice.models.RootWithRefAndMeta + :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/xml") # type: Optional[str] + + content = self._serialize.body(model, "RootWithRefAndMeta", is_xml=True) + + request = rest_xml.build_put_complex_type_ref_with_meta_request( + content_type=content_type, + content=content, + template_url=self.put_complex_type_ref_with_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore + + @distributed_trace_async + async def get_simple(self, **kwargs: Any) -> "_models.Slideshow": + """Get a simple XML document. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Slideshow, or the result of cls(response) + :rtype: ~xmlservice.models.Slideshow + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_simple_request( + template_url=self.get_simple.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Slideshow", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_simple.metadata = {"url": "/xml/simple"} # type: ignore + + @distributed_trace_async + async def put_simple(self, slideshow: "_models.Slideshow", **kwargs: Any) -> None: + """Put a simple XML document. + + :param slideshow: + :type slideshow: ~xmlservice.models.Slideshow + :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/xml") # type: Optional[str] + + content = self._serialize.body(slideshow, "Slideshow", is_xml=True) + + request = rest_xml.build_put_simple_request( + content_type=content_type, + content=content, + template_url=self.put_simple.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_simple.metadata = {"url": "/xml/simple"} # type: ignore + + @distributed_trace_async + async def get_wrapped_lists(self, **kwargs: Any) -> "_models.AppleBarrel": + """Get an XML document with multiple wrapped lists. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppleBarrel, or the result of cls(response) + :rtype: ~xmlservice.models.AppleBarrel + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_wrapped_lists_request( + template_url=self.get_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("AppleBarrel", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore + + @distributed_trace_async + async def put_wrapped_lists(self, wrapped_lists: "_models.AppleBarrel", **kwargs: Any) -> None: + """Put an XML document with multiple wrapped lists. + + :param wrapped_lists: + :type wrapped_lists: ~xmlservice.models.AppleBarrel + :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/xml") # type: Optional[str] + + content = self._serialize.body(wrapped_lists, "AppleBarrel", is_xml=True) + + request = rest_xml.build_put_wrapped_lists_request( + content_type=content_type, + content=content, + template_url=self.put_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore + + @distributed_trace_async + async def get_headers(self, **kwargs: Any) -> None: + """Get strongly-typed response headers. + + :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", {})) + + request = rest_xml.build_get_headers_request( + template_url=self.get_headers.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["Custom-Header"] = self._deserialize("str", response.headers.get("Custom-Header")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get_headers.metadata = {"url": "/xml/headers"} # type: ignore + + @distributed_trace_async + async def get_empty_list(self, **kwargs: Any) -> "_models.Slideshow": + """Get an empty list. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Slideshow, or the result of cls(response) + :rtype: ~xmlservice.models.Slideshow + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_list_request( + template_url=self.get_empty_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Slideshow", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore + + @distributed_trace_async + async def put_empty_list(self, slideshow: "_models.Slideshow", **kwargs: Any) -> None: + """Puts an empty list. + + :param slideshow: + :type slideshow: ~xmlservice.models.Slideshow + :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/xml") # type: Optional[str] + + content = self._serialize.body(slideshow, "Slideshow", is_xml=True) + + request = rest_xml.build_put_empty_list_request( + content_type=content_type, + content=content, + template_url=self.put_empty_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore + + @distributed_trace_async + async def get_empty_wrapped_lists(self, **kwargs: Any) -> "_models.AppleBarrel": + """Gets some empty wrapped lists. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppleBarrel, or the result of cls(response) + :rtype: ~xmlservice.models.AppleBarrel + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_wrapped_lists_request( + template_url=self.get_empty_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("AppleBarrel", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore + + @distributed_trace_async + async def put_empty_wrapped_lists(self, apple_barrel: "_models.AppleBarrel", **kwargs: Any) -> None: + """Puts some empty wrapped lists. + + :param apple_barrel: + :type apple_barrel: ~xmlservice.models.AppleBarrel + :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/xml") # type: Optional[str] + + content = self._serialize.body(apple_barrel, "AppleBarrel", is_xml=True) + + request = rest_xml.build_put_empty_wrapped_lists_request( + content_type=content_type, + content=content, + template_url=self.put_empty_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore + + @distributed_trace_async + async def get_root_list(self, **kwargs: Any) -> List["_models.Banana"]: + """Gets a list as the root element. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Banana, or the result of cls(response) + :rtype: list[~xmlservice.models.Banana] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_root_list_request( + template_url=self.get_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[Banana]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root_list.metadata = {"url": "/xml/root-list"} # type: ignore + + @distributed_trace_async + async def put_root_list(self, bananas: List["_models.Banana"], **kwargs: Any) -> None: + """Puts a list as the root element. + + :param bananas: + :type bananas: list[~xmlservice.models.Banana] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} + content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) + + request = rest_xml.build_put_root_list_request( + content_type=content_type, + content=content, + template_url=self.put_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_root_list.metadata = {"url": "/xml/root-list"} # type: ignore + + @distributed_trace_async + async def get_root_list_single_item(self, **kwargs: Any) -> List["_models.Banana"]: + """Gets a list with a single item. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Banana, or the result of cls(response) + :rtype: list[~xmlservice.models.Banana] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_root_list_single_item_request( + template_url=self.get_root_list_single_item.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[Banana]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore + + @distributed_trace_async + async def put_root_list_single_item(self, bananas: List["_models.Banana"], **kwargs: Any) -> None: + """Puts a list with a single item. + + :param bananas: + :type bananas: list[~xmlservice.models.Banana] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} + content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) + + request = rest_xml.build_put_root_list_single_item_request( + content_type=content_type, + content=content, + template_url=self.put_root_list_single_item.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore + + @distributed_trace_async + async def get_empty_root_list(self, **kwargs: Any) -> List["_models.Banana"]: + """Gets an empty list as the root element. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Banana, or the result of cls(response) + :rtype: list[~xmlservice.models.Banana] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_root_list_request( + template_url=self.get_empty_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[Banana]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore + + @distributed_trace_async + async def put_empty_root_list(self, bananas: List["_models.Banana"], **kwargs: Any) -> None: + """Puts an empty list as the root element. + + :param bananas: + :type bananas: list[~xmlservice.models.Banana] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} + content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) + + request = rest_xml.build_put_empty_root_list_request( + content_type=content_type, + content=content, + template_url=self.put_empty_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore + + @distributed_trace_async + async def get_empty_child_element(self, **kwargs: Any) -> "_models.Banana": + """Gets an XML document with an empty child element. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Banana, or the result of cls(response) + :rtype: ~xmlservice.models.Banana + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Banana"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_child_element_request( + template_url=self.get_empty_child_element.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Banana", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore + + @distributed_trace_async + async def put_empty_child_element(self, banana: "_models.Banana", **kwargs: Any) -> None: + """Puts a value with an empty child element. + + :param banana: + :type banana: ~xmlservice.models.Banana + :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/xml") # type: Optional[str] + + content = self._serialize.body(banana, "Banana", is_xml=True) + + request = rest_xml.build_put_empty_child_element_request( + content_type=content_type, + content=content, + template_url=self.put_empty_child_element.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore + + @distributed_trace_async + async def list_containers(self, **kwargs: Any) -> "_models.ListContainersResponse": + """Lists containers in a storage account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListContainersResponse, or the result of cls(response) + :rtype: ~xmlservice.models.ListContainersResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ListContainersResponse"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_list_containers_request( + template_url=self.list_containers.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ListContainersResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_containers.metadata = {"url": "/xml/"} # type: ignore + + @distributed_trace_async + async def get_service_properties(self, **kwargs: Any) -> "_models.StorageServiceProperties": + """Gets storage service properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageServiceProperties, or the result of cls(response) + :rtype: ~xmlservice.models.StorageServiceProperties + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageServiceProperties"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_service_properties_request( + template_url=self.get_service_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("StorageServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/xml/"} # type: ignore + + @distributed_trace_async + async def put_service_properties(self, properties: "_models.StorageServiceProperties", **kwargs: Any) -> None: + """Puts storage service properties. + + :param properties: + :type properties: ~xmlservice.models.StorageServiceProperties + :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/xml") # type: Optional[str] + + content = self._serialize.body(properties, "StorageServiceProperties", is_xml=True) + + request = rest_xml.build_put_service_properties_request( + content_type=content_type, + content=content, + template_url=self.put_service_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_service_properties.metadata = {"url": "/xml/"} # type: ignore + + @distributed_trace_async + async def get_acls(self, **kwargs: Any) -> List["_models.SignedIdentifier"]: + """Gets storage ACLs for a container. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of SignedIdentifier, or the result of cls(response) + :rtype: list[~xmlservice.models.SignedIdentifier] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.SignedIdentifier"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_acls_request( + template_url=self.get_acls.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[SignedIdentifier]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore + + @distributed_trace_async + async def put_acls(self, properties: List["_models.SignedIdentifier"], **kwargs: Any) -> None: + """Puts storage ACLs for a container. + + :param properties: + :type properties: list[~xmlservice.models.SignedIdentifier] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "SignedIdentifiers", "wrapped": True, "itemsName": "SignedIdentifier"}} + content = self._serialize.body( + properties, "[SignedIdentifier]", is_xml=True, serialization_ctxt=serialization_ctxt + ) + + request = rest_xml.build_put_acls_request( + content_type=content_type, + content=content, + template_url=self.put_acls.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore + + @distributed_trace_async + async def list_blobs(self, **kwargs: Any) -> "_models.ListBlobsResponse": + """Lists blobs in a storage container. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListBlobsResponse, or the result of cls(response) + :rtype: ~xmlservice.models.ListBlobsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ListBlobsResponse"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_list_blobs_request( + template_url=self.list_blobs.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ListBlobsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_blobs.metadata = {"url": "/xml/mycontainer"} # type: ignore + + @distributed_trace_async + async def json_input(self, id: Optional[int] = None, **kwargs: Any) -> None: + """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID + number 42. + + :param id: + :type id: int + :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/json") # type: Optional[str] + + _properties = _models.JSONInput(id=id) + json = self._serialize.body(_properties, "JSONInput") + + request = rest_xml.build_json_input_request( + content_type=content_type, + json=json, + template_url=self.json_input.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + json_input.metadata = {"url": "/xml/jsoninput"} # type: ignore + + @distributed_trace_async + async def json_output(self, **kwargs: Any) -> "_models.JSONOutput": + """A Swagger with XML that has one operation that returns JSON. ID number 42. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JSONOutput, or the result of cls(response) + :rtype: ~xmlservice.models.JSONOutput + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.JSONOutput"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_json_output_request( + template_url=self.json_output.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("JSONOutput", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + json_output.metadata = {"url": "/xml/jsonoutput"} # type: ignore + + @distributed_trace_async + async def get_xms_text(self, **kwargs: Any) -> "_models.ObjectWithXMsTextProperty": + """Get back an XML object with an x-ms-text property, which should translate to the returned + object's 'language' property being 'english' and its 'content' property being 'I am text'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectWithXMsTextProperty, or the result of cls(response) + :rtype: ~xmlservice.models.ObjectWithXMsTextProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ObjectWithXMsTextProperty"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_xms_text_request( + template_url=self.get_xms_text.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ObjectWithXMsTextProperty", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_xms_text.metadata = {"url": "/xml/x-ms-text"} # type: ignore + + @distributed_trace_async + async def get_bytes(self, **kwargs: Any) -> "_models.ModelWithByteProperty": + """Get an XML document with binary property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ModelWithByteProperty, or the result of cls(response) + :rtype: ~xmlservice.models.ModelWithByteProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithByteProperty"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_bytes_request( + template_url=self.get_bytes.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ModelWithByteProperty", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_bytes.metadata = {"url": "/xml/bytes"} # type: ignore + + @distributed_trace_async + async def put_binary(self, bytes: Optional[bytearray] = None, **kwargs: Any) -> None: + """Put an XML document with binary property. + + :param bytes: + :type bytes: bytearray + :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/xml") # type: Optional[str] + + _slideshow = _models.ModelWithByteProperty(bytes=bytes) + content = self._serialize.body(_slideshow, "ModelWithByteProperty", is_xml=True) + + request = rest_xml.build_put_binary_request( + content_type=content_type, + content=content, + template_url=self.put_binary.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_binary.metadata = {"url": "/xml/bytes"} # type: ignore + + @distributed_trace_async + async def get_uri(self, **kwargs: Any) -> "_models.ModelWithUrlProperty": + """Get an XML document with uri property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ModelWithUrlProperty, or the result of cls(response) + :rtype: ~xmlservice.models.ModelWithUrlProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithUrlProperty"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_uri_request( + template_url=self.get_uri.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ModelWithUrlProperty", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uri.metadata = {"url": "/xml/url"} # type: ignore + + @distributed_trace_async + async def put_uri(self, url: Optional[str] = None, **kwargs: Any) -> None: + """Put an XML document with uri property. + + :param url: + :type url: 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/xml") # type: Optional[str] + + _model = _models.ModelWithUrlProperty(url=url) + content = self._serialize.body(_model, "ModelWithUrlProperty", is_xml=True) + + request = rest_xml.build_put_uri_request( + content_type=content_type, + content=content, + template_url=self.put_uri.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_uri.metadata = {"url": "/xml/url"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/_auto_rest_swagger_batxml_service_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/_auto_rest_swagger_batxml_service_enums.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/_auto_rest_swagger_batxml_service_enums.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/_auto_rest_swagger_batxml_service_enums.py diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/Xml/xmlservice/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py new file mode 100644 index 00000000000..6c298b71141 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/operations/_xml_operations.py @@ -0,0 +1,1405 @@ +# 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 .. import models as _models +from .._rest import xml as rest_xml + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class XmlOperations(object): + """XmlOperations 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: ~xmlservice.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 get_complex_type_ref_no_meta( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.RootWithRefAndNoMeta" + """Get a complex type that has a ref to a complex type with no XML node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RootWithRefAndNoMeta, or the result of cls(response) + :rtype: ~xmlservice.models.RootWithRefAndNoMeta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndNoMeta"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_complex_type_ref_no_meta_request( + template_url=self.get_complex_type_ref_no_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("RootWithRefAndNoMeta", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore + + @distributed_trace + def put_complex_type_ref_no_meta( + self, + model, # type: "_models.RootWithRefAndNoMeta" + **kwargs # type: Any + ): + # type: (...) -> None + """Puts a complex type that has a ref to a complex type with no XML node. + + :param model: + :type model: ~xmlservice.models.RootWithRefAndNoMeta + :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/xml") # type: Optional[str] + + content = self._serialize.body(model, "RootWithRefAndNoMeta", is_xml=True) + + request = rest_xml.build_put_complex_type_ref_no_meta_request( + content_type=content_type, + content=content, + template_url=self.put_complex_type_ref_no_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_type_ref_no_meta.metadata = {"url": "/xml/complex-type-ref-no-meta"} # type: ignore + + @distributed_trace + def get_complex_type_ref_with_meta( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.RootWithRefAndMeta" + """Get a complex type that has a ref to a complex type with XML node. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RootWithRefAndMeta, or the result of cls(response) + :rtype: ~xmlservice.models.RootWithRefAndMeta + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.RootWithRefAndMeta"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_complex_type_ref_with_meta_request( + template_url=self.get_complex_type_ref_with_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("RootWithRefAndMeta", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore + + @distributed_trace + def put_complex_type_ref_with_meta( + self, + model, # type: "_models.RootWithRefAndMeta" + **kwargs # type: Any + ): + # type: (...) -> None + """Puts a complex type that has a ref to a complex type with XML node. + + :param model: + :type model: ~xmlservice.models.RootWithRefAndMeta + :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/xml") # type: Optional[str] + + content = self._serialize.body(model, "RootWithRefAndMeta", is_xml=True) + + request = rest_xml.build_put_complex_type_ref_with_meta_request( + content_type=content_type, + content=content, + template_url=self.put_complex_type_ref_with_meta.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_complex_type_ref_with_meta.metadata = {"url": "/xml/complex-type-ref-with-meta"} # type: ignore + + @distributed_trace + def get_simple( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Slideshow" + """Get a simple XML document. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Slideshow, or the result of cls(response) + :rtype: ~xmlservice.models.Slideshow + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_simple_request( + template_url=self.get_simple.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("Slideshow", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_simple.metadata = {"url": "/xml/simple"} # type: ignore + + @distributed_trace + def put_simple( + self, + slideshow, # type: "_models.Slideshow" + **kwargs # type: Any + ): + # type: (...) -> None + """Put a simple XML document. + + :param slideshow: + :type slideshow: ~xmlservice.models.Slideshow + :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/xml") # type: Optional[str] + + content = self._serialize.body(slideshow, "Slideshow", is_xml=True) + + request = rest_xml.build_put_simple_request( + content_type=content_type, + content=content, + template_url=self.put_simple.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_simple.metadata = {"url": "/xml/simple"} # type: ignore + + @distributed_trace + def get_wrapped_lists( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.AppleBarrel" + """Get an XML document with multiple wrapped lists. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppleBarrel, or the result of cls(response) + :rtype: ~xmlservice.models.AppleBarrel + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_wrapped_lists_request( + template_url=self.get_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("AppleBarrel", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore + + @distributed_trace + def put_wrapped_lists( + self, + wrapped_lists, # type: "_models.AppleBarrel" + **kwargs # type: Any + ): + # type: (...) -> None + """Put an XML document with multiple wrapped lists. + + :param wrapped_lists: + :type wrapped_lists: ~xmlservice.models.AppleBarrel + :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/xml") # type: Optional[str] + + content = self._serialize.body(wrapped_lists, "AppleBarrel", is_xml=True) + + request = rest_xml.build_put_wrapped_lists_request( + content_type=content_type, + content=content, + template_url=self.put_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_wrapped_lists.metadata = {"url": "/xml/wrapped-lists"} # type: ignore + + @distributed_trace + def get_headers( + self, **kwargs # type: Any + ): + # type: (...) -> None + """Get strongly-typed response headers. + + :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", {})) + + request = rest_xml.build_get_headers_request( + template_url=self.get_headers.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["Custom-Header"] = self._deserialize("str", response.headers.get("Custom-Header")) + + if cls: + return cls(pipeline_response, None, response_headers) + + get_headers.metadata = {"url": "/xml/headers"} # type: ignore + + @distributed_trace + def get_empty_list( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Slideshow" + """Get an empty list. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Slideshow, or the result of cls(response) + :rtype: ~xmlservice.models.Slideshow + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Slideshow"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_list_request( + template_url=self.get_empty_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Slideshow", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore + + @distributed_trace + def put_empty_list( + self, + slideshow, # type: "_models.Slideshow" + **kwargs # type: Any + ): + # type: (...) -> None + """Puts an empty list. + + :param slideshow: + :type slideshow: ~xmlservice.models.Slideshow + :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/xml") # type: Optional[str] + + content = self._serialize.body(slideshow, "Slideshow", is_xml=True) + + request = rest_xml.build_put_empty_list_request( + content_type=content_type, + content=content, + template_url=self.put_empty_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_list.metadata = {"url": "/xml/empty-list"} # type: ignore + + @distributed_trace + def get_empty_wrapped_lists( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.AppleBarrel" + """Gets some empty wrapped lists. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppleBarrel, or the result of cls(response) + :rtype: ~xmlservice.models.AppleBarrel + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.AppleBarrel"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_wrapped_lists_request( + template_url=self.get_empty_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("AppleBarrel", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore + + @distributed_trace + def put_empty_wrapped_lists( + self, + apple_barrel, # type: "_models.AppleBarrel" + **kwargs # type: Any + ): + # type: (...) -> None + """Puts some empty wrapped lists. + + :param apple_barrel: + :type apple_barrel: ~xmlservice.models.AppleBarrel + :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/xml") # type: Optional[str] + + content = self._serialize.body(apple_barrel, "AppleBarrel", is_xml=True) + + request = rest_xml.build_put_empty_wrapped_lists_request( + content_type=content_type, + content=content, + template_url=self.put_empty_wrapped_lists.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_wrapped_lists.metadata = {"url": "/xml/empty-wrapped-lists"} # type: ignore + + @distributed_trace + def get_root_list( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Banana"] + """Gets a list as the root element. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Banana, or the result of cls(response) + :rtype: list[~xmlservice.models.Banana] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_root_list_request( + template_url=self.get_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[Banana]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root_list.metadata = {"url": "/xml/root-list"} # type: ignore + + @distributed_trace + def put_root_list( + self, + bananas, # type: List["_models.Banana"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts a list as the root element. + + :param bananas: + :type bananas: list[~xmlservice.models.Banana] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} + content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) + + request = rest_xml.build_put_root_list_request( + content_type=content_type, + content=content, + template_url=self.put_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_root_list.metadata = {"url": "/xml/root-list"} # type: ignore + + @distributed_trace + def get_root_list_single_item( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Banana"] + """Gets a list with a single item. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Banana, or the result of cls(response) + :rtype: list[~xmlservice.models.Banana] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_root_list_single_item_request( + template_url=self.get_root_list_single_item.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[Banana]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore + + @distributed_trace + def put_root_list_single_item( + self, + bananas, # type: List["_models.Banana"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts a list with a single item. + + :param bananas: + :type bananas: list[~xmlservice.models.Banana] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} + content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) + + request = rest_xml.build_put_root_list_single_item_request( + content_type=content_type, + content=content, + template_url=self.put_root_list_single_item.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_root_list_single_item.metadata = {"url": "/xml/root-list-single-item"} # type: ignore + + @distributed_trace + def get_empty_root_list( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.Banana"] + """Gets an empty list as the root element. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Banana, or the result of cls(response) + :rtype: list[~xmlservice.models.Banana] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.Banana"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_root_list_request( + template_url=self.get_empty_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[Banana]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore + + @distributed_trace + def put_empty_root_list( + self, + bananas, # type: List["_models.Banana"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts an empty list as the root element. + + :param bananas: + :type bananas: list[~xmlservice.models.Banana] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "bananas", "wrapped": True, "itemsName": "banana"}} + content = self._serialize.body(bananas, "[Banana]", is_xml=True, serialization_ctxt=serialization_ctxt) + + request = rest_xml.build_put_empty_root_list_request( + content_type=content_type, + content=content, + template_url=self.put_empty_root_list.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_root_list.metadata = {"url": "/xml/empty-root-list"} # type: ignore + + @distributed_trace + def get_empty_child_element( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.Banana" + """Gets an XML document with an empty child element. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Banana, or the result of cls(response) + :rtype: ~xmlservice.models.Banana + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.Banana"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_empty_child_element_request( + template_url=self.get_empty_child_element.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("Banana", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore + + @distributed_trace + def put_empty_child_element( + self, + banana, # type: "_models.Banana" + **kwargs # type: Any + ): + # type: (...) -> None + """Puts a value with an empty child element. + + :param banana: + :type banana: ~xmlservice.models.Banana + :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/xml") # type: Optional[str] + + content = self._serialize.body(banana, "Banana", is_xml=True) + + request = rest_xml.build_put_empty_child_element_request( + content_type=content_type, + content=content, + template_url=self.put_empty_child_element.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_empty_child_element.metadata = {"url": "/xml/empty-child-element"} # type: ignore + + @distributed_trace + def list_containers( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ListContainersResponse" + """Lists containers in a storage account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListContainersResponse, or the result of cls(response) + :rtype: ~xmlservice.models.ListContainersResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ListContainersResponse"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_list_containers_request( + template_url=self.list_containers.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ListContainersResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_containers.metadata = {"url": "/xml/"} # type: ignore + + @distributed_trace + def get_service_properties( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.StorageServiceProperties" + """Gets storage service properties. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageServiceProperties, or the result of cls(response) + :rtype: ~xmlservice.models.StorageServiceProperties + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.StorageServiceProperties"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_service_properties_request( + template_url=self.get_service_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("StorageServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/xml/"} # type: ignore + + @distributed_trace + def put_service_properties( + self, + properties, # type: "_models.StorageServiceProperties" + **kwargs # type: Any + ): + # type: (...) -> None + """Puts storage service properties. + + :param properties: + :type properties: ~xmlservice.models.StorageServiceProperties + :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/xml") # type: Optional[str] + + content = self._serialize.body(properties, "StorageServiceProperties", is_xml=True) + + request = rest_xml.build_put_service_properties_request( + content_type=content_type, + content=content, + template_url=self.put_service_properties.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_service_properties.metadata = {"url": "/xml/"} # type: ignore + + @distributed_trace + def get_acls( + self, **kwargs # type: Any + ): + # type: (...) -> List["_models.SignedIdentifier"] + """Gets storage ACLs for a container. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of SignedIdentifier, or the result of cls(response) + :rtype: list[~xmlservice.models.SignedIdentifier] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[List["_models.SignedIdentifier"]] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_acls_request( + template_url=self.get_acls.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("[SignedIdentifier]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore + + @distributed_trace + def put_acls( + self, + properties, # type: List["_models.SignedIdentifier"] + **kwargs # type: Any + ): + # type: (...) -> None + """Puts storage ACLs for a container. + + :param properties: + :type properties: list[~xmlservice.models.SignedIdentifier] + :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/xml") # type: Optional[str] + + serialization_ctxt = {"xml": {"name": "SignedIdentifiers", "wrapped": True, "itemsName": "SignedIdentifier"}} + content = self._serialize.body( + properties, "[SignedIdentifier]", is_xml=True, serialization_ctxt=serialization_ctxt + ) + + request = rest_xml.build_put_acls_request( + content_type=content_type, + content=content, + template_url=self.put_acls.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_acls.metadata = {"url": "/xml/mycontainer"} # type: ignore + + @distributed_trace + def list_blobs( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ListBlobsResponse" + """Lists blobs in a storage container. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListBlobsResponse, or the result of cls(response) + :rtype: ~xmlservice.models.ListBlobsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ListBlobsResponse"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_list_blobs_request( + template_url=self.list_blobs.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ListBlobsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_blobs.metadata = {"url": "/xml/mycontainer"} # type: ignore + + @distributed_trace + def json_input( + self, + id=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID + number 42. + + :param id: + :type id: int + :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/json") # type: Optional[str] + + _properties = _models.JSONInput(id=id) + json = self._serialize.body(_properties, "JSONInput") + + request = rest_xml.build_json_input_request( + content_type=content_type, + json=json, + template_url=self.json_input.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + json_input.metadata = {"url": "/xml/jsoninput"} # type: ignore + + @distributed_trace + def json_output( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.JSONOutput" + """A Swagger with XML that has one operation that returns JSON. ID number 42. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JSONOutput, or the result of cls(response) + :rtype: ~xmlservice.models.JSONOutput + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.JSONOutput"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_json_output_request( + template_url=self.json_output.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("JSONOutput", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + json_output.metadata = {"url": "/xml/jsonoutput"} # type: ignore + + @distributed_trace + def get_xms_text( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ObjectWithXMsTextProperty" + """Get back an XML object with an x-ms-text property, which should translate to the returned + object's 'language' property being 'english' and its 'content' property being 'I am text'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectWithXMsTextProperty, or the result of cls(response) + :rtype: ~xmlservice.models.ObjectWithXMsTextProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ObjectWithXMsTextProperty"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_xms_text_request( + template_url=self.get_xms_text.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("ObjectWithXMsTextProperty", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_xms_text.metadata = {"url": "/xml/x-ms-text"} # type: ignore + + @distributed_trace + def get_bytes( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ModelWithByteProperty" + """Get an XML document with binary property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ModelWithByteProperty, or the result of cls(response) + :rtype: ~xmlservice.models.ModelWithByteProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithByteProperty"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_bytes_request( + template_url=self.get_bytes.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ModelWithByteProperty", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_bytes.metadata = {"url": "/xml/bytes"} # type: ignore + + @distributed_trace + def put_binary( + self, + bytes=None, # type: Optional[bytearray] + **kwargs # type: Any + ): + # type: (...) -> None + """Put an XML document with binary property. + + :param bytes: + :type bytes: bytearray + :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/xml") # type: Optional[str] + + _slideshow = _models.ModelWithByteProperty(bytes=bytes) + content = self._serialize.body(_slideshow, "ModelWithByteProperty", is_xml=True) + + request = rest_xml.build_put_binary_request( + content_type=content_type, + content=content, + template_url=self.put_binary.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_binary.metadata = {"url": "/xml/bytes"} # type: ignore + + @distributed_trace + def get_uri( + self, **kwargs # type: Any + ): + # type: (...) -> "_models.ModelWithUrlProperty" + """Get an XML document with uri property. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ModelWithUrlProperty, or the result of cls(response) + :rtype: ~xmlservice.models.ModelWithUrlProperty + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.ModelWithUrlProperty"] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + request = rest_xml.build_get_uri_request( + template_url=self.get_uri.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("ModelWithUrlProperty", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_uri.metadata = {"url": "/xml/url"} # type: ignore + + @distributed_trace + def put_uri( + self, + url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Put an XML document with uri property. + + :param url: + :type url: 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/xml") # type: Optional[str] + + _model = _models.ModelWithUrlProperty(url=url) + content = self._serialize.body(_model, "ModelWithUrlProperty", is_xml=True) + + request = rest_xml.build_put_uri_request( + content_type=content_type, + content=content, + template_url=self.put_uri.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + put_uri.metadata = {"url": "/xml/url"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/setup.py new file mode 100644 index 00000000000..be1b940b1a8 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/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 = "xmserrorresponseextensions" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="XMSErrorResponseExtensions", + author_email="", + url="", + keywords=["Swagger", "XMSErrorResponseExtensions"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + XMS Error Response Extensions. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_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/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/__init__.py new file mode 100644 index 00000000000..108280ab605 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/__init__.py @@ -0,0 +1,22 @@ +# 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_get_pet_by_id_request + from ._request_builders_py3 import build_do_something_request + from ._request_builders_py3 import build_has_models_param_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_pet_by_id_request # type: ignore + from ._request_builders import build_do_something_request # type: ignore + from ._request_builders import build_has_models_param_request # type: ignore + +__all__ = [ + "build_get_pet_by_id_request", + "build_do_something_request", + "build_has_models_param_request", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/_request_builders.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/_request_builders.py new file mode 100644 index 00000000000..d01d83ec1d7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/_request_builders.py @@ -0,0 +1,138 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_pet_by_id_request( + pet_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets pets by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: pet id. + :type pet_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/errorStatusCodes/Pets/{petId}/GetPet') + path_format_arguments = { + 'petId': _SERIALIZER.url("pet_id", pet_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_do_something_request( + what_action, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Asks pet to do something. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param what_action: what action the pet should do. + :type what_action: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/errorStatusCodes/Pets/doSomething/{whatAction}') + path_format_arguments = { + 'whatAction': _SERIALIZER.url("what_action", what_action, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_has_models_param_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't + conflict with the input param name 'models'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword models: Make sure model deserialization doesn't conflict with this param name, which + has input name 'models'. Use client default value in call. + :paramtype models: str + :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 + """ + + models = kwargs.pop('models', "value1") # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/errorStatusCodes/Pets/hasModelsParam') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if models is not None: + query_parameters['models'] = _SERIALIZER.query("models", models, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/_request_builders_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/_request_builders_py3.py new file mode 100644 index 00000000000..2375f54326e --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_rest/pet/_request_builders_py3.py @@ -0,0 +1,104 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_pet_by_id_request(pet_id: str, **kwargs: Any) -> HttpRequest: + """Gets pets by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: pet id. + :type pet_id: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/errorStatusCodes/Pets/{petId}/GetPet") + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_do_something_request(what_action: str, **kwargs: Any) -> HttpRequest: + """Asks pet to do something. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param what_action: what action the pet should do. + :type what_action: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/errorStatusCodes/Pets/doSomething/{whatAction}") + path_format_arguments = { + "whatAction": _SERIALIZER.url("what_action", what_action, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_has_models_param_request(*, models: Optional[str] = "value1", **kwargs: Any) -> HttpRequest: + """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't + conflict with the input param name 'models'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword models: Make sure model deserialization doesn't conflict with this param name, which + has input name 'models'. Use client default value in call. + :paramtype models: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/errorStatusCodes/Pets/hasModelsParam") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if models is not None: + query_parameters["models"] = _SERIALIZER.query("models", models, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_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/XmsErrorResponse/xmserrorresponse/_xms_error_response_extensions.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_xms_error_response_extensions.py new file mode 100644 index 00000000000..d5e966b8a3d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_xms_error_response_extensions.py @@ -0,0 +1,96 @@ +# 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 XMSErrorResponseExtensionsConfiguration +from .operations import PetOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class XMSErrorResponseExtensions(object): + """XMS Error Response Extensions. + + :ivar pet: PetOperations operations + :vartype pet: xmserrorresponse.operations.PetOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost" + self._config = XMSErrorResponseExtensionsConfiguration(**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.pet = PetOperations(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. + + We have helper methods to create requests specific to this service in `xmserrorresponse.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmserrorresponse._rest import pet + >>> request = pet.build_get_pet_by_id_request(pet_id, **kwargs) + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> XMSErrorResponseExtensions + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_configuration.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_configuration.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_configuration.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_xms_error_response_extensions.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_xms_error_response_extensions.py new file mode 100644 index 00000000000..f5fe691f10d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/_xms_error_response_extensions.py @@ -0,0 +1,78 @@ +# 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 XMSErrorResponseExtensionsConfiguration +from .operations import PetOperations + + +class XMSErrorResponseExtensions: + """XMS Error Response Extensions. + + :ivar pet: PetOperations operations + :vartype pet: xmserrorresponse.aio.operations.PetOperations + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost" + self._config = XMSErrorResponseExtensionsConfiguration(**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.pet = PetOperations(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. + + We have helper methods to create requests specific to this service in `xmserrorresponse.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmserrorresponse._rest import pet + >>> request = pet.build_get_pet_by_id_request(pet_id, **kwargs) + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "XMSErrorResponseExtensions": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py new file mode 100644 index 00000000000..2ead507eb22 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations/_pet_operations.py @@ -0,0 +1,192 @@ +# 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 ... import models as _models +from ..._rest import pet as rest_pet + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PetOperations: + """PetOperations 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: ~xmserrorresponse.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 get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional["_models.Pet"]: + """Gets pets by id. + + :param pet_id: pet id. + :type pet_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~xmserrorresponse.models.Pet or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Pet"]] + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 400: HttpResponseError, + 404: lambda response: ResourceNotFoundError( + response=response, model=self._deserialize(_models.NotFoundErrorBase, response) + ), + 501: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_get_pet_by_id_request( + pet_id=pet_id, + template_url=self.get_pet_by_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_pet_by_id.metadata = {"url": "/errorStatusCodes/Pets/{petId}/GetPet"} # type: ignore + + @distributed_trace_async + async def do_something(self, what_action: str, **kwargs: Any) -> "_models.PetAction": + """Asks pet to do something. + + :param what_action: what action the pet should do. + :type what_action: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAction, or the result of cls(response) + :rtype: ~xmserrorresponse.models.PetAction + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAction"] + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 500: lambda response: HttpResponseError( + response=response, model=self._deserialize(_models.PetActionError, response) + ), + } + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_do_something_request( + what_action=what_action, + template_url=self.do_something.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + do_something.metadata = {"url": "/errorStatusCodes/Pets/doSomething/{whatAction}"} # type: ignore + + @distributed_trace_async + async def has_models_param(self, models: Optional[str] = "value1", **kwargs: Any) -> None: + """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't + conflict with the input param name 'models'. + + :param models: Make sure model deserialization doesn't conflict with this param name, which has + input name 'models'. Use client default value in call. + :type models: 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, + 500: lambda response: HttpResponseError( + response=response, model=self._deserialize(_models.PetActionError, response) + ), + } + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_has_models_param_request( + models=models, + template_url=self.has_models_param.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client.send_request( + request, stream=False, _return_pipeline_response=True, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + has_models_param.metadata = {"url": "/errorStatusCodes/Pets/hasModelsParam"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/__init__.py diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models.py diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/models/_models_py3.py diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/__init__.py similarity index 100% rename from test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/__init__.py rename to test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/__init__.py diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py new file mode 100644 index 00000000000..452cdd1657d --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py @@ -0,0 +1,205 @@ +# 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 .. import models as _models +from .._rest import pet as rest_pet + +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]] + + +class PetOperations(object): + """PetOperations 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: ~xmserrorresponse.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 get_pet_by_id( + self, + pet_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.Pet"] + """Gets pets by id. + + :param pet_id: pet id. + :type pet_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pet, or the result of cls(response) + :rtype: ~xmserrorresponse.models.Pet or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.Pet"]] + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 400: HttpResponseError, + 404: lambda response: ResourceNotFoundError( + response=response, model=self._deserialize(_models.NotFoundErrorBase, response) + ), + 501: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_get_pet_by_id_request( + pet_id=pet_id, + template_url=self.get_pet_by_id.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Pet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_pet_by_id.metadata = {"url": "/errorStatusCodes/Pets/{petId}/GetPet"} # type: ignore + + @distributed_trace + def do_something( + self, + what_action, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PetAction" + """Asks pet to do something. + + :param what_action: what action the pet should do. + :type what_action: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PetAction, or the result of cls(response) + :rtype: ~xmserrorresponse.models.PetAction + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType["_models.PetAction"] + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 500: lambda response: HttpResponseError( + response=response, model=self._deserialize(_models.PetActionError, response) + ), + } + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_do_something_request( + what_action=what_action, + template_url=self.do_something.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("PetAction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + do_something.metadata = {"url": "/errorStatusCodes/Pets/doSomething/{whatAction}"} # type: ignore + + @distributed_trace + def has_models_param( + self, + models="value1", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't + conflict with the input param name 'models'. + + :param models: Make sure model deserialization doesn't conflict with this param name, which has + input name 'models'. Use client default value in call. + :type models: 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, + 500: lambda response: HttpResponseError( + response=response, model=self._deserialize(_models.PetActionError, response) + ), + } + error_map.update(kwargs.pop("error_map", {})) + + request = rest_pet.build_has_models_param_request( + models=models, + template_url=self.has_models_param.metadata["url"], + )._to_pipeline_transport_request() + request.url = self._client.format_url(request.url) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.PetActionError, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + has_models_param.metadata = {"url": "/errorStatusCodes/Pets/hasModelsParam"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/doc/.gitignore b/test/vanilla/legacy/doc/.gitignore similarity index 100% rename from test/vanilla/doc/.gitignore rename to test/vanilla/legacy/doc/.gitignore diff --git a/test/vanilla/doc/conf.py b/test/vanilla/legacy/doc/conf.py similarity index 100% rename from test/vanilla/doc/conf.py rename to test/vanilla/legacy/doc/conf.py diff --git a/test/vanilla/doc/index.rst b/test/vanilla/legacy/doc/index.rst similarity index 100% rename from test/vanilla/doc/index.rst rename to test/vanilla/legacy/doc/index.rst diff --git a/test/vanilla/requirements.txt b/test/vanilla/legacy/requirements.txt similarity index 100% rename from test/vanilla/requirements.txt rename to test/vanilla/legacy/requirements.txt diff --git a/test/vanilla/tox.ini b/test/vanilla/legacy/tox.ini similarity index 100% rename from test/vanilla/tox.ini rename to test/vanilla/legacy/tox.ini diff --git a/test/vanilla/low-level/AcceptanceTests/__init__.py b/test/vanilla/low-level/AcceptanceTests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/__init__.py b/test/vanilla/low-level/AcceptanceTests/asynctests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/conftest.py b/test/vanilla/low-level/AcceptanceTests/asynctests/conftest.py new file mode 100644 index 00000000000..ed50902a130 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/conftest.py @@ -0,0 +1,59 @@ +# -------------------------------------------------------------------------- +# +# 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 msrest import Serializer, Deserializer + +@pytest.fixture() +def base_send_request(): + async def send_request(client, request): + response = await client.send_request(request) + response.raise_for_status() + return response + return send_request + +@pytest.fixture() +def base_send_request_json_response(): + async def send_request_json_response(client, request): + response = await client.send_request(request) + response.raise_for_status() + return response.json() + return send_request_json_response + +@pytest.fixture() +def base_make_stream_request(): + async def make_stream_request(client, request): + response = await client.send_request(request, stream=True) + response.raise_for_status() + return response.stream_download() + return make_stream_request + +@pytest.fixture +def msrest_serializer(): + return Serializer() + +@pytest.fixture +def msrest_deserializer(): + return Deserializer diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_additional_properties.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_additional_properties.py new file mode 100644 index 00000000000..847fb43a315 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_additional_properties.py @@ -0,0 +1,135 @@ +# -------------------------------------------------------------------------- +# +# 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 async_generator import yield_, async_generator +from additionalpropertieslowlevel.aio import AdditionalPropertiesClient +from additionalpropertieslowlevel.rest import pets + +@pytest.fixture +@async_generator +async def client(): + async with AdditionalPropertiesClient(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_create_ap_true(send_request_json_response): + json = { + 'birthdate': '2017-12-13T02:29:51Z', + 'complexProperty': { + 'color': 'Red' + }, + "id": 1, + "name": "Puppy", + } + request = pets.build_create_ap_true_request(json=json) + response = await send_request_json_response(request) + assert response["birthdate"] == '2017-12-13T02:29:51Z' + +@pytest.mark.asyncio +async def test_create_cat_ap_true(send_request_json_response): + json = { + 'birthdate': '2017-12-13T02:29:51Z', + 'complexProperty': {'color': 'Red'}, + 'id': 1, + 'name': 'Lisa', + 'friendly': True + } + request = pets.build_create_cat_ap_true_request(json=json) + response = await send_request_json_response(request) + assert response['birthdate'] == '2017-12-13T02:29:51Z' + +@pytest.mark.asyncio +async def test_create_ap_object(send_request_json_response): + json = { + "id": 2, + "name": "Hira", + 'siblings': [{ + 'id': 1, + 'name': 'Puppy', + 'birthdate': '2017-12-13T02:29:51Z', + 'complexProperty': { + 'color': 'Red' + } + }], + 'picture': '//////4=' + } + request = pets.build_create_ap_object_request(json=json) + response = await send_request_json_response(request) + assert response['siblings'][0]['birthdate'] == '2017-12-13T02:29:51Z' + +@pytest.mark.asyncio +async def test_create_ap_string(send_request_json_response): + json = { + "id": 3, + "name": 'Tommy', + 'color': 'red', + 'weight': '10 kg', + 'city': 'Bombay' + } + request = pets.build_create_ap_string_request(json=json) + response = await send_request_json_response(request) + assert response['color'] == 'red' + +@pytest.mark.asyncio +async def test_create_ap_in_properties(send_request_json_response): + json = { + "id": 4, + "name": 'Bunny', + "additionalProperties": { + 'height': 5.61, + 'weight': 599, + 'footsize': 11.5 + } + } + request = pets.build_create_ap_in_properties_request(json=json) + response = await send_request_json_response(request) + assert response["additionalProperties"]['weight'] == 599 + +@pytest.mark.asyncio +async def test_create_ap_in_properties_with_ap_string(send_request_json_response): + json = { + "id": 5, + "name": 'Funny', + "@odata.location":'westus', + 'color': 'red', + 'city': 'Seattle', + 'food': 'tikka masala', + "additionalProperties": { + 'height': 5.61, + 'weight': 599, + 'footsize': 11.5 + } + } + request = pets.build_create_ap_in_properties_with_ap_string_request(json=json) + response = await send_request_json_response(request) + assert response['color'] == 'red' + assert response['additionalProperties']['weight'] == 599 \ No newline at end of file diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_anything.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_anything.py new file mode 100644 index 00000000000..dacb83ae8d5 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_anything.py @@ -0,0 +1,78 @@ +# -------------------------------------------------------------------------- +# +# 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 async_generator import yield_, async_generator +from anythinglowlevel.aio import AnythingClient +from anythinglowlevel import rest + +@pytest.fixture +@async_generator +async def client(): + async with AnythingClient(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_get_string(send_request_json_response): + request = rest.build_get_string_request() + assert await send_request_json_response(request) == 'anything' + +@pytest.mark.asyncio +async def test_put_string(send_request): + request = rest.build_put_string_request(json="anything") + await send_request(request) + +@pytest.mark.asyncio +async def test_get_object(send_request_json_response): + request = rest.build_get_object_request() + assert await send_request_json_response(request) == {"message": "An object was successfully returned"} + +@pytest.mark.asyncio +async def test_put_object(send_request): + request = rest.build_put_object_request(json={'foo': 'bar'}) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_array(send_request_json_response): + request = rest.build_get_array_request() + assert await send_request_json_response(request) == ['foo', 'bar'] + +@pytest.mark.asyncio +async def test_put_array(send_request): + request = rest.build_put_array_request(json=['foo', 'bar']) + await send_request(request) + diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_array.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_array.py new file mode 100644 index 00000000000..e7f7b6e9c3e --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_array.py @@ -0,0 +1,414 @@ +# -------------------------------------------------------------------------- +# +# 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 json +import isodate +from async_generator import yield_, async_generator +from azure.core.exceptions import DecodeError +from datetime import date, datetime, timedelta +from base64 import b64encode +from bodyarraylowlevel.aio import AutoRestSwaggerBATArrayService +from bodyarraylowlevel.rest import array +import msrest + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestSwaggerBATArrayService(base_url="http://localhost:3000") as client: + await yield_(client) + + +@pytest.fixture +def datetimes(): + datetime1 = isodate.parse_datetime("2000-12-01T00:00:01Z") + datetime2 = isodate.parse_datetime("1980-01-02T00:11:35Z") + datetime3 = isodate.parse_datetime("1492-10-12T10:15:01Z") + return [datetime1, datetime2, datetime3] + +@pytest.fixture +def products(): + prod1 = {"integer": 1, "string": "2"} + prod2 = {"integer": 3, "string": "4"} + prod3 = {"integer": 5, "string": "6"} + return [prod1, prod2, prod3] + +@pytest.fixture +def listdict(): + return [{"1": "one", "2": "two", "3": "three"}, + {"4": "four", "5": "five", "6": "six"}, + {"7": "seven", "8": "eight", "9": "nine"}] + +@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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_empty(send_request, send_request_json_response): + request = array.build_get_empty_request() + + assert [] == await send_request_json_response(request) + + request = array.build_get_null_request() + response = await send_request(request) + assert response.text == '' + + request = array.build_put_empty_request(json=[]) + await send_request(request) + +@pytest.mark.asyncio +async def test_boolean_tfft(send_request, send_request_json_response): + request = array.build_get_boolean_tfft_request() + assert [True, False, False, True] == await send_request_json_response(request) + request = array.build_put_boolean_tfft_request(json=[True, False, False, True]) + await send_request(request) + +@pytest.mark.asyncio +async def test_integer_valid(send_request, send_request_json_response): + request = array.build_get_integer_valid_request() + assert [1, -1, 3, 300] == await send_request_json_response(request) + request = array.build_put_integer_valid_request(json=[1, -1, 3, 300]) + await send_request(request) + +@pytest.mark.asyncio +async def test_long_valid(send_request, send_request_json_response): + request = array.build_get_long_valid_request() + assert [1, -1, 3, 300] == await send_request_json_response(request) + request = array.build_put_long_valid_request(json=[1, -1, 3, 300]) + await send_request(request) + +@pytest.mark.asyncio +async def test_float_valid(send_request, send_request_json_response): + request = array.build_get_float_valid_request() + assert [0, -0.01, -1.2e20] == await send_request_json_response(request) + request = array.build_put_float_valid_request(json=[0, -0.01, -1.2e20]) + await send_request(request) + +@pytest.mark.asyncio +async def test_double_valid(send_request, send_request_json_response): + request = array.build_get_double_valid_request() + assert [0, -0.01, -1.2e20] == await send_request_json_response(request) + request = array.build_put_double_valid_request(json=[0, -0.01, -1.2e20]) + await send_request(request) + +@pytest.mark.asyncio +async def test_string_valid(send_request, send_request_json_response): + request = array.build_get_string_valid_request() + assert ["foo1", "foo2", "foo3"] == await send_request_json_response(request) + request = array.build_put_string_valid_request(json=["foo1", "foo2", "foo3"]) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_string_with_null(send_request_json_response): + request = array.build_get_string_with_null_request() + assert ["foo", None, "foo2"] == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_string_with_invalid(send_request_json_response): + request = array.build_get_string_with_invalid_request() + + # response differs from convenience layer + # this is bc in convenence layer we tell the demsrest_serializer to deserialize it fully as a list of string + assert ["foo", 123, "foo2"] == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_uuid_valid(send_request, send_request_json_response): + request = array.build_get_uuid_valid_request() + assert ["6dcc7237-45fe-45c4-8a6b-3a8a3f625652", "d1399005-30f7-40d6-8da6-dd7c89ad34db", + "f42f6aa1-a5bc-4ddf-907e-5f915de43205"] == await send_request_json_response(request) + request = array.build_put_uuid_valid_request(json=["6dcc7237-45fe-45c4-8a6b-3a8a3f625652", "d1399005-30f7-40d6-8da6-dd7c89ad34db", + "f42f6aa1-a5bc-4ddf-907e-5f915de43205"]) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_uuid_invalid_chars(send_request, send_request_json_response): + #Handles invalid characters without error because of no guid class + request = array.build_get_uuid_invalid_chars_request() + assert ["6dcc7237-45fe-45c4-8a6b-3a8a3f625652", "foo"] == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_date_valid(send_request, send_request_json_response): + def datetime_handler(x): + if isinstance(x, datetime.date): + return x.isoformat() + raise TypeError("Unknown type") + date1 = isodate.parse_date("2000-12-01") + date2 = isodate.parse_date("1980-01-02") + date3 = isodate.parse_date("1492-10-12") + + request = array.build_get_date_valid_request() + assert await send_request_json_response(request), [date1, date2 == date3] + request = array.build_put_date_valid_request(json=[str(date1), str(date2), str(date3)]) # dates are not json serializable + await send_request(request) + +@pytest.mark.asyncio +async def test_date_time_valid(send_request, send_request_json_response, datetimes, msrest_serializer): + request = array.build_get_date_time_valid_request() + + assert await send_request_json_response(request), [datetimes[0], datetimes[1] == datetimes[2]] + request = array.build_put_date_time_valid_request(json=[msrest_serializer.serialize_iso(datetime) for datetime in datetimes]) + await send_request(request) + +@pytest.mark.asyncio +async def test_date_time_rfc1123_valid(send_request, send_request_json_response, datetimes, msrest_serializer): + request = array.build_get_date_time_rfc1123_valid_request() + assert await send_request_json_response(request), [datetimes[0], datetimes[1] == datetimes[2]] + request = array.build_put_date_time_rfc1123_valid_request(json=[msrest_serializer.serialize_rfc(datetime) for datetime in datetimes]) + await send_request(request) + +@pytest.mark.asyncio +async def test_duration_valid(send_request, send_request_json_response): + duration1 = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + duration2 = timedelta(days=5, hours=1) + + request = array.build_get_duration_valid_request() + assert await send_request_json_response(request), [duration1 == duration2] + request = array.build_put_duration_valid_request(json=[isodate.duration_isoformat(duration1), isodate.duration_isoformat(duration2)]) + await send_request(request) + +@pytest.mark.asyncio +async def test_byte_valid(send_request, send_request_json_response): + bytes1 = bytearray([0x0FF, 0x0FF, 0x0FF, 0x0FA]) + bytes2 = bytearray([0x01, 0x02, 0x03]) + bytes3 = bytearray([0x025, 0x029, 0x043]) + + request = array.build_get_byte_valid_request() + assert await send_request_json_response(request), [bytes1, bytes2 == bytes3] + request = array.build_put_byte_valid_request(json=[b64encode(b).decode() for b in [bytes1, bytes2, bytes3]]) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_byte_invalid_null(send_request_json_response): + request = array.build_get_byte_invalid_null_request() + assert await send_request_json_response(request), [bytearray([0x0AB, 0x0AC, 0x0AD]) == None] + +@pytest.mark.asyncio +async def test_get_complex_null(send_request): + request = array.build_get_complex_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_get_complex_empty(send_request_json_response): + request = array.build_get_complex_empty_request() + assert [] == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_complex_valid(send_request, send_request_json_response, products): + request = array.build_get_complex_valid_request() + assert products == await send_request_json_response(request) + request = array.build_put_complex_valid_request(json=products) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_array_valid(send_request, send_request_json_response): + listlist = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] + request = array.build_get_array_valid_request() + assert listlist == await send_request_json_response(request) + request = array.build_put_array_valid_request(json=listlist) + await send_request(request) + + +@pytest.mark.asyncio +async def test_dictionary_valid(send_request, send_request_json_response, listdict): + request = array.build_get_dictionary_valid_request() + assert listdict == await send_request_json_response(request) + request = array.build_put_dictionary_valid_request(json=listdict) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_complex_item_null(send_request_json_response, products): + products_null = [products[0], None, products[2]] + request = array.build_get_complex_item_null_request() + assert products_null == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_complex_item_empty(send_request_json_response, products): + products_empty = [products[0], {}, products[2]] + + request = array.build_get_complex_item_empty_request() + assert products_empty == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_array_null(send_request): + request = array.build_get_array_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_get_array_empty(send_request_json_response): + request = array.build_get_array_empty_request() + assert [] == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_array_item_null(send_request_json_response): + listlist2 = [["1", "2", "3"], None, ["7", "8", "9"]] + request = array.build_get_array_item_null_request() + assert listlist2 == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_array_item_empty(send_request_json_response): + listlist3 = [["1", "2", "3"], [], ["7", "8", "9"]] + request = array.build_get_array_item_empty_request() + assert listlist3 == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_dictionary_and_dictionary_item_null(send_request, send_request_json_response, listdict): + + request = array.build_get_dictionary_null_request() + assert (await send_request(request)).text == '' + + listdict[1] = None + request = array.build_get_dictionary_item_null_request() + assert listdict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_dictionary_and_dictionary_item_empty(send_request_json_response, listdict): + request = array.build_get_dictionary_empty_request() + assert [] == await send_request_json_response(request) + + listdict[1] = {} + request = array.build_get_dictionary_item_empty_request() + assert listdict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_array_get_invalid(send_request_json_response): + request = array.build_get_invalid_request() + with pytest.raises(DecodeError): # raises a diff error than the sync version + await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_array_get_boolean_invalid_null(send_request_json_response): + request = array.build_get_boolean_invalid_null_request() + assert await send_request_json_response(request), [True, None == False] + +@pytest.mark.asyncio +async def test_array_get_boolean_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_boolean_invalid_string_request() + assert await send_request_json_response(request) == [True, "boolean", False] + +@pytest.mark.asyncio +async def test_array_get_int_invalid_null(send_request_json_response): + request = array.build_get_int_invalid_null_request() + assert await send_request_json_response(request), [1, None == 0] + +@pytest.mark.asyncio +async def test_array_get_int_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_int_invalid_string_request() + assert await send_request_json_response(request) == [1, "integer", 0] + +@pytest.mark.asyncio +async def test_array_get_long_invalid_null(send_request_json_response): + request = array.build_get_long_invalid_null_request() + assert await send_request_json_response(request), [1, None == 0] + +@pytest.mark.asyncio +async def test_array_get_long_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_long_invalid_string_request() + assert await send_request_json_response(request) == [1, "integer", 0] + +@pytest.mark.asyncio +async def test_array_get_float_invalid_null(send_request_json_response): + request = array.build_get_float_invalid_null_request() + assert await send_request_json_response(request), [0.0, None == -1.2e20] + +@pytest.mark.asyncio +async def test_array_get_float_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_float_invalid_string_request() + assert await send_request_json_response(request) == [1, "number", 0] + +@pytest.mark.asyncio +async def test_array_get_double_invalid_null(send_request_json_response): + request = array.build_get_double_invalid_null_request() + assert await send_request_json_response(request), [0.0, None == -1.2e20] + +@pytest.mark.asyncio +async def test_array_get_double_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_double_invalid_string_request() + assert await send_request_json_response(request) == [1, "number", 0] + +@pytest.mark.asyncio +async def test_array_get_string_with_invalid(send_request_json_response): + request = array.build_get_string_with_invalid_request() + assert await send_request_json_response(request), ["foo", "123" == "foo2"] + +@pytest.mark.asyncio +async def test_array_get_date_invalid_null(send_request_json_response): + request = array.build_get_date_invalid_null_request() + assert await send_request_json_response(request), [isodate.parse_date("2012-01-01"), None == isodate.parse_date("1776-07-04")] + +@pytest.mark.asyncio +async def test_array_get_date_invalid_chars(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_date_invalid_chars_request() + assert await send_request_json_response(request) == ["2011-03-22", "date"] + +@pytest.mark.asyncio +async def test_array_get_date_time_invalid_null(send_request_json_response): + request = array.build_get_date_time_invalid_null_request() + assert await send_request_json_response(request), [isodate.parse_datetime("2000-12-01T00:00:01Z") == None] + +@pytest.mark.asyncio +async def test_array_get_date_time_invalid_chars(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_date_time_invalid_chars_request() + assert await send_request_json_response(request) == ['2000-12-01t00:00:01z', 'date-time'] + +@pytest.mark.asyncio +async def test_array_get_base64_url(send_request_json_response, msrest_deserializer): + test_array = ['a string that gets encoded with base64url'.encode(), + 'test string'.encode(), + 'Lorem ipsum'.encode()] + request = array.build_get_base64_url_request() + response = await send_request_json_response(request) + assert [msrest_deserializer.deserialize_base64(s) for s in await send_request_json_response(request)] == test_array + +@pytest.mark.asyncio +async def test_array_enum_valid(send_request, send_request_json_response): + request = array.build_get_enum_valid_request() + response = await send_request_json_response(request) + assert response == ['foo1', 'foo2', 'foo3'] + request = array.build_put_enum_valid_request(json=response) + await send_request(request) + +@pytest.mark.asyncio +async def test_array_string_enum_valid(send_request, send_request_json_response): + request = array.build_get_string_enum_valid_request() + response = await send_request_json_response(request) + assert response == ['foo1', 'foo2', 'foo3'] + request = array.build_put_string_enum_valid_request(json=response) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_bool.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_bool.py new file mode 100644 index 00000000000..b92b02655e4 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_bool.py @@ -0,0 +1,79 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from bodybooleanlowlevel.aio import AutoRestBoolTestService +from bodybooleanlowlevel.rest import bool +from async_generator import yield_, async_generator +import pytest +from azure.core.exceptions import DecodeError + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestBoolTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_model_get_true(send_request_json_response): + request = bool.build_get_true_request() + assert await send_request_json_response(request) == True + +@pytest.mark.asyncio +async def test_model_get_false(send_request_json_response): + request = bool.build_get_false_request() + assert not await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_model_get_null(send_request): + request = bool.build_get_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_model_put_false(send_request): + request = bool.build_put_false_request(json=False) # have to pass in bc we don't do constant bodies in request builders + await send_request(request) + +@pytest.mark.asyncio +async def test_model_put_true(send_request): + request = bool.build_put_true_request(json=True) # have to pass in bc we don't do constant bodies in request builders + await send_request(request) + +@pytest.mark.asyncio +async def test_model_get_invalid(send_request): + request = bool.build_get_invalid_request() + with pytest.raises(DecodeError): + await send_request(request) # this behavior is diff from sync diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_byte.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_byte.py new file mode 100644 index 00000000000..0074fbf8fab --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_byte.py @@ -0,0 +1,67 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from bodybytelowlevel.aio import AutoRestSwaggerBATByteService +from bodybytelowlevel.rest import byte +from async_generator import yield_, async_generator +from base64 import b64encode + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestSwaggerBATByteService(base_url="http://localhost:3000") as client: + await 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_non_ascii(send_request): + tests = bytearray([0x0FF, 0x0FE, 0x0FD, 0x0FC, 0x0FB, 0x0FA, 0x0F9, 0x0F8, 0x0F7, 0x0F6]) + request = byte.build_put_non_ascii_request(json=b64encode(tests).decode()) + await send_request(request) + + request = byte.build_get_non_ascii_request() + response = await send_request(request) + +@pytest.mark.asyncio +async def test_get_null(send_request): + request = byte.build_get_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_get_empty(send_request): + request = byte.build_get_empty_request() + assert b'""' == (await send_request(request)).content # in convenience layer, we deserialize as bytearray specif + +@pytest.mark.asyncio +async def test_get_invalid(send_request): + request = byte.build_get_invalid_request() + assert (await send_request(request)).content == b'"::::SWAGGER::::"' diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_complex.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_complex.py new file mode 100644 index 00000000000..801b3eb667d --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_complex.py @@ -0,0 +1,649 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +import pytest +import isodate +from datetime import datetime, timedelta, tzinfo +from bodycomplexlowlevel.aio import AutoRestComplexTestService +from bodycomplexlowlevel.rest import ( + basic, + array, + dictionary, + polymorphicrecursive, + polymorphism, + primitive, + readonlyproperty, + inheritance, +) +from azure.core.exceptions import HttpResponseError +from msrest import Serializer, Deserializer +from base64 import b64decode, b64encode + + +class UTC(tzinfo): + def utcoffset(self,dt): + return timedelta(hours=0,minutes=0) + + def tzname(self,dt): + return "Z" + + def dst(self,dt): + return timedelta(0) + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestComplexTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def min_date(): + min_date = datetime.min + return min_date.replace(tzinfo=UTC()) + +@pytest.mark.asyncio +async def test_basic_get_and_put_valid(send_request, send_request_json_response): + # GET basic/valid + request = basic.build_get_valid_request() + basic_result = await send_request_json_response(request) + assert 2 == basic_result['id'] + assert "abc" == basic_result['name'] + assert "YELLOW" == basic_result['color'] + + # PUT basic/valid + json = { + "id": 2, + "name": "abc", + "color": "Magenta", + } + request = basic.build_put_valid_request(json=json) + await send_request(request) + json = { + "id": 2, + "name": "abc", + "color": "Magenta", + } + request = basic.build_put_valid_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_basic_get_empty(send_request, send_request_json_response): + # GET basic/empty + request = basic.build_get_empty_request() + basic_result = await send_request_json_response(request) + assert basic_result == {} + +@pytest.mark.asyncio +async def test_basic_get_null(send_request_json_response): + # GET basic/null + request = basic.build_get_null_request() + basic_result = await send_request_json_response(request) + assert basic_result['id'] is None + assert basic_result['name'] is None + +@pytest.mark.asyncio +async def test_basic_get_not_provided(send_request): + # GET basic/notprovided + request = basic.build_get_not_provided_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_basic_get_invalid(send_request_json_response): + # GET basic/invalid + request = basic.build_get_invalid_request() + basic_result = await send_request_json_response(request) + # it's deserialized as invalid bc the id is not a number + # with LLC, we don't care thought + assert basic_result['id'] == 'a' + assert basic_result['name'] == 'abc' + +# COMPLEX TYPE WITH PRIMITIVE PROPERTIES +@pytest.mark.asyncio +async def test_primitive_get_and_put_int(send_request, send_request_json_response): + # GET primitive/integer + request = primitive.build_get_int_request() + int_result = await send_request_json_response(request) + assert -1 == int_result['field1'] + assert 2 == int_result['field2'] + + # PUT primitive/integer + int_request = {'field1':-1, 'field2':2} + request = primitive.build_put_int_request(json=int_request) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_long(send_request, send_request_json_response): + # GET primitive/long + request = primitive.build_get_long_request() + long_result = await send_request_json_response(request) + assert 1099511627775 == long_result['field1'] + assert -999511627788 == long_result['field2'] + + # PUT primitive/long + json = {'field1':1099511627775, 'field2':-999511627788} + request = primitive.build_put_long_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_float(send_request, send_request_json_response): + # GET primitive/float + request = primitive.build_get_float_request() + float_result = await send_request_json_response(request) + assert 1.05 == float_result['field1'] + assert -0.003 == float_result['field2'] + + # PUT primitive/float + json = { + "field1": 1.05, + "field2": -0.003 + } + request = primitive.build_put_float_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_double(send_request, send_request_json_response): + # GET primitive/double + request = primitive.build_get_double_request() + double_result = await send_request_json_response(request) + assert 3e-100 == double_result['field1'] + assert -5e-57 == double_result['field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose'] + + # PUT primitive/double + json = { + "field1": 3e-100, + "field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose": -5e-57 + } + request = primitive.build_put_double_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_bool(send_request, send_request_json_response): + # GET primitive/bool + request = primitive.build_get_bool_request() + bool_result = await send_request_json_response(request) + assert bool_result['field_true'] + assert not bool_result['field_false'] + + # PUT primitive/bool + json = { + "field_true": True, + "field_false": False + } + request = primitive.build_put_bool_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_string(send_request, send_request_json_response): + # GET primitive/string + request = primitive.build_get_string_request() + string_result = await send_request_json_response(request) + assert "goodrequest" == string_result['field'] + assert "" == string_result['empty'] + assert string_result['null'] is None + + # PUT primitive/string + json = { + "null": None, + "empty": "", + "field": "goodrequest" + } + request = primitive.build_put_string_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_date(send_request, send_request_json_response): + # GET primitive/date + request = primitive.build_get_date_request() + date_result = await send_request_json_response(request) + assert isodate.parse_date("0001-01-01") == isodate.parse_date(date_result['field']) + assert isodate.parse_date("2016-02-29") == isodate.parse_date(date_result['leap']) + + json = { + "field": '0001-01-01', + "leap": '2016-02-29' + } + request = primitive.build_put_date_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_date_time(send_request, send_request_json_response, min_date): + # GET primitive/datetime + request = primitive.build_get_date_time_request() + datetime_result = await send_request_json_response(request) + + assert min_date == Deserializer.deserialize_iso(datetime_result['field']) + + json = { + "field": "0001-01-01T00:00:00Z", + "now": "2015-05-18T18:38:00Z" + } + request = primitive.build_put_date_time_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_date_time_rfc1123(send_request, send_request_json_response): + # GET primitive/datetimerfc1123 + request = primitive.build_get_date_time_rfc1123_request() + datetimerfc1123_result = await send_request_json_response(request) + + # we are not using the min date of year 1 because of the latest msrest update + # with msrest update, minimal year we can parse is 100, instead of 1 + min_date = datetime(2001, 1, 1) + assert min_date.replace(tzinfo=UTC()) == Deserializer.deserialize_rfc(datetimerfc1123_result['field']) + + # we can still model year 1 though with the latest msrest update + json = { + "field": Serializer.serialize_rfc(isodate.parse_datetime("0001-01-01T00:00:00Z")), + "now": Serializer.serialize_rfc(isodate.parse_datetime("2015-05-18T11:38:00Z")) + } + request = primitive.build_put_date_time_rfc1123_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_duration(send_request, send_request_json_response): + # GET primitive/duration + expected = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + request = primitive.build_get_duration_request() + duration_result = await send_request_json_response(request) + assert expected == Deserializer.deserialize_duration(duration_result['field']) + + request = primitive.build_put_duration_request(json={"field": Serializer.serialize_duration(expected)}) + await send_request(request) + +@pytest.mark.asyncio +async def test_primitive_get_and_put_byte(send_request, send_request_json_response): + # GET primitive/byte + request = primitive.build_get_byte_request() + byte_result = await send_request_json_response(request) + valid_bytes = bytearray([0x0FF, 0x0FE, 0x0FD, 0x0FC, 0x000, 0x0FA, 0x0F9, 0x0F8, 0x0F7, 0x0F6]) + assert valid_bytes == bytearray(b64decode(byte_result['field'])) + + # PUT primitive/byte + request = primitive.build_put_byte_request(json={"field": b64encode(valid_bytes).decode()}) + await send_request(request) + +# COMPLEX TYPE WITH READ ONLY PROPERTIES + +@pytest.mark.asyncio +async def test_readonlyproperty_get_and_put_valid(send_request, send_request_json_response): + # GET readonly/valid + valid_obj = {"size": 2, 'id': '1234'} + request = readonlyproperty.build_get_valid_request() + readonly_result = await send_request_json_response(request) + assert readonly_result == valid_obj + + # PUT readonly/valid + request = readonlyproperty.build_put_valid_request(json=2) + assert (await send_request(request)).text == '' + +# COMPLEX TYPE WITH ARRAY PROPERTIES + +@pytest.mark.asyncio +async def test_array_get_and_put_valid(send_request, send_request_json_response): + # GET array/valid + request = array.build_get_valid_request() + array_result = await send_request_json_response(request) + assert 5 == len(array_result['array']) + + array_value = ["1, 2, 3, 4", "", None, "&S#$(*Y", + "The quick brown fox jumps over the lazy dog"] + assert array_result['array'] == array_value + + # PUT array/valid + request = array.build_put_valid_request(json={"array": array_value}) + await send_request(request) + +@pytest.mark.asyncio +async def test_array_get_and_put_empty(send_request, send_request_json_response): + + # GET array/empty + request = array.build_get_empty_request() + array_result = await send_request_json_response(request) + assert 0 == len(array_result['array']) + + # PUT array/empty + request = array.build_put_empty_request(json={"array": []}) + await send_request(request) + +@pytest.mark.asyncio +async def test_array_get_not_provided(send_request_json_response): + # Get array/notprovided + request = array.build_get_not_provided_request() + assert await send_request_json_response(request) == {} + +# COMPLEX TYPE WITH DICTIONARY PROPERTIES + +@pytest.mark.asyncio +async def test_dictionary_get_and_put_valid(send_request, send_request_json_response): + # GET dictionary/valid + request = dictionary.build_get_valid_request() + dict_result = await send_request_json_response(request) + assert 5 == len(dict_result['defaultProgram']) + + dict_val = {'txt':'notepad', 'bmp':'mspaint', 'xls':'excel', 'exe':'', '':None} + assert dict_val == dict_result['defaultProgram'] + + # PUT dictionary/valid + request = dictionary.build_put_valid_request(json={"defaultProgram": dict_val}) + await send_request(request) + +@pytest.mark.asyncio +async def test_dictionary_get_and_put_empty(send_request, send_request_json_response): + # GET dictionary/empty + request = dictionary.build_get_empty_request() + dict_result = await send_request_json_response(request) + assert 0 == len(dict_result['defaultProgram']) + + # PUT dictionary/empty + request = dictionary.build_put_empty_request(json={"defaultProgram": {}}) + await send_request(request) + +@pytest.mark.asyncio +async def test_dictionary_get_and_null(send_request_json_response): + # GET dictionary/null + request = dictionary.build_get_null_request() + dictionary_result = await send_request_json_response(request) + assert dictionary_result['defaultProgram'] is None + +@pytest.mark.asyncio +async def test_dictionary_get_not_provided(send_request_json_response): + # GET dictionary/notprovided + request = dictionary.build_get_not_provided_request() + assert await send_request_json_response(request) == {} + + +# COMPLEX TYPES THAT INVOLVE INHERITANCE + +@pytest.mark.asyncio +async def test_inheritance_get_and_put_valid(send_request, send_request_json_response): + # GET inheritance/valid + request = inheritance.build_get_valid_request() + inheritance_result = await send_request_json_response(request) + assert 2 == inheritance_result['id'] + assert "Siameeee" == inheritance_result['name'] + assert -1 == inheritance_result['hates'][1]['id'] + assert "Tomato" == inheritance_result['hates'][1]['name'] + + # PUT inheritance/valid + json = { + 'id': 2, + 'name': "Siameeee", + 'color': "green", + 'breed': "persian", + 'hates': [{"id": 1, "name": "Potato", "food": "tomato"}, + {"id": -1, "name": "Tomato", "food": "french fries"}] + } + request = inheritance.build_put_valid_request(json=json) + await send_request(request) + +# COMPLEX TYPES THAT INVOLVE POLYMORPHISM + +@pytest.mark.asyncio +async def test_get_composed_with_discriminator(send_request_json_response): + request = polymorphism.build_get_composed_with_discriminator_request() + result = await send_request_json_response(request) + assert result['sampleSalmon']['fish.type'] == "DotSalmon" + +@pytest.mark.asyncio +async def test_get_composed_without_discriminator(send_request_json_response): + request = polymorphism.build_get_composed_without_discriminator_request() + result = await send_request_json_response(request) + with pytest.raises(KeyError): + result['sampleSalmon']['fish.type'] # shouldn't have a discriminator + +@pytest.mark.asyncio +async def test_polymorphism_get_and_put_valid(send_request, send_request_json_response): + # GET polymorphism/valid + request = polymorphism.build_get_valid_request() + result = await send_request_json_response(request) + assert result is not None + assert result['location'] == "alaska" + assert len(result['siblings']) == 3 + assert result['siblings'][0]['fishtype'] == 'shark' + assert result['siblings'][1]['fishtype'] == 'sawshark' + assert result['siblings'][2]['fishtype'] == 'goblin' + assert result['siblings'][0]['age'] == 6 + assert result['siblings'][1]['age'] == 105 + assert result['siblings'][2]['age'] == 1 + + + # PUT polymorphism/valid + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + }, + { + "fishtype": "goblin", + "species": "scary", + "length": 30.0, + "age": 1, + "birthday": "2015-08-08T00:00:00.000Z", + "jawsize": 5, + "color": "pinkish-gray" + } + ], + "location": "alaska", + "iswild": True + } + request = polymorphism.build_put_valid_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_polymorphism_put_valid_missing_required(send_request): + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "picture": "//////4=" + } + ], + "location": "alaska", + "iswild": True + } + + request = polymorphism.build_put_valid_missing_required_request(json=json) + + # in convenience layer, this raises a ValidationError (when generated with client side validation) + with pytest.raises(HttpResponseError) as e: + await send_request(request) + assert "Reached server in scenario: /complex/polymorphism/missingrequired/invalid" in str(e.value.response.text) + +# COMPLEX TYPES THAT INVOLVE RECURSIVE REFERENCE + +@pytest.mark.asyncio +async def test_polymorphismrecursive_get_and_put_valid(send_request, send_request_json_response): + # GET polymorphicrecursive/valid + request = polymorphicrecursive.build_get_valid_request() + result = await send_request_json_response(request) + assert result['fishtype'] == 'salmon' + assert result['siblings'][0]['fishtype'] == 'shark' + assert result['siblings'][0]['siblings'][0]['fishtype'] == 'salmon' + assert result['siblings'][0]['siblings'][0]['location'] == "atlantic" + + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + } + ], + "location": "atlantic", + "iswild": True + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "siblings": [], + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + } + ], + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "siblings": [], + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + } + ], + "location": "alaska", + "iswild": True + } + + # PUT polymorphicrecursive/valid + request = polymorphicrecursive.build_put_valid_request(json=json) + await send_request(request) + + +# Complex types that uses additional properties and polymorphism +@pytest.mark.asyncio +async def test_polymorphism_get_and_put_complicated(send_request, send_request_json_response): + request = polymorphism.build_get_complicated_request() + response = await send_request_json_response(request) + request = polymorphism.build_put_complicated_request(json=response) + await send_request(request) + +# Complex types that uses missing discriminator + +@pytest.mark.asyncio +async def test_polymorphism_get_and_put_missing_discriminator(send_request, send_request_json_response): + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + }, + { + "fishtype": "goblin", + "species": "scary", + "length": 30.0, + "age": 1, + "birthday": "2015-08-08T00:00:00.000Z", + "jawsize": 5, + "color": "pinkish-gray" + } + ], + "location": "alaska", + "iswild": True + } + # Not raise is enough of a test + request = polymorphism.build_put_missing_discriminator_request(json=json) + await send_request(request) + + # Dot syntax + request = polymorphism.build_get_dot_syntax_request() + dot_salmon = await send_request_json_response(request) + assert dot_salmon['fish.type'] == "DotSalmon" + assert dot_salmon['location'] == "sweden" diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_config.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_config.py new file mode 100644 index 00000000000..86398b05b65 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_config.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# +# 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 azure.core.pipeline.policies import HttpLoggingPolicy +from bodystringlowlevel.aio import AutoRestSwaggerBATService + +@pytest.mark.asyncio +async def test_http_logging_policy_default(): + async with AutoRestSwaggerBATService(base_url="http://localhost:3000") as client: + assert isinstance(client._config.http_logging_policy, HttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == HttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST + +@pytest.mark.asyncio +async def test_http_logging_policy_custom(): + http_logging_policy = HttpLoggingPolicy(base_url="test") + http_logging_policy = HttpLoggingPolicy() + http_logging_policy.allowed_header_names.update( + {"x-ms-added-header"} + ) + async with AutoRestSwaggerBATService(base_url="http://localhost:3000", http_logging_policy=http_logging_policy) as client: + assert isinstance(client._config.http_logging_policy, HttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == HttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST.union({"x-ms-added-header"}) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_content_type.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_content_type.py new file mode 100644 index 00000000000..b5d5924f132 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_content_type.py @@ -0,0 +1,49 @@ +# 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 io +import pytest +from mediatypeslowlevel.aio import MediaTypesClient +from mediatypeslowlevel.rest import * +from async_generator import yield_, async_generator + +@pytest.mark.asyncio +async def test_stream_unread_until_send_request(): + class FakeStream: + def __init__(self): + self.call_count = 0 + + @async_generator + async def streaming_body(self, data): + self.call_count += 1 + await yield_(data) + + fake_stream = FakeStream() + request = build_analyze_body_request(content=fake_stream.streaming_body(b"PDF")) + assert not request.headers.get("Content-Type") + assert fake_stream.call_count == 0 + await MediaTypesClient().send_request(request) + assert fake_stream.call_count == 1 diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_date.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_date.py new file mode 100644 index 00000000000..0708f76c732 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_date.py @@ -0,0 +1,94 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +import datetime +from async_generator import yield_, async_generator + +from bodydatelowlevel.aio import AutoRestDateTestService +from bodydatelowlevel.rest import date + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestDateTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_model_get_and_put_max_date(send_request, send_request_json_response): + max_date = isodate.parse_date("9999-12-31T23:59:59.999999Z") + request = date.build_put_max_date_request(json=str(max_date)) + await send_request(request) + + request = date.build_get_max_date_request() + assert max_date == isodate.parse_date(await send_request_json_response(request)) + +@pytest.mark.asyncio +async def test_model_get_and_put_min_date(send_request, send_request_json_response): + min_date = isodate.parse_date("0001-01-01T00:00:00Z") + request = date.build_put_min_date_request(json=str(min_date)) + await send_request(request) + + request = date.build_get_min_date_request() + assert min_date == isodate.parse_date(await send_request_json_response(request)) + +@pytest.mark.asyncio +async def test_model_get_null(send_request): + request = date.build_get_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_model_get_invalid_date(send_request_json_response): + request = date.build_get_invalid_date_request() + assert datetime.date(2001, 1, 1) == isodate.parse_date(await send_request_json_response(request)) + +@pytest.mark.asyncio +async def test_model_get_overflow_date(send_request_json_response): + request = date.build_get_overflow_date_request() + with pytest.raises(ValueError) as ex: + isodate.parse_date(await send_request_json_response(request)) + assert "day is out of range for month" in str(ex.value) + +@pytest.mark.asyncio +async def test_model_get_underflow_date(send_request_json_response): + request = date.build_get_underflow_date_request() + with pytest.raises(ValueError) as ex: + isodate.parse_date(await send_request_json_response(request)) + assert "year 0 is out of range" in str(ex.value) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_datetime.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_datetime.py new file mode 100644 index 00000000000..31a6a65ff68 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_datetime.py @@ -0,0 +1,165 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +from async_generator import yield_, async_generator + +from msrest.exceptions import DeserializationError, SerializationError + +from bodydatetimelowlevel.aio import AutoRestDateTimeTestService +from bodydatetimelowlevel.rest import datetime + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestDateTimeTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def get_deserialized_iso(send_request_json_response, msrest_deserializer): + async def _get_deserialized_iso(request): + return msrest_deserializer.deserialize_iso(await send_request_json_response(request)) + return _get_deserialized_iso + +@pytest.fixture +def get_serialized_iso(msrest_serializer): + def _get_serialized_iso(date): + return msrest_serializer.serialize_iso(date) + return _get_serialized_iso + +@pytest.mark.asyncio +async def test_utc_max_date_time(send_request, get_serialized_iso, get_deserialized_iso): + max_date = isodate.parse_datetime("9999-12-31T23:59:59.999Z") + request = datetime.build_get_utc_lowercase_max_date_time_request() + assert max_date == await get_deserialized_iso(request) + + request = datetime.build_get_utc_uppercase_max_date_time_request() + assert await get_deserialized_iso(request) == max_date + + request = datetime.build_put_utc_max_date_time_request(json=get_serialized_iso(max_date)) + await send_request(request) + +@pytest.mark.asyncio +async def test_utc_max_date_time_7digits(send_request, get_serialized_iso, get_deserialized_iso): + max_date = isodate.parse_datetime("9999-12-31T23:59:59.999999Z") + request = datetime.build_get_utc_uppercase_max_date_time7_digits_request() + assert await get_deserialized_iso(request) == max_date + + request = datetime.build_put_utc_max_date_time7_digits_request(json=get_serialized_iso(max_date)) + with pytest.raises(Exception): + # Python doesn't support 7 digits + await send_request(request) + +@pytest.mark.asyncio +async def test_get_utc_min_date_time(send_request, get_serialized_iso, get_deserialized_iso): + min_date = isodate.parse_datetime("0001-01-01T00:00:00Z") + request = datetime.build_get_utc_min_date_time_request() + assert await get_deserialized_iso(request) == min_date + + request = datetime.build_put_utc_min_date_time_request(json=get_serialized_iso(min_date)) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_local_negative_offset_min_date_time(send_request, send_request_json_response, get_serialized_iso): + request = datetime.build_get_local_negative_offset_min_date_time_request() + assert '0001-01-01T00:00:00-14:00' == await send_request_json_response(request) + + request = datetime.build_put_local_negative_offset_min_date_time_request(json=get_serialized_iso(isodate.parse_datetime("0001-01-01T00:00:00-14:00"))) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_local_no_offset_min_date_time(get_deserialized_iso): + local_no_offset_min_date_time = isodate.parse_datetime("0001-01-01T00:00:00") + request = datetime.build_get_local_no_offset_min_date_time_request() + assert await get_deserialized_iso(request) == local_no_offset_min_date_time + +@pytest.mark.asyncio +async def test_get_local_negative_offset_lowercase_max_date_time(send_request_json_response): + request = datetime.build_get_local_negative_offset_lowercase_max_date_time_request() + assert await send_request_json_response(request) == "9999-12-31t23:59:59.999-14:00" + +@pytest.mark.asyncio +async def test_get_local_negative_offset_uppercase_max_date_time(send_request_json_response): + request = datetime.build_get_local_negative_offset_uppercase_max_date_time_request() + assert await send_request_json_response(request) == "9999-12-31T23:59:59.999-14:00" + +@pytest.mark.asyncio +async def test_local_positive_offset_min_date_time(send_request_json_response, get_serialized_iso): + request = datetime.build_get_local_positive_offset_min_date_time_request() + assert await send_request_json_response(request) == "0001-01-01T00:00:00+14:00" + + with pytest.raises(SerializationError): + datetime.build_put_local_positive_offset_min_date_time_request(json=get_serialized_iso(isodate.parse_datetime("0001-01-01T00:00:00+14:00"))) + + +@pytest.mark.asyncio +async def test_local_positive_offset_max_date_time(send_request_json_response, send_request, get_serialized_iso): + request = datetime.build_get_local_positive_offset_lowercase_max_date_time_request() + assert await send_request_json_response(request) == "9999-12-31t23:59:59.999+14:00" + + request = datetime.build_get_local_positive_offset_uppercase_max_date_time_request() + assert await send_request_json_response(request) == "9999-12-31T23:59:59.999+14:00" + + request = datetime.build_put_local_positive_offset_max_date_time_request(json=get_serialized_iso(isodate.parse_datetime("9999-12-31T23:59:59.999999+14:00"))) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_null(send_request, get_serialized_iso, get_deserialized_iso): + request = datetime.build_get_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_get_overflow(send_request_json_response): + request = datetime.build_get_overflow_request() + assert await send_request_json_response(request) == "9999-12-31T23:59:59.999-14:00" + +@pytest.mark.asyncio +async def test_get_invalid(send_request_json_response): + request = datetime.build_get_invalid_request() + assert await send_request_json_response(request) == "201O-18-90D00:89:56.9AX" + +@pytest.mark.asyncio +async def test_get_underflow(send_request_json_response): + request = datetime.build_get_underflow_request() + assert await send_request_json_response(request) == "0000-00-00T00:00:00.000+00:00" + +@pytest.mark.asyncio +async def test_put_local_negative_offset_max_date_time(get_serialized_iso): + with pytest.raises(SerializationError): + datetime.build_put_local_negative_offset_max_date_time_request(json=get_serialized_iso(isodate.parse_datetime("9999-12-31T23:59:59.999999-14:00"))) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_datetime_rfc.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_datetime_rfc.py new file mode 100644 index 00000000000..abecc3b9a0a --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_datetime_rfc.py @@ -0,0 +1,93 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +from async_generator import yield_, async_generator + +from bodydatetimerfc1123lowlevel.aio import AutoRestRFC1123DateTimeTestService +from bodydatetimerfc1123lowlevel.rest import datetimerfc1123 + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestRFC1123DateTimeTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_get_null(send_request): + request = datetimerfc1123.build_get_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_get_invalid(send_request_json_response): + request = datetimerfc1123.build_get_invalid_request() + assert "Tue, 01 Dec 2000 00:00:0A ABC" == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_underflow(send_request_json_response): + request = datetimerfc1123.build_get_underflow_request() + assert "Tue, 00 Jan 0000 00:00:00 GMT" == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_overflow(send_request_json_response): + request = datetimerfc1123.build_get_overflow_request() + assert "Sat, 1 Jan 10000 00:00:00 GMT" == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_utc_max_date_time(send_request, msrest_serializer): + max_date = isodate.parse_datetime("9999-12-31T23:59:59.999999Z") + + request = datetimerfc1123.build_get_utc_lowercase_max_date_time_request() + await send_request(request) + + request = datetimerfc1123.build_get_utc_uppercase_max_date_time_request() + await send_request(request) + + request = datetimerfc1123.build_put_utc_max_date_time_request(json=msrest_serializer.serialize_rfc(max_date)) + await send_request(request) + +@pytest.mark.asyncio +async def test_utc_min_date_time(send_request, msrest_serializer): + min_date = isodate.parse_datetime("0001-01-01T00:00:00Z") + request = datetimerfc1123.build_get_utc_min_date_time_request() + await send_request(request) + + request = datetimerfc1123.build_put_utc_min_date_time_request(json=msrest_serializer.serialize_rfc(min_date)) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_dictionary.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_dictionary.py new file mode 100644 index 00000000000..d0e80f74ce3 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_dictionary.py @@ -0,0 +1,417 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +from datetime import timedelta +from bodydictionarylowlevel.rest import dictionary +from bodydictionarylowlevel.aio import AutoRestSwaggerBATDictionaryService +from azure.core.exceptions import DecodeError +from async_generator import yield_, async_generator + + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestSwaggerBATDictionaryService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def get_deserialized_dict(send_request_json_response): + async def _get_deserialized_dict(request, deserialize_value_callable): + json_response = await send_request_json_response(request) + return { + str(idx): deserialize_value_callable(json_response[key]) if json_response[key] else None + for idx, key in enumerate(json_response.keys()) + } + return _get_deserialized_dict + +@pytest.fixture +def get_serialized_dict(): + def _get_serialized_dict(dict, serialize_value_callable): + return { + k: serialize_value_callable(v) for k, v in dict.items() + } + return _get_serialized_dict + + +@pytest.fixture +@pytest.mark.asyncio +async def test_dict(): + test_product1 = {"integer": 1, "string": "2"} + test_product2 = {"integer": 3, "string": "4"} + test_product3 = {"integer": 5, "string": "6"} + return {"0":test_product1, "1":test_product2, "2":test_product3} + +# Primitive types +@pytest.mark.asyncio +async def test_boolean_tfft(send_request, send_request_json_response): + tfft = {"0":True, "1":False, "2":False, "3":True} + request = dictionary.build_get_boolean_tfft_request() + assert tfft == await send_request_json_response(request) + + request = dictionary.build_put_boolean_tfft_request(json=tfft) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_boolean_invalid(send_request_json_response): + invalid_null_dict = {"0":True, "1":None, "2":False} + request = dictionary.build_get_boolean_invalid_null_request() + assert invalid_null_dict == await send_request_json_response(request) + + request = dictionary.build_get_boolean_invalid_string_request() + assert {"0": True, "1": "boolean", "2": False} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_integer_valid(send_request, send_request_json_response): + int_valid = {"0":1, "1":-1, "2":3, "3":300} + request = dictionary.build_get_integer_valid_request() + assert int_valid == await send_request_json_response(request) + + request = dictionary.build_put_integer_valid_request(json=int_valid) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_int_invalid(send_request_json_response): + int_null_dict = {"0":1, "1":None, "2":0} + request = dictionary.build_get_int_invalid_null_request() + assert int_null_dict == await send_request_json_response(request) + + request = dictionary.build_get_int_invalid_string_request() + assert {"0": 1, "1": "integer", "2": 0} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_long_valid(send_request, send_request_json_response): + long_valid = {"0":1, "1":-1, "2":3, "3":300} + request = dictionary.build_get_long_valid_request() + assert long_valid == await send_request_json_response(request) + + request = dictionary.build_put_long_valid_request(json=long_valid) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_long_invalid(send_request_json_response): + long_null_dict = {"0":1, "1":None, "2":0} + request = dictionary.build_get_long_invalid_null_request() + assert long_null_dict == await send_request_json_response(request) + + request = dictionary.build_get_long_invalid_string_request() + assert {"0": 1, "1": "integer", "2": 0} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_float_valid(send_request, send_request_json_response): + float_valid = {"0":0, "1":-0.01, "2":-1.2e20} + request = dictionary.build_get_float_valid_request() + assert float_valid == await send_request_json_response(request) + + request = dictionary.build_put_float_valid_request(json=float_valid) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_float_invalid(send_request_json_response): + float_null_dict = {"0":0.0, "1":None, "2":-1.2e20} + request = dictionary.build_get_float_invalid_null_request() + assert float_null_dict == await send_request_json_response(request) + + request = dictionary.build_get_float_invalid_string_request() + assert {"0": 1, "1": "number", "2": 0} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_double_valid(send_request, send_request_json_response): + double_valid = {"0":0, "1":-0.01, "2":-1.2e20} + request = dictionary.build_get_double_valid_request() + assert double_valid == await send_request_json_response(request) + + request = dictionary.build_put_double_valid_request(json=double_valid) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_double_invalid(send_request_json_response): + double_null_dict = {"0":0.0, "1":None, "2":-1.2e20} + request = dictionary.build_get_double_invalid_null_request() + assert double_null_dict == await send_request_json_response(request) + + request = dictionary.build_get_double_invalid_string_request() + assert {"0": 1, "1": "number", "2": 0} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_string_valid(send_request, send_request_json_response): + string_valid = {"0":"foo1", "1":"foo2", "2":"foo3"} + request = dictionary.build_get_string_valid_request() + assert string_valid == await send_request_json_response(request) + + request = dictionary.build_put_string_valid_request(json=string_valid) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_string_with_null_and_invalid(send_request_json_response): + string_null_dict = {"0":"foo", "1":None, "2":"foo2"} + string_invalid_dict = {"0":"foo", "1":123, "2":"foo2"} # in llc, we don't know we should serialize this whole thing as string, so serializes 123 as number + request = dictionary.build_get_string_with_null_request() + assert string_null_dict == await send_request_json_response(request) + request = dictionary.build_get_string_with_invalid_request() + assert string_invalid_dict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_date_valid(send_request, get_serialized_dict, get_deserialized_dict, msrest_serializer, msrest_deserializer): + date1 = isodate.parse_date("2000-12-01T00:00:00Z") + date2 = isodate.parse_date("1980-01-02T00:00:00Z") + date3 = isodate.parse_date("1492-10-12T00:00:00Z") + valid_date_dict = {"0":date1, "1":date2, "2":date3} + + request = dictionary.build_get_date_valid_request() + assert await get_deserialized_dict(request, msrest_deserializer.deserialize_date) == valid_date_dict + + request = dictionary.build_put_date_valid_request(json=get_serialized_dict(valid_date_dict, msrest_serializer.serialize_date)) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_date_invalid(send_request_json_response, msrest_deserializer, get_deserialized_dict): + date_null_dict = {"0":isodate.parse_date("2012-01-01"), + "1":None, + "2":isodate.parse_date("1776-07-04")} + request = dictionary.build_get_date_invalid_null_request() + assert date_null_dict == await get_deserialized_dict(request, msrest_deserializer.deserialize_date) + + request = dictionary.build_get_date_invalid_chars_request() + assert {"0": "2011-03-22", "1": "date"} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_date_time_valid(send_request, get_deserialized_dict, get_serialized_dict, msrest_serializer, msrest_deserializer): + datetime1 = isodate.parse_datetime("2000-12-01T00:00:01Z") + datetime2 = isodate.parse_datetime("1980-01-02T00:11:35+01:00") + datetime3 = isodate.parse_datetime("1492-10-12T10:15:01-08:00") + valid_datetime_dict = {"0":datetime1, "1":datetime2, "2":datetime3} + + request = dictionary.build_get_date_time_valid_request() + assert valid_datetime_dict == await get_deserialized_dict(request, msrest_deserializer.deserialize_iso) + + request = dictionary.build_put_date_time_valid_request( + json=get_serialized_dict(valid_datetime_dict, msrest_serializer.serialize_iso) + ) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_date_time_invalid(send_request_json_response, msrest_deserializer, get_deserialized_dict): + datetime_null_dict = {"0":isodate.parse_datetime("2000-12-01T00:00:01Z"), "1":None} + request = dictionary.build_get_date_time_invalid_null_request() + assert datetime_null_dict == await get_deserialized_dict(request, msrest_deserializer.deserialize_iso) + + request = dictionary.build_get_date_time_invalid_chars_request() + assert {"0": "2000-12-01t00:00:01z", "1": "date-time"} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_date_time_rfc1123_valid(send_request, get_deserialized_dict, get_serialized_dict, msrest_serializer, msrest_deserializer): + rfc_datetime1 = isodate.parse_datetime("2000-12-01T00:00:01Z") + rfc_datetime2 = isodate.parse_datetime("1980-01-02T00:11:35Z") + rfc_datetime3 = isodate.parse_datetime("1492-10-12T10:15:01Z") + valid_rfc_dict = {"0":rfc_datetime1, "1":rfc_datetime2, "2":rfc_datetime3} + + request = dictionary.build_get_date_time_rfc1123_valid_request() + assert valid_rfc_dict == await get_deserialized_dict(request, msrest_deserializer.deserialize_rfc) + + request = dictionary.build_put_date_time_rfc1123_valid_request(json=get_serialized_dict(valid_rfc_dict, msrest_serializer.serialize_rfc)) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_duration_valid(send_request, msrest_serializer, msrest_deserializer, get_deserialized_dict, get_serialized_dict): + duration1 = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + duration2 = timedelta(days=5, hours=1) + valid_duration_dict = {"0":duration1, "1":duration2} + + request = dictionary.build_get_duration_valid_request() + assert valid_duration_dict == await get_deserialized_dict(request, msrest_deserializer.deserialize_duration) + + request = dictionary.build_put_duration_valid_request(json=get_serialized_dict(valid_duration_dict, msrest_serializer.serialize_duration)) + await send_request(request) + +@pytest.mark.asyncio +async def test_bytes_valid(send_request, msrest_serializer, msrest_deserializer, get_serialized_dict, get_deserialized_dict): + bytes1 = bytearray([0x0FF, 0x0FF, 0x0FF, 0x0FA]) + bytes2 = bytearray([0x01, 0x02, 0x03]) + bytes3 = bytearray([0x025, 0x029, 0x043]) + bytes4 = bytearray([0x0AB, 0x0AC, 0x0AD]) + + bytes_valid = {"0":bytes1, "1":bytes2, "2":bytes3} + request = dictionary.build_put_byte_valid_request(json=get_serialized_dict(bytes_valid, msrest_serializer.serialize_bytearray)) + await send_request(request) + + request = dictionary.build_get_byte_valid_request() + assert bytes_valid == await get_deserialized_dict(request, msrest_deserializer.deserialize_bytearray) + +@pytest.mark.asyncio +async def test_get_byte_invalid_null(msrest_deserializer, get_deserialized_dict): + bytes4 = bytearray([0x0AB, 0x0AC, 0x0AD]) + bytes_null = {"0":bytes4, "1":None} + request = dictionary.build_get_byte_invalid_null_request() + assert bytes_null == await get_deserialized_dict(request, msrest_deserializer.deserialize_bytearray) +@pytest.mark.asyncio +async def test_get_base64_url(msrest_deserializer, get_deserialized_dict): + test_dict = {'0': 'a string that gets encoded with base64url'.encode(), + '1': 'test string'.encode(), + '2': 'Lorem ipsum'.encode()} + request = dictionary.build_get_base64_url_request() + assert test_dict == await get_deserialized_dict(request, msrest_deserializer.deserialize_base64) + +# Basic dictionary parsing +@pytest.mark.asyncio +async def test_empty(send_request, send_request_json_response): + + request = dictionary.build_get_empty_request() + assert {} == await send_request_json_response(request) + + request = dictionary.build_put_empty_request(json={}) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_null_and_invalid(send_request, send_request_json_response): + + request = dictionary.build_get_null_request() + assert (await send_request(request)).text == '' + + request = dictionary.build_get_invalid_request() + with pytest.raises(DecodeError): + await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_null_key_and_value(send_request, send_request_json_response): + # {null:"val1"} is not standard JSON format. C# might work and expects this test to pass, + # but we fail and we're happy with it. + request = dictionary.build_get_null_key_request() + with pytest.raises(DecodeError): + await send_request_json_response(request) + + request = dictionary.build_get_null_value_request() + assert {"key1":None} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_empty_string_key(send_request_json_response): + request = dictionary.build_get_empty_string_key_request() + assert {"":"val1"} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_complex_valid(send_request, send_request_json_response, test_dict): + + request = dictionary.build_put_complex_valid_request(json=test_dict) + await send_request(request) + + request = dictionary.build_get_complex_valid_request() + assert test_dict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_array_valid(send_request, send_request_json_response): + list_dict = {"0":["1","2","3"], "1":["4","5","6"], "2":["7","8","9"]} + + request = dictionary.build_put_array_valid_request(json=list_dict) + await send_request(request) + + request = dictionary.build_get_array_valid_request() + assert list_dict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_dictionary_valid(send_request, send_request_json_response): + dict_dict = {"0":{"1":"one","2":"two","3":"three"}, + "1":{"4":"four","5":"five","6":"six"}, + "2":{"7":"seven","8":"eight","9":"nine"}} + + request = dictionary.build_put_dictionary_valid_request(json=dict_dict) + await send_request(request) + + request = dictionary.build_get_dictionary_valid_request() + assert dict_dict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_complex_null_and_empty(send_request, send_request_json_response): + + request = dictionary.build_get_complex_null_request() + assert (await send_request(request)).text == '' + + request = dictionary.build_get_complex_empty_request() + assert {} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_complex_item_null_and_empty(send_request_json_response, test_dict): + test_dict_null = {"0":test_dict["0"], "1":None, "2":test_dict["2"]} + + request = dictionary.build_get_complex_item_null_request() + assert test_dict_null == await send_request_json_response(request) + + test_dict_empty = {"0":test_dict["0"], "1": {}, "2":test_dict["2"]} + + request = dictionary.build_get_complex_item_empty_request() + assert await send_request_json_response(request) == test_dict_empty + +@pytest.mark.asyncio +async def test_get_array_empty(send_request, send_request_json_response): + request = dictionary.build_get_array_null_request() + assert (await send_request(request)).text == '' + + request = dictionary.build_get_array_empty_request() + assert {} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_array_item_null_and_empty(send_request_json_response): + list_dict = {"0":["1","2","3"], "1":None, "2":["7","8","9"]} + request = dictionary.build_get_array_item_null_request() + assert list_dict == await send_request_json_response(request) + + # in convenience layer, we deserialize as {[str]}. Since we don't have that in llc, the value for "1" will be None, not an empty list + list_dict = {"0":["1","2","3"], "1":None, "2":["7","8","9"]} + assert list_dict == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_dictionary_null_and_empty(send_request, send_request_json_response): + request = dictionary.build_get_dictionary_null_request() + assert (await send_request(request)).text == '' + + request = dictionary.build_get_dictionary_empty_request() + assert {} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_get_dictionary_item_null_and_empty(send_request, send_request_json_response): + dict_dict = {"0":{"1":"one","2":"two","3":"three"}, + "1":None, + "2":{"7":"seven","8":"eight","9":"nine"}} + request = dictionary.build_get_dictionary_item_null_request() + assert dict_dict == await send_request_json_response(request) + + dict_dict = {"0":{"1":"one","2":"two","3":"three"}, + "1":{}, + "2":{"7":"seven","8":"eight","9":"nine"}} + request = dictionary.build_get_dictionary_item_empty_request() + assert dict_dict == await send_request_json_response(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_duration.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_duration.py new file mode 100644 index 00000000000..00fee3ca84b --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_duration.py @@ -0,0 +1,69 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from datetime import timedelta +from async_generator import yield_, async_generator +import isodate + +from bodydurationlowlevel.aio import AutoRestDurationTestService +from bodydurationlowlevel.rest import duration + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestDurationTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_get_null_and_invalid(send_request, send_request_json_response): + request = duration.build_get_null_request() + assert (await send_request(request)).text == '' + + request = duration.build_get_invalid_request() + with pytest.raises(isodate.ISO8601Error): + isodate.parse_duration(await send_request_json_response(request)) + +@pytest.mark.asyncio +async def test_positive_duration(send_request, send_request_json_response): + request = duration.build_get_positive_duration_request() + assert isodate.duration.Duration(4, 45005, 0, years=3, months=6) == isodate.parse_duration(await send_request_json_response(request)) + + request = duration.build_put_positive_duration_request(json=isodate.duration_isoformat(timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11))) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_extensible_enums.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_extensible_enums.py new file mode 100644 index 00000000000..19c7df3a771 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_extensible_enums.py @@ -0,0 +1,77 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from async_generator import yield_, async_generator + +from extensibleenumsswaggerlowlevel.aio import PetStoreInc +from extensibleenumsswaggerlowlevel.rest import pet + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with PetStoreInc(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_get_by_pet_id(send_request_json_response): + # Now enum return are always string (Autorest.Python 3.0) + + request = pet.build_get_by_pet_id_request(pet_id="tommy") + tommy = await send_request_json_response(request) + assert tommy["DaysOfWeek"] == "Monday" + assert tommy["IntEnum"] == "1" + + request = pet.build_get_by_pet_id_request(pet_id="casper") + casper = await send_request_json_response(request) + assert casper["DaysOfWeek"] == "Weekend" + assert casper["IntEnum"] == "2" + + request = pet.build_get_by_pet_id_request(pet_id="scooby") + scooby = await send_request_json_response(request) + assert scooby["DaysOfWeek"] == "Thursday" + # https://github.com/Azure/autorest.csharp/blob/e5f871b7433e0f6ca6a17307fba4a2cfea4942b4/test/vanilla/AcceptanceTests.cs#L429 + # "allowedValues" of "x-ms-enum" is not supported in Python + assert scooby["IntEnum"] == "2.1" # Might be "2" if one day Python is supposed to support "allowedValues" + +@pytest.mark.asyncio +async def test_add_pet(send_request_json_response): + retriever = { + "name": "Retriever", + "IntEnum": "3", + "DaysOfWeek": "Friday" + } + request = pet.build_add_pet_request(json=retriever) + returned_pet = await send_request_json_response(request) + assert returned_pet["DaysOfWeek"] == "Friday" + assert returned_pet["IntEnum"] == "3" + assert returned_pet["name"] == "Retriever" diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_file.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_file.py new file mode 100644 index 00000000000..ff521bec527 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_file.py @@ -0,0 +1,99 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +from os.path import dirname, pardir, join, realpath +import io +from bodyfilelowlevel.aio import AutoRestSwaggerBATFileService +from bodyfilelowlevel.rest.files import * + +import pytest + +cwd = dirname(realpath(__file__)) + + +@pytest.fixture +@async_generator +async def client(connection_data_block_size=None): + async with AutoRestSwaggerBATFileService( + base_url="http://localhost:3000", connection_data_block_size=connection_data_block_size + ) as client: + await yield_(client) + + +@pytest.mark.asyncio +@pytest.mark.parametrize('client', [1000], indirect=True) +async def test_get_file(client): + file_length = 0 + with io.BytesIO() as file_handle: + request = build_get_file_request() + async with client.send_request(request, stream=True) as response: + assert not response._internal_response._released + assert not response.is_closed + assert not response.is_stream_consumed + async for data in response.iter_raw(): + # assert 0 < len(data) <= stream.block_size + file_length += len(data) + file_handle.write(data) + + assert file_length != 0 + assert response.is_closed + assert response.is_stream_consumed + assert response._internal_response._released + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + +@pytest.mark.asyncio +@pytest.mark.parametrize('client', [4096], indirect=True) +async def test_get_empty_file(client): + file_length = 0 + with io.BytesIO() as file_handle: + request = build_get_empty_file_request() + async with client.send_request(request, stream=True) as response: + assert not response._internal_response._released + + async for data in response.iter_raw(): + file_length += len(data) + file_handle.write(data) + + assert file_length == 0 + +@pytest.mark.asyncio +@pytest.mark.parametrize('client', [4096], indirect=True) +async def test_files_long_running(client): + file_length = 0 + request = build_get_file_large_request() + async with client.send_request(request, stream=True) as response: + async for data in response.iter_bytes(): + assert 0 < len(data) <= response._connection_data_block_size + file_length += len(data) + + assert file_length == 3000 * 1024 * 1024 diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_form_data.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_form_data.py new file mode 100644 index 00000000000..72a761a73d6 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_form_data.py @@ -0,0 +1,158 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from async_generator import yield_, async_generator +import subprocess +import sys +import io +import os +import tempfile +from os.path import dirname, pardir, join, realpath + +cwd = dirname(realpath(__file__)) +log_level = int(os.environ.get('PythonLogLevel', 30)) + +tests = realpath(join(cwd, pardir, "Expected", "AcceptanceTests")) +sys.path.append(join(tests, "BodyFormData")) + + +from bodyformdatalowlevel.aio import AutoRestSwaggerBATFormDataService +from bodyformdatalowlevel.rest import formdata +import pytest + +@pytest.fixture +def dummy_file(): + with tempfile.NamedTemporaryFile(mode='w', delete=False) as dummy: + dummy.write("Test file") + # Get outside of the "with", so file can be re-opened on Windows + yield dummy.name + os.remove(dummy.name) + +@pytest.fixture +@async_generator +async def client(connection_data_block_size=None): + async with AutoRestSwaggerBATFormDataService( + base_url="http://localhost:3000", + connection_data_block_size = 2, + retry_total = 50, # Be agressive on this test, sometimes testserver DDOS :-p + retry_backoff_factor = 1.6 + ) as client: + await yield_(client) + +@pytest.mark.asyncio +async def test_file_upload_stream(client): + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + result = io.BytesIO() + with io.BytesIO(test_bytes) as stream_data: + files = { + "fileContent": stream_data, + "fileName": "UploadFile.txt", + } + request = formdata.build_upload_file_request(files=files) + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + async for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == test_string + +@pytest.mark.asyncio +async def test_file_upload_file_stream(client, dummy_file): + + name = os.path.basename(dummy_file) + result = io.BytesIO() + with open(dummy_file, 'rb') as upload_data: + files = { + "fileContent": upload_data, + "fileName": name, + } + request = formdata.build_upload_file_request(files=files) + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + async for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == "Test file" + +@pytest.mark.asyncio +async def test_file_body_upload(client, dummy_file): + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + + result = io.BytesIO() + with io.BytesIO(test_bytes) as stream_data: + request = formdata.build_upload_file_via_body_request(content=stream_data) + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + async for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == test_string + + result = io.BytesIO() + with open(dummy_file, 'rb') as upload_data: + request = formdata.build_upload_file_via_body_request(content=upload_data) + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + async for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == "Test file" + +@pytest.mark.asyncio +async def test_file_body_upload_generator(client, dummy_file): + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + + @async_generator + async def stream_upload(data, length, block_size): + progress = 0 + while True: + block = data.read(block_size) + progress += len(block) + print("Progress... {}%".format(int(progress*100/length))) + if not block: + break + await yield_(block) + + result = io.BytesIO() + with io.BytesIO(test_bytes) as stream_data: + streamed_upload = stream_upload(stream_data, len(test_string), 2) + request = formdata.build_upload_file_via_body_request(content=streamed_upload, headers={"Content-Type": "application/octet-stream"}) + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + async for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == test_string + + result = io.BytesIO() + with open(dummy_file, 'rb') as upload_data: + streamed_upload = stream_upload(upload_data, len("Test file"), 2) + request = formdata.build_upload_file_via_body_request(content=streamed_upload) + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + async for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == "Test file" \ No newline at end of file diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_header.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_header.py new file mode 100644 index 00000000000..a4ec81cb6b7 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_header.py @@ -0,0 +1,248 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +from datetime import datetime, timedelta +from async_generator import yield_, async_generator +from base64 import b64decode + +from headerlowlevel.aio import AutoRestSwaggerBATHeaderService +from headerlowlevel.rest import header + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestSwaggerBATHeaderService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_value_response_header(client, base_send_request): + async def _send_request(request): + return (await base_send_request(client, request)).headers['value'] + return _send_request + +# NOTE: in llc, we don't know to deserialize response headers as int / datetime etc. So you'll see they'll just be strings, not ints etc +@pytest.mark.asyncio +async def test_integer(send_request, send_request_value_response_header): + + request = header.build_param_integer_request(scenario="positive", value=1) + await send_request(request) + request = header.build_param_integer_request(scenario="negative", value=-2) + await send_request(request) + + request = header.build_response_integer_request(scenario="positive") + assert await send_request_value_response_header(request) == "1" + + request = header.build_response_integer_request(scenario="negative") + assert await send_request_value_response_header(request) == "-2" + +@pytest.mark.asyncio +async def test_long(send_request, send_request_value_response_header): + request = header.build_param_long_request(scenario="positive", value=105) + await send_request(request) + request = header.build_param_long_request(scenario="negative", value=-2) + await send_request(request) + + request = header.build_response_long_request(scenario="positive") + assert await send_request_value_response_header(request) == "105" + + request = header.build_response_long_request(scenario="negative") + assert await send_request_value_response_header(request) == "-2" + +@pytest.mark.asyncio +async def test_float(send_request, send_request_value_response_header): + request = header.build_param_float_request(scenario="positive", value=0.07) + await send_request(request) + + request = header.build_param_float_request(scenario="negative", value=-3.0) + await send_request(request) + + request = header.build_response_float_request(scenario="positive") + assert abs(0.07 - float(await send_request_value_response_header(request))) < 0.00001 + + request = header.build_response_float_request(scenario="negative") + assert abs(-3.0 - float(await send_request_value_response_header(request))) < 0.00001 + +@pytest.mark.asyncio +async def test_double(send_request, send_request_value_response_header): + request = header.build_param_double_request(scenario="positive", value=7e120) + await send_request(request) + + request = header.build_param_double_request(scenario="negative", value=-3.0) + await send_request(request) + + request = header.build_response_double_request(scenario="positive") + assert await send_request_value_response_header(request) == "7e+120" + + request = header.build_response_double_request(scenario="negative") + assert await send_request_value_response_header(request) == "-3" + +@pytest.mark.asyncio +async def test_bool(send_request, send_request_value_response_header): + request = header.build_param_bool_request(scenario="true", value=True) + await send_request(request) + request = header.build_param_bool_request(scenario="false", value=False) + await send_request(request) + + request = header.build_response_bool_request(scenario="true") + assert await send_request_value_response_header(request) == 'true' + + request = header.build_response_bool_request(scenario="false") + assert await send_request_value_response_header(request) == 'false' + +@pytest.mark.asyncio +async def test_string(send_request, send_request_value_response_header): + request = header.build_param_string_request(scenario="valid", value="The quick brown fox jumps over the lazy dog") + await send_request(request) + + request = header.build_param_string_request(scenario="null", value=None) + await send_request(request) + + request = header.build_param_string_request(scenario="empty", value="") + await send_request(request) + + request = header.build_response_string_request(scenario="valid") + assert await send_request_value_response_header(request) == "The quick brown fox jumps over the lazy dog" + + request = header.build_response_string_request(scenario="null") + assert await send_request_value_response_header(request) == "null" # TODO This should be None + + request = header.build_response_string_request(scenario="empty") + assert await send_request_value_response_header(request) == "" + +@pytest.mark.asyncio +async def test_enum(send_request, send_request_value_response_header): + request = header.build_param_enum_request(scenario="valid", value="GREY") + await send_request(request) + + request = header.build_param_enum_request(scenario="valid", value="GREY") + await send_request(request) + + request = header.build_param_enum_request(scenario="null", value=None) + await send_request(request) + + + request = header.build_response_enum_request(scenario="valid") + assert await send_request_value_response_header(request) == "GREY" + + # We receive an empty string. + # Starting msrest 0.4.22, we consider that if a string is not in the enum, this not + # a Deserialization issue and we return the string. + # Here we now return empty string without failin **on purpose** + # with pytest.raises(DeserializationError): + request = header.build_response_enum_request(scenario="null") + assert await send_request_value_response_header(request) == "" + +@pytest.mark.asyncio +async def test_date(send_request, send_request_value_response_header): + request = header.build_param_date_request(scenario="valid", value=isodate.parse_date("2010-01-01")) + await send_request(request) + request = header.build_param_date_request(scenario="min", value=datetime.min) + await send_request(request) + + request = header.build_response_date_request(scenario="valid") + assert await send_request_value_response_header(request) == str(isodate.parse_date("2010-01-01")) + + request = header.build_response_date_request(scenario="min") + assert await send_request_value_response_header(request) == str(isodate.parse_date("0001-01-01")) + +@pytest.mark.asyncio +async def test_datetime(send_request, send_request_value_response_header): + request = header.build_param_datetime_request(scenario="valid", value=isodate.parse_datetime("2010-01-01T12:34:56Z")) + await send_request(request) + request = header.build_param_datetime_request(scenario="min", value=datetime.min) + await send_request(request) + + request = header.build_response_datetime_request(scenario="valid") + assert await send_request_value_response_header(request) == '2010-01-01T12:34:56Z' + + request = header.build_response_datetime_request(scenario="min") + assert await send_request_value_response_header(request) == '0001-01-01T00:00:00Z' + +@pytest.mark.asyncio +async def test_datetime_rfc(send_request, send_request_value_response_header): + request = header.build_param_datetime_rfc1123_request(scenario="valid", value=isodate.parse_datetime("2010-01-01T12:34:56Z")) + await send_request(request) + + request = header.build_param_datetime_rfc1123_request(scenario="min", value=datetime.min) + await send_request(request) + + request = header.build_response_datetime_rfc1123_request(scenario="valid") + assert await send_request_value_response_header(request) == "Fri, 01 Jan 2010 12:34:56 GMT" + + # we are not using the min date of year 1 because of the latest msrest update + # with msrest update, minimal year we can parse is 100, instead of 1 + request = header.build_response_datetime_rfc1123_request(scenario="min") + assert await send_request_value_response_header(request) == "Mon, 01 Jan 0001 00:00:00 GMT" + +@pytest.mark.asyncio +async def test_duration(send_request, send_request_value_response_header): + request = header.build_param_duration_request(scenario="valid", value=timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11)) + await send_request(request) + + request = header.build_response_duration_request(scenario="valid") + assert await send_request_value_response_header(request) == 'P123DT22H14M12.011S' # raw str of the above timedelta + +@pytest.mark.asyncio +async def test_byte(send_request, send_request_value_response_header): + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + request = header.build_param_byte_request(scenario="valid", value=u_bytes) + await send_request(request) + + request = header.build_response_byte_request(scenario="valid") + assert bytearray(b64decode(await send_request_value_response_header(request))) == u_bytes + +@pytest.mark.asyncio +async def test_response_existing_key(send_request): + + request = header.build_param_existing_key_request(user_agent_parameter="overwrite") + await send_request(request) + request = header.build_response_existing_key_request() + assert (await send_request(request)).headers['User-Agent'] == "overwrite" + +@pytest.mark.asyncio +async def test_response_protected_key(send_request): + # This test is only valid for C#, which content-type can't be override this way + #client.header.param_protected_key("text/html") + + # This test has different result compare to C#, which content-type is saved in another place. + request = header.build_response_protected_key_request() + assert (await send_request(request)).headers['Content-Type'] == "text/html; charset=utf-8" + +@pytest.mark.xfail(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +@pytest.mark.asyncio +async def test_custom_request_id(send_request): + custom_headers = {"x-ms-client-request-id": "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} + request = header.build_custom_request_id_request(headers=custom_headers) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_http.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_http.py new file mode 100644 index 00000000000..568da1e4415 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_http.py @@ -0,0 +1,536 @@ +# -------------------------------------------------------------------------- +# +# 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 requests +from async_generator import yield_, async_generator + +from azure.core.exceptions import HttpResponseError +from azure.core.pipeline.policies import ContentDecodePolicy, AsyncRetryPolicy, HeadersPolicy, AsyncRedirectPolicy + +from httpinfrastructurelowlevel.aio import AutoRestHttpInfrastructureTestService +from httpinfrastructurelowlevel.rest import ( + multiple_responses, + http_server_failure, + http_failure, + http_redirects, + http_retry, + http_success, + http_client_failure, +) + +import pytest + + +@pytest.fixture +@async_generator +async def client(cookie_policy): + """Create a AutoRestHttpInfrastructureTestService client with test server credentials.""" + policies = [ + HeadersPolicy(), + ContentDecodePolicy(), + AsyncRedirectPolicy(), + AsyncRetryPolicy(), + cookie_policy + ] + async with AutoRestHttpInfrastructureTestService(base_url="http://localhost:3000", policies=policies) as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def send_request_assert_status(client, base_send_request): + async def _send_request(request, status_code): + response = await base_send_request(client, request) + assert response.status_code == status_code + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_message(client, base_send_request): + async def _send_request(request, message): + with pytest.raises(HttpResponseError) as ex: + await base_send_request(client, request) + assert ex.value.message == message + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_status(client, base_send_request): + async def _send_request(request, status_code): + with pytest.raises(HttpResponseError) as ex: + await base_send_request(client, request) + assert ex.value.status_code == status_code + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_status_and_message(client, base_send_request): + async def _send_request(request, status_code, message): + with pytest.raises(HttpResponseError) as ex: + await base_send_request(client, request) + assert ex.value.status_code == status_code + assert ex.value.message == message + assert message in str(ex.value) + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_status_and_response_contains_message(client, base_send_request): + async def _send_request(request, status_code, message): + with pytest.raises(HttpResponseError) as ex: + await base_send_request(client, request) + assert ex.value.status_code == status_code + assert ex.value.response.json()['message'] == message + return _send_request + +@pytest.mark.asyncio +async def test_get200_model204(send_request, send_request_assert_status, send_request_assert_raises_with_status_and_response_contains_message): + # a lot of these tests raised in high level bc we made some 200 status codes errors in high level + # can't do this in low level, so these don't actually raise + request = multiple_responses.build_get200_model204_no_model_default_error200_valid_request() + await send_request_assert_status(request, 200) + + request = multiple_responses.build_get200_model204_no_model_default_error201_invalid_request() + await send_request_assert_status(request, 201) + + request = multiple_responses.build_get200_model204_no_model_default_error202_none_request() + await send_request_assert_status(request, 202) + + request = multiple_responses.build_get200_model204_no_model_default_error204_valid_request() + + assert (await send_request(request)).text == '' + + request = multiple_responses.build_get200_model204_no_model_default_error400_valid_request() + await send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + +@pytest.mark.asyncio +async def test_get200_model201(send_request_json_response, send_request_assert_status, send_request_assert_raises_with_status_and_response_contains_message): + request = multiple_responses.build_get200_model201_model_default_error200_valid_request() + await send_request_assert_status(request, 200) + + request = multiple_responses.build_get200_model201_model_default_error201_valid_request() + b_model = await send_request_json_response(request) + assert b_model is not None + assert b_model['statusCode'] == "201" + assert b_model['textStatusCode'] == "Created" + + request = multiple_responses.build_get200_model201_model_default_error400_valid_request() + await send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + +@pytest.mark.asyncio +async def test_get200_model_a201_model_c404(send_request_json_response, send_request_assert_raises_with_status_and_response_contains_message, send_request_assert_raises_with_status): + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error200_valid_request() + a_model = await send_request_json_response(request) + assert a_model['statusCode']== "200" + + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error201_valid_request() + + c_model = await send_request_json_response(request) + assert c_model['httpCode'] == "201" + + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error404_valid_request() + await send_request_assert_raises_with_status(request, 404) # in high level, this doesn't raise and returns a model since we've made 404 a valid status code. can't do that in llc + + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error400_valid_request() + await send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + +@pytest.mark.asyncio +async def test_get202_none204(send_request, send_request_assert_raises_with_status, send_request_assert_raises_with_status_and_response_contains_message): + request = multiple_responses.build_get202_none204_none_default_error202_none_request() + await send_request(request) + + request = multiple_responses.build_get202_none204_none_default_error204_none_request() + await send_request(request) + + request = multiple_responses.build_get202_none204_none_default_error400_valid_request() + await send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + + request = multiple_responses.build_get202_none204_none_default_none202_invalid_request() + await send_request(request) + + request = multiple_responses.build_get202_none204_none_default_none204_none_request() + await send_request(request) + + request = multiple_responses.build_get202_none204_none_default_none400_none_request() + await send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get202_none204_none_default_none400_invalid_request() + await send_request_assert_raises_with_status(request, 400) + +@pytest.mark.asyncio +async def test_get_default_model_a200(send_request, send_request_assert_status): + request = multiple_responses.build_get_default_model_a200_valid_request() + await send_request_assert_status(request, 200) + + request = multiple_responses.build_get_default_model_a200_none_request() + assert (await send_request(request)).text == '' + + request = multiple_responses.build_get_default_model_a200_valid_request() + await send_request(request) + request = multiple_responses.build_get_default_model_a200_none_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_get_default_none200(send_request): + request = multiple_responses.build_get_default_none200_invalid_request() + await send_request(request) + + requst = multiple_responses.build_get_default_none200_none_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_get_default_none400(send_request_assert_raises_with_status): + request = multiple_responses.build_get_default_none400_invalid_request() + await send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get_default_none400_none_request() + await send_request_assert_raises_with_status(request, 400) + +@pytest.mark.asyncio +async def test_get200_model_a200(send_request, send_request_assert_status): + request = multiple_responses.build_get200_model_a200_none_request() + assert (await send_request(request)).text == '' + + request = multiple_responses.build_get200_model_a200_valid_request() + await send_request_assert_status(request, 200) + + request = multiple_responses.build_get200_model_a200_invalid_request() + await send_request_assert_status(request, 200) # in high level it's supposed to deserialize as exception model "MyException", can't do that in LLC + +@pytest.mark.asyncio +async def test_get200_model_a400(send_request_assert_raises_with_status): + request = multiple_responses.build_get200_model_a400_none_request() + await send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get200_model_a400_valid_request() + await send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get200_model_a400_invalid_request() + await send_request_assert_raises_with_status(request, 400) + +@pytest.mark.asyncio +async def test_get200_model_a202(send_request_assert_status): + request = multiple_responses.build_get200_model_a202_valid_request() + await send_request_assert_status(request, 202) # raises in HLC bc we've marked all status codes that are not "200" as errors + +@pytest.mark.asyncio +async def test_server_error_status_codes_501(send_request_assert_raises_with_status): + request = http_server_failure.build_head501_request() + await send_request_assert_raises_with_status(request, requests.codes.not_implemented) + + request = http_server_failure.build_get501_request() + await send_request_assert_raises_with_status(request, requests.codes.not_implemented) + +@pytest.mark.asyncio +async def test_server_error_status_codes_505(send_request_assert_raises_with_status): + request = http_server_failure.build_post505_request() + await send_request_assert_raises_with_status(request, requests.codes.http_version_not_supported) + + request = http_server_failure.build_delete505_request() + await send_request_assert_raises_with_status(request, requests.codes.http_version_not_supported) + +@pytest.mark.asyncio +async def test_retry_status_codes_408(send_request): + request = http_retry.build_head408_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_retry_status_codes_502(send_request): + request = http_retry.build_get502_request() + await send_request(request) + + # TODO, 4042586: Support options operations in swagger modeler + #client.http_retry.options429() + +@pytest.mark.asyncio +async def test_retry_status_codes_500(send_request): + request = http_retry.build_put500_request() + await send_request(request) + request = http_retry.build_patch500_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_retry_status_codes_503(send_request): + request = http_retry.build_post503_request() + await send_request(request) + + request = http_retry.build_delete503_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_retry_status_codes_504(send_request): + request = http_retry.build_put504_request() + await send_request(request) + + request = http_retry.build_patch504_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_error_status_codes_400(send_request_assert_raises_with_status): + request = http_client_failure.build_head400_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_get400_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.bad_request, + # client.http_client_failure.options400) + + request = http_client_failure.build_put400_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_patch400_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_post400_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_delete400_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) + +@pytest.mark.asyncio +async def test_error_status_codes_401(send_request_assert_raises_with_status): + request = http_client_failure.build_head401_request() + await send_request_assert_raises_with_status(request, requests.codes.unauthorized) + +@pytest.mark.asyncio +async def test_error_status_codes_402(send_request_assert_raises_with_status): + request = http_client_failure.build_get402_request() + await send_request_assert_raises_with_status(request, requests.codes.payment_required) + +@pytest.mark.asyncio +async def test_error_status_codes_403(send_request_assert_raises_with_status): + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.forbidden, + # client.http_client_failure.options403) + + request = http_client_failure.build_get403_request() + await send_request_assert_raises_with_status(request, requests.codes.forbidden) + +@pytest.mark.asyncio +async def test_error_status_codes_404(send_request_assert_raises_with_status): + request = http_client_failure.build_put404_request() + await send_request_assert_raises_with_status(request, requests.codes.not_found) + +@pytest.mark.asyncio +async def test_error_status_codes_405(send_request_assert_raises_with_status): + request = http_client_failure.build_patch405_request() + await send_request_assert_raises_with_status(request, requests.codes.method_not_allowed) + +@pytest.mark.asyncio +async def test_error_status_codes_406(send_request_assert_raises_with_status): + request = http_client_failure.build_post406_request() + await send_request_assert_raises_with_status(request, requests.codes.not_acceptable) + +@pytest.mark.asyncio +async def test_error_status_codes_407(send_request_assert_raises_with_status): + request = http_client_failure.build_delete407_request() + await send_request_assert_raises_with_status(request, requests.codes.proxy_authentication_required) + +@pytest.mark.asyncio +async def test_error_status_codes_409(send_request_assert_raises_with_status): + request = http_client_failure.build_put409_request() + await send_request_assert_raises_with_status(request, requests.codes.conflict) + +@pytest.mark.asyncio +async def test_error_status_codes_410(send_request_assert_raises_with_status): + request = http_client_failure.build_head410_request() + await send_request_assert_raises_with_status(request, requests.codes.gone) + +@pytest.mark.asyncio +async def test_error_status_codes_411(send_request_assert_raises_with_status): + + request = http_client_failure.build_get411_request() + await send_request_assert_raises_with_status(request, requests.codes.length_required) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.precondition_failed, + # client.http_client_failure.options412) + + request = http_client_failure.build_get412_request() + await send_request_assert_raises_with_status(request, requests.codes.precondition_failed) + + request = http_client_failure.build_put413_request() + await send_request_assert_raises_with_status(request, requests.codes.request_entity_too_large) + + request = http_client_failure.build_patch414_request() + await send_request_assert_raises_with_status(request, requests.codes.request_uri_too_large) + + request = http_client_failure.build_post415_request() + await send_request_assert_raises_with_status(request, requests.codes.unsupported_media) + + request = http_client_failure.build_get416_request() + await send_request_assert_raises_with_status(request, requests.codes.requested_range_not_satisfiable) + + request = http_client_failure.build_delete417_request() + await send_request_assert_raises_with_status(request, requests.codes.expectation_failed) + + request = http_client_failure.build_head429_request() + await send_request_assert_raises_with_status(request, 429) + +@pytest.mark.asyncio +async def test_redirect_to_300(send_request_assert_status): + request = http_redirects.build_get300_request() + await send_request_assert_status(request, 200) + +@pytest.mark.asyncio +async def test_redirect_to_301(send_request_assert_status): + request = http_redirects.build_head301_request() + await send_request_assert_status(request, 200) + + + request = http_redirects.build_get301_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_put301_request() + await send_request_assert_status(request, requests.codes.moved_permanently) + +@pytest.mark.asyncio +async def test_redirect_to_302(send_request_assert_status): + request = http_redirects.build_head302_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_get302_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_patch302_request() + await send_request_assert_status(request, requests.codes.found) + +@pytest.mark.asyncio +async def test_redicret_to_303(send_request_assert_status): + request = http_redirects.build_post303_request() + await send_request_assert_status(request, 200) + +@pytest.mark.asyncio +async def test_redirect_to_307(send_request_assert_status): + request = http_redirects.build_head307_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_get307_request() + await send_request_assert_status(request, 200) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_status(200, client.http_redirects.options307) + request = http_redirects.build_put307_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_post307_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_patch307_request() + await send_request_assert_status(request, 200) + + request = http_redirects.build_delete307_request() + await send_request_assert_status(request, 200) + +@pytest.mark.asyncio +async def test_bad_request_status_assert(send_request_assert_raises_with_message): + request = http_failure.build_get_empty_error_request() + await send_request_assert_raises_with_message(request, "Operation returned an invalid status 'Bad Request'") + +@pytest.mark.asyncio +async def test_no_error_model_status_assert(send_request_assert_raises_with_status_and_response_contains_message): + request = http_failure.build_get_no_model_error_request() + await send_request_assert_raises_with_status_and_response_contains_message(request, requests.codes.bad_request, "NoErrorModel") + +@pytest.mark.asyncio +async def test_success_status_codes_200(send_request): + request = http_success.build_head200_request() + await send_request(request) + request = http_success.build_get200_request() + assert (await send_request(request)).text + + request = http_success.build_put200_request() + await send_request(request) + + request = http_success.build_post200_request() + await send_request(request) + + request = http_success.build_patch200_request() + await send_request(request) + + request = http_success.build_delete200_request() + await send_request(request) + + # TODO, 4042586: Support options operations in swagger modeler + #assert client.http_success.options200() + +@pytest.mark.asyncio +async def test_success_status_codes_201(send_request): + request = http_success.build_put201_request() + await send_request(request) + + request = http_success.build_post201_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_success_status_codes_202(send_request): + request = http_success.build_put202_request() + await send_request(request) + + request = http_success.build_post202_request() + await send_request(request) + + request = http_success.build_patch202_request() + await send_request(request) + + request = http_success.build_delete202_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_success_status_codes_204(send_request): + request = http_success.build_head204_request() + await send_request(request) + + request = http_success.build_put204_request() + await send_request(request) + + request = http_success.build_post204_request() + await send_request(request) + + request = http_success.build_delete204_request() + await send_request(request) + + request = http_success.build_patch204_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_success_status_codes_404(send_request_assert_raises_with_status): + # raises bc in high level we're able to mark 404 as a valid status code, but can't do that in llc + request = http_success.build_head404_request() + await send_request_assert_raises_with_status(request, 404) + +@pytest.mark.asyncio +async def test_empty_no_content(send_request_assert_raises_with_status): + request = http_failure.build_get_no_model_empty_request() + await send_request_assert_raises_with_status(request, requests.codes.bad_request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_integer.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_integer.py new file mode 100644 index 00000000000..32f8406917e --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_integer.py @@ -0,0 +1,111 @@ +# -------------------------------------------------------------------------- +# +# 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 async_generator import yield_, async_generator +from datetime import datetime +from azure.core.exceptions import DecodeError + +from bodyintegerlowlevel.aio import AutoRestIntegerTestService +from bodyintegerlowlevel.rest import int as int_rest +import calendar +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestIntegerTestService(base_url="http://localhost:3000") as client: + await 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_max_min_32_bit(send_request): + request = int_rest.build_put_max32_request(json=2147483647) # sys.maxint + await send_request(request) + + request = int_rest.build_put_min32_request(json=-2147483648) + await send_request(request) + +@pytest.mark.asyncio +async def test_max_min_64_bit(send_request): + request = int_rest.build_put_max64_request(json=9223372036854776000) # sys.maxsize + await send_request(request) + + request = int_rest.build_put_min64_request(json=-9223372036854776000) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_null_and_invalid(send_request): + request = int_rest.build_get_null_request() + await send_request(request) + + request = int_rest.build_get_invalid_request() + with pytest.raises(DecodeError): + await send_request(request) + +@pytest.mark.asyncio +async def test_get_overflow(send_request): + # Testserver excepts these to fail, but they won't in Python and it's ok. + + request = int_rest.build_get_overflow_int32_request() + await send_request(request) + + request = int_rest.build_get_overflow_int64_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_get_underflow(send_request): + request = int_rest.build_get_underflow_int32_request() + await send_request(request) + + request = int_rest.build_get_underflow_int64_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_unix_time_date(send_request): + unix_date = datetime(year=2016, month=4, day=13) + request = int_rest.build_put_unix_time_date_request(json=int(calendar.timegm(unix_date.utctimetuple()))) + await send_request(request) + + request = int_rest.build_get_unix_time_request() + assert unix_date.utctimetuple() == datetime.fromtimestamp((await send_request(request)).json(), TZ_UTC).utctimetuple() + +@pytest.mark.asyncio +async def test_get_null_and_invalid_unix_time(send_request): + request = int_rest.build_get_null_unix_time_request() + assert (await send_request(request)).text == '' + + request = int_rest.build_get_invalid_unix_time_request() + with pytest.raises(DecodeError): + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_media_types.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_media_types.py new file mode 100644 index 00000000000..6935a5f1525 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_media_types.py @@ -0,0 +1,57 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from mediatypeslowlevel.aio import MediaTypesClient +from mediatypeslowlevel.rest import * +from async_generator import yield_, async_generator + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with MediaTypesClient() as client: + await yield_(client) + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_pdf(send_request_json_response): + request = build_analyze_body_request(content=b"PDF", content_type="application/pdf") + assert await send_request_json_response(request) == "Nice job with PDF" + +@pytest.mark.asyncio +async def test_json(send_request_json_response): + request = build_analyze_body_request(json={"source":"foo"}) + assert await send_request_json_response(request) == "Nice job with JSON" + +@pytest.mark.asyncio +async def test_content_type_with_encoding(send_request_json_response): + request = build_content_type_with_encoding_request(content="hello", content_type='text/plain; encoding=UTF-8') + assert await send_request_json_response(request) == "Nice job sending content type with encoding" diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_model_flattening.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_model_flattening.py new file mode 100644 index 00000000000..1280b7590e2 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_model_flattening.py @@ -0,0 +1,300 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from async_generator import yield_, async_generator +from modelflatteninglowlevel.aio import AutoRestResourceFlatteningTestService +from modelflatteninglowlevel import rest + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestResourceFlatteningTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + + +@pytest.mark.asyncio +async def test_flattening_array(send_request, send_request_json_response): + #Array + request = rest.build_get_array_request() + result = await send_request_json_response(request) + assert 3 == len(result) + # Resource 1 + assert "1" == result[0]['id'] + assert "OK" == result[0]['properties']['provisioningStateValues'] + assert "Product1" == result[0]['properties']['p.name'] + assert "Flat" == result[0]['properties']['type'] + assert "Building 44" == result[0]['location'] + assert "Resource1" == result[0]['name'] + assert "Succeeded" == result[0]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result[0]['type'] + assert "value1" == result[0]['tags']["tag1"] + assert "value3" == result[0]['tags']["tag2"] + # Resource 2 + assert "2" == result[1]['id'] + assert "Resource2" == result[1]['name'] + assert "Building 44" == result[1]['location'] + # Resource 3 + assert "3" == result[2]['id'] + assert "Resource3" == result[2]['name'] + + json = [ + { + 'tags': { + 'tag1': 'value1', + 'tag2': 'value3' + }, + 'location': 'West US' + }, + { + 'location': 'Building 44' + } + ] + request = rest.build_put_array_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_flattening_dictionary(send_request, send_request_json_response): + + request = rest.build_get_dictionary_request() + result = await send_request_json_response(request) + assert 3 == len(result) + # Resource 1 + assert "1" == result["Product1"]['id'] + assert "OK" == result["Product1"]['properties']['provisioningStateValues'] + assert "Product1" == result["Product1"]['properties']['p.name'] + assert "Flat" == result["Product1"]['properties']['type'] + assert "Building 44" == result["Product1"]['location'] + assert "Resource1" == result["Product1"]['name'] + assert "Succeeded" == result["Product1"]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result["Product1"]['type'] + assert "value1" == result["Product1"]['tags']["tag1"] + assert "value3" == result["Product1"]['tags']["tag2"] + # Resource 2 + assert "2" == result["Product2"]['id'] + assert "Resource2" == result["Product2"]['name'] + assert "Building 44" == result["Product2"]['location'] + # Resource 3 + assert "3" == result["Product3"]['id'] + assert "Resource3" == result["Product3"]['name'] + + json = { + "Resource1": { + "tags": { + "tag1": "value1", + "tag2": "value3" + }, + "location": "West US", + "properties": { + "p.name": "Product1", + "type": "Flat" + } + }, + "Resource2": { + "location": "Building 44", + "properties": { + "p.name": "Product2", + "type": "Flat" + } + } + } + + request = rest.build_put_dictionary_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_flattening_complex_object(send_request, send_request_json_response): + + #ResourceCollection + request = rest.build_get_resource_collection_request() + result = await send_request_json_response(request) + + #dictionaryofresources + assert 3 == len(result['dictionaryofresources']) + # Resource 1 + assert "1" == result['dictionaryofresources']["Product1"]['id'] + assert "OK" == result['dictionaryofresources']["Product1"]['properties']['provisioningStateValues'] + assert "Product1" == result['dictionaryofresources']["Product1"]['properties']['p.name'] + assert "Flat" == result['dictionaryofresources']["Product1"]['properties']['type'] + assert "Building 44" == result['dictionaryofresources']["Product1"]['location'] + assert "Resource1" == result['dictionaryofresources']["Product1"]['name'] + assert "Succeeded" == result['dictionaryofresources']["Product1"]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result['dictionaryofresources']["Product1"]['type'] + assert "value1" == result['dictionaryofresources']["Product1"]['tags']["tag1"] + assert "value3" == result['dictionaryofresources']["Product1"]['tags']["tag2"] + # Resource 2 + assert "2" == result['dictionaryofresources']["Product2"]['id'] + assert "Resource2" == result['dictionaryofresources']["Product2"]['name'] + assert "Building 44" == result['dictionaryofresources']["Product2"]['location'] + # Resource 3 + assert "3" == result['dictionaryofresources']["Product3"]['id'] + assert "Resource3" == result['dictionaryofresources']["Product3"]['name'] + + #arrayofresources + assert 3 == len(result['arrayofresources']) + # Resource 1 + assert "4" == result['arrayofresources'][0]['id'] + assert "OK" == result['arrayofresources'][0]['properties']['provisioningStateValues'] + assert "Product4" == result['arrayofresources'][0]['properties']['p.name'] + assert "Flat" == result['arrayofresources'][0]['properties']['type'] + assert "Building 44" == result['arrayofresources'][0]['location'] + assert "Resource4" == result['arrayofresources'][0]['name'] + assert "Succeeded" == result['arrayofresources'][0]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result['arrayofresources'][0]['type'] + assert "value1" == result['arrayofresources'][0]['tags']["tag1"] + assert "value3" == result['arrayofresources'][0]['tags']["tag2"] + # Resource 2 + assert "5" == result['arrayofresources'][1]['id'] + assert "Resource5" == result['arrayofresources'][1]['name'] + assert "Building 44" == result['arrayofresources'][1]['location'] + # Resource 3 + assert "6" == result['arrayofresources'][2]['id'] + assert "Resource6" == result['arrayofresources'][2]['name'] + + #productresource + assert "7" == result['productresource']['id'] + assert "Resource7" == result['productresource']['name'] + + json = { + "productresource": { + "location": "India", + "properties": { + "p.name": "Azure", + "type": "Flat" + } + }, + "arrayofresources": [ + { + "tags": { + "tag1": "value1", + "tag2": "value3" + }, + "location": "West US", + "properties": { + "p.name": "Product1", + "type": "Flat" + } + }, + { + "location": "East US", + "properties": { + "p.name": "Product2", + "type": "Flat" + } + } + ], + "dictionaryofresources": { + "Resource1": { + "tags": { + "tag1": "value1", + "tag2": "value3" + }, + "location": "West US", + "properties": { + "p.name": "Product1", + "type": "Flat" + } + }, + "Resource2": { + "location": "Building 44", + "properties": { + "p.name": "Product2", + "type": "Flat" + } + } + } + } + request = rest.build_put_resource_collection_request(json=json) + await send_request(request) + +@pytest.mark.asyncio +async def test_model_flattening_simple(send_request_json_response): + json = { + "base_product_id": "123", + "base_product_description": "product description", + "details": { + "max_product_display_name": "max name", + "max_product_capacity": "Large", + "max_product_image": { + "generic_value": "https://generic", + "@odata.value": "http://foo" + } + } + } + request = rest.build_put_simple_product_request(json=json) + result = await send_request_json_response(request) + assert json == result + +@pytest.mark.asyncio +async def test_model_flattening_with_parameter_flattening(send_request_json_response): + + json = { + "base_product_id": "123", + "base_product_description": "product description", + "details": { + "max_product_display_name": "max name", + "max_product_capacity": "Large", + "max_product_image": { + "@odata.value": "http://foo" + } + } + } + + request = rest.build_post_flattened_simple_product_request(json=json) + result = await send_request_json_response(request) + assert result == json + +@pytest.mark.asyncio +async def test_model_flattening_with_grouping(send_request_json_response): + json = { + "base_product_id": "123", + "base_product_description": "product description", + "details": { + "max_product_display_name": "max name", + "max_product_capacity": "Large", + "max_product_image": { + "@odata.value": "http://foo" + } + } + } + request = rest.build_put_simple_product_with_grouping_request( + name='groupproduct', + json=json + ) + result = await send_request_json_response(request) + assert result == json diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_multiple_inheritance.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_multiple_inheritance.py new file mode 100644 index 00000000000..6c760b5236e --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_multiple_inheritance.py @@ -0,0 +1,97 @@ +# 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. +# +# -------------------------------------------------------------------------- + + +from multipleinheritancelowlevel.aio import MultipleInheritanceServiceClient +from multipleinheritancelowlevel.rest import * +from async_generator import yield_, async_generator +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with MultipleInheritanceServiceClient(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_get_pet(send_request_json_response): + request = build_get_pet_request() + assert {"name": "Peanut"} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_put_pet(send_request_json_response): + request = build_put_pet_request(json={"name": "Butter"}) + result = await send_request_json_response(request) + assert result == "Pet was correct!" + +@pytest.mark.asyncio +async def test_get_horse(send_request_json_response): + request = build_get_horse_request() + assert {"name": "Fred", "isAShowHorse": True} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_put_horse(send_request_json_response): + request = build_put_horse_request(json={"name": "General", "isAShowHorse": False}) + result = await send_request_json_response(request) + assert result == "Horse was correct!" + +@pytest.mark.asyncio +async def test_get_feline(send_request_json_response): + request = build_get_feline_request() + assert {"meows": True, "hisses": True} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_put_feline(send_request_json_response): + request = build_put_feline_request(json={"meows": False, "hisses": True}) + result = await send_request_json_response(request) + assert result == "Feline was correct!" + +@pytest.mark.asyncio +async def test_get_cat(send_request_json_response): + request = build_get_cat_request() + assert {"name": "Whiskers", "likesMilk": True, "meows": True, "hisses": True} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_put_cat(send_request_json_response): + request = build_put_cat_request(json={"name": "Boots", "likesMilk": False, "meows": True, "hisses": False}) + assert await send_request_json_response(request) == "Cat was correct!" + +@pytest.mark.asyncio +async def test_get_kitten(send_request_json_response): + request = build_get_kitten_request() + assert {"name": "Gatito", "likesMilk": True, "meows": True, "hisses": True, "eatsMiceYet": False} == await send_request_json_response(request) + +@pytest.mark.asyncio +async def test_put_kitten(send_request_json_response): + request = build_put_kitten_request(json={"name": "Kitty", "likesMilk": False, "meows": True, "hisses": False, "eatsMiceYet": True}) + assert "Kitten was correct!" == await send_request_json_response(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_non_string_enums.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_non_string_enums.py new file mode 100644 index 00000000000..920cba496be --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_non_string_enums.py @@ -0,0 +1,62 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from nonstringenumslowlevel.aio import NonStringEnumsClient +from nonstringenumslowlevel.rest import int, float +from async_generator import yield_, async_generator + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with NonStringEnumsClient(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_put_int_enum(send_request_json_response): + request = int.build_put_request(json=200) + assert await send_request_json_response(request) == "Nice job posting an int enum" + +@pytest.mark.asyncio +async def test_get_int_enum(send_request_json_response): + request = int.build_get_request() + assert await send_request_json_response(request) == 429 + +@pytest.mark.asyncio +async def test_put_float_enum(send_request_json_response): + request = float.build_put_request(json=200.4) + assert await send_request_json_response(request) == "Nice job posting a float enum" + +@pytest.mark.asyncio +async def test_get_float_enum(send_request_json_response): + request = float.build_get_request() + assert await send_request_json_response(request) == 429.1 diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_number.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_number.py new file mode 100644 index 00000000000..3dd9eec455e --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_number.py @@ -0,0 +1,155 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from decimal import Decimal +import pytest +from async_generator import yield_, async_generator +from azure.core.exceptions import DecodeError + +from bodynumberlowlevel.aio import AutoRestNumberTestService +from bodynumberlowlevel.rest import number + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestNumberTestService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_big_float(send_request, send_request_json_response): + request = number.build_put_big_float_request(json=3.402823e+20) + await send_request(request) + + request = number.build_get_big_float_request() + assert await send_request_json_response(request) == 3.402823e+20 + +@pytest.mark.asyncio +async def test_small_float(send_request, send_request_json_response): + request = number.build_put_small_float_request(json=3.402823e-20) + await send_request(request) + + request = number.build_get_small_float_request() + assert await send_request_json_response(request) == 3.402823e-20 + +@pytest.mark.asyncio +async def test_big_double(send_request, send_request_json_response): + request = number.build_put_big_double_request(json=2.5976931e+101) + await send_request(request) + + request = number.build_get_big_double_request() + assert await send_request_json_response(request) == 2.5976931e+101 + +@pytest.mark.asyncio +async def test_small_double(send_request, send_request_json_response): + request = number.build_put_small_double_request(json=2.5976931e-101) + await send_request(request) + + request = number.build_get_small_double_request() + assert await send_request_json_response(request) == 2.5976931e-101 + +@pytest.mark.asyncio +async def test_big_double_negative_decimal(send_request, send_request_json_response): + request = number.build_get_big_double_negative_decimal_request(json=-99999999.99) + await send_request(request) + + request = number.build_get_big_double_negative_decimal_request() + assert await send_request_json_response(request) == -99999999.99 + +@pytest.mark.asyncio +async def test_big_double_positive_decimal(send_request, send_request_json_response): + request = number.build_put_big_double_positive_decimal_request(json=99999999.99) + await send_request(request) + + request = number.build_get_big_double_positive_decimal_request() + assert await send_request_json_response(request) == 99999999.99 + +@pytest.mark.asyncio +async def test_big_decimal(send_request, send_request_json_response): + request = number.build_put_big_decimal_request(json=2.5976931e+101) + await send_request(request) + + request = number.build_get_big_decimal_request() + assert await send_request_json_response(request) == 2.5976931e+101 + +@pytest.mark.asyncio +async def test_small_decimal(send_request, send_request_json_response): + request = number.build_put_small_decimal_request(json=2.5976931e-101) + await send_request(request) + + request = number.build_get_small_decimal_request() + assert await send_request_json_response(request) == 2.5976931e-101 + +@pytest.mark.asyncio +async def test_get_big_decimal_negative_decimal(send_request, send_request_json_response): + request = number.build_put_big_decimal_negative_decimal_request(json=-99999999.99) + + request = number.build_get_big_decimal_negative_decimal_request() + assert await send_request_json_response(request) == -99999999.99 + +@pytest.mark.asyncio +async def test_get_big_decimal_positive_decimal(send_request, send_request_json_response): + request = number.build_put_big_decimal_positive_decimal_request(json=99999999.99) + await send_request(request) + + request = number.build_get_big_decimal_positive_decimal_request() + assert await send_request_json_response(request) == 99999999.99 + +@pytest.mark.asyncio +async def test_get_null(send_request): + request = number.build_get_null_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_get_invalid_decimal(send_request): + request = number.build_get_invalid_decimal_request() + with pytest.raises(DecodeError): + await send_request(request) + +@pytest.mark.asyncio +async def test_get_invalid_double(send_request): + request = number.build_get_invalid_double_request() + with pytest.raises(DecodeError): + await send_request(request) + +@pytest.mark.asyncio +async def test_get_invalid_float(send_request): + request = number.build_get_invalid_float_request() + with pytest.raises(DecodeError): + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_object_type.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_object_type.py new file mode 100644 index 00000000000..01bd0ea7a09 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_object_type.py @@ -0,0 +1,60 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from async_generator import yield_, async_generator +from objecttypelowlevel.aio import ObjectTypeClient +from objecttypelowlevel.rest import * +from azure.core.exceptions import HttpResponseError + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with ObjectTypeClient(base_url="http://localhost:3000") as client: + await 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_get_object(send_request): + request = build_get_request() + assert (await send_request(request)).json() == {"message": "An object was successfully returned"} + +@pytest.mark.asyncio +async def test_put_object_success(send_request): + request = build_put_request(json={"foo": "bar"}) + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_put_object_fail(send_request): + request = build_put_request(json={"should": "fail"}) + with pytest.raises(HttpResponseError) as ex: + await send_request(request) + assert ex.value.response.json()['message'] == 'The object you passed was incorrect' diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_required_optional.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_required_optional.py new file mode 100644 index 00000000000..7a409558325 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_required_optional.py @@ -0,0 +1,210 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +import io +from azure.core.exceptions import HttpResponseError +from msrest.exceptions import ValidationError + +from requiredoptionallowlevel.aio import AutoRestRequiredOptionalTestService +from requiredoptionallowlevel.rest import implicit, explicit + +import pytest + +@pytest.fixture +@async_generator +async def client_required(): + async with AutoRestRequiredOptionalTestService( + "required_path", + "required_query", + base_url="http://localhost:3000") as client: + client._config.required_global_path = "required_path" + client._config.required_global_query = "required_query" + await yield_(client) + + +@pytest.fixture +def send_request_required_client(client_required, base_send_request): + def _send_request(request): + return base_send_request(client_required, request) + return _send_request + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestRequiredOptionalTestService( + "required_path", + "required_query", + base_url="http://localhost:3000") as client: + client._config.required_global_path = None + client._config.required_global_query = None + await yield_(client) + +@pytest.fixture +def send_request_client(client, base_send_request): + def _send_request(request): + return base_send_request(client, request) + return _send_request +# NOTE: in the LLC version, we can't raise as many ValidationErrors as the high level convenience layer does. +# This is because we're not serializing bodies at all, so msrest doesn't have a chance to throw the validation error + + +# These clients have a required global path and query +@pytest.mark.asyncio +async def test_put_optional(send_request_required_client): + request = implicit.build_put_optional_query_request(query_parameter=None) + await send_request_required_client(request) + + request = implicit.build_put_optional_body_request(json=None) + await send_request_required_client(request) + + request = implicit.build_put_optional_header_request(query_parameter=None) + await send_request_required_client(request) + +@pytest.mark.asyncio +async def test_get_optional_global_query(send_request_required_client): + request = implicit.build_get_optional_global_query_request(optional_global_query=None) + await send_request_required_client(request) + +@pytest.mark.asyncio +async def test_post_optional_integer(send_request_required_client): + request = explicit.build_post_optional_integer_parameter_request(json=None) + await send_request_required_client(request) + + + request = explicit.build_post_optional_integer_property_request(json={"value": None}) + await send_request_required_client(request) + + request = explicit.build_post_optional_integer_header_request(header_parameter=None) + await send_request_required_client(request) + +@pytest.mark.asyncio +async def test_post_optional_string(send_request_required_client): + request = explicit.build_post_optional_string_parameter_request(json=None) + await send_request_required_client(request) + + + request = explicit.build_post_optional_string_property_request(json={"value": None}) + await send_request_required_client(request) + + request = explicit.build_post_optional_string_header_request(body_parameter=None) + await send_request_required_client(request) + +@pytest.mark.asyncio +async def test_post_optional_class(send_request_required_client): + request = explicit.build_post_optional_class_parameter_request() + await send_request_required_client(request) + + request = explicit.build_post_optional_class_property_request(json={"value": None}) + await send_request_required_client(request) + +@pytest.mark.asyncio +async def test_post_optional_array(send_request_required_client): + request = explicit.build_post_optional_array_parameter_request(json=None) + await send_request_required_client(request) + + request = explicit.build_post_optional_array_property_request(json={"value": None}) + await send_request_required_client(request) + + request = explicit.build_post_optional_array_header_request(header_parameter=None) + await send_request_required_client(request) + +@pytest.mark.asyncio +async def test_implicit_get_required(send_request_client): + with pytest.raises(ValidationError): + request = implicit.build_get_required_path_request(path_parameter=None) + await send_request_client(request) + + with pytest.raises(ValidationError): + request = implicit.build_get_required_global_path_request(required_global_path=None) + await send_request_client(request) + + with pytest.raises(ValidationError): + request = implicit.build_get_required_global_query_request(required_global_query=None) + await send_request_client(request) + +@pytest.mark.asyncio +async def test_post_required_string(send_request_client): + with pytest.raises(ValidationError): + request = explicit.build_post_required_string_header_request(header_parameter=None) + await send_request_client(request) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_string_parameter_request() + await send_request_client(request) + + assert "Not Found" in str(ex.value) + + with pytest.raises(HttpResponseError)as ex: + request = explicit.build_post_required_string_property_request(json={"value": None}) + await send_request_client(request) + assert "Not Found" in str(ex.value) + +@pytest.mark.asyncio +async def test_post_required_array(send_request_client): + with pytest.raises(ValidationError): + request = explicit.build_post_required_array_header_request(header_parameter=None) + await send_request_client(request) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_array_parameter_request() + await send_request_client(request) + assert "Not Found" in str(ex.value) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_array_property_request(json={"value": None}) + await send_request_client(request) + assert "Not Found" in str(ex.value) + +@pytest.mark.asyncio +async def test_post_required_class(send_request_client): + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_class_parameter_request() + await send_request_client(request) + assert "Not Found" in str(ex.value) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_class_property_request(json={"value": None}) + await send_request_client(request) + assert "Not Found" in str(ex.value) + +@pytest.mark.asyncio +async def test_explict_put_optional_binary_body(send_request_client): + request = explicit.build_put_optional_binary_body_request() + await send_request_client(request) + +@pytest.mark.asyncio +async def test_explict_put_required_binary_body(client): + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = explicit.build_put_required_binary_body_request(content=stream_data) + await client.send_request(request, stream=True) + +@pytest.mark.asyncio +async def test_implicit_put_optional_binary_body(send_request_client): + request = explicit.build_put_optional_binary_body_request() + await send_request_client(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_send_request.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_send_request.py new file mode 100644 index 00000000000..a2a440345cf --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_send_request.py @@ -0,0 +1,174 @@ +# -------------------------------------------------------------------------- +# +# 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 io +import json +import pytest +from azure.core.rest import HttpRequest + +from os.path import dirname, pardir, join, realpath +import pytest + +cwd = dirname(realpath(__file__)) + +class TestSendRequest(object): + + @pytest.mark.asyncio + async def test_send_request_with_body_get_model_deserialize(self): + from bodycomplexlowlevel.aio import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + response = await client.send_request(request) + deserialized = response.json() + assert 2 == deserialized['id'] + assert "Siameeee" == deserialized['name'] + assert -1 == deserialized['hates'][1]['id'] + assert "Tomato" == deserialized['hates'][1]['name'] + + @pytest.mark.asyncio + async def test_send_request_with_stream_get_direct_json(self): + from bodycomplexlowlevel.aio import AutoRestComplexTestService + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + async with client.send_request(request, stream=True) as response: + data = '' + async for chunk in response.iter_text(): + data += chunk + json_response = json.loads(data) + assert 2 == json_response['id'] + assert "Siameeee" == json_response['name'] + assert - 1 == json_response['hates'][1]['id'] + assert "Tomato" == json_response['hates'][1]['name'] + + @pytest.mark.asyncio + async def test_send_request_with_body_put_json_dumps(self): + from bodycomplexlowlevel.aio import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + siamese_body = { + "id": 2, + "name": "Siameeee", + "color": "green", + "hates": + [ + { + "id": 1, + "name": "Potato", + "food": "tomato" + }, + { + "id": -1, + "name": "Tomato", + "food": "french fries" + } + ], + "breed": "persian" + } + + request = HttpRequest("PUT", "/complex/inheritance/valid", + json=siamese_body, + ) + + response = await client.send_request(request) + assert response.status_code == 200 + + @pytest.mark.asyncio + async def test_send_request_get_stream(self): + from bodyfilelowlevel.aio import AutoRestSwaggerBATFileService + + client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000", connection_data_block_size=1000) + file_length = 0 + with io.BytesIO() as file_handle: + + request = HttpRequest("GET", "http://localhost:3000/files/stream/nonempty", + headers={ + 'Accept': 'image/png, application/json' + }, + ) + + async with client.send_request(request, stream=True) as response: + response.raise_for_status() + + async for data in response.iter_bytes(): + file_length += len(data) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + @pytest.mark.asyncio + async def test_send_request_put_stream(self): + from bodyformdatalowlevel.aio import AutoRestSwaggerBATFormDataService + + client = AutoRestSwaggerBATFormDataService( + base_url="http://localhost:3000", + headers={"Content-Type": "application/octet-stream"} + ) + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = HttpRequest("PUT", '/formdata/stream/uploadfile', + data=stream_data, + ) + response = await client.send_request(request, stream=True) + assert response.status_code == 200 + + @pytest.mark.asyncio + async def test_send_request_full_url(self): + from bodycomplexlowlevel import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://fakeUrl") + + request = HttpRequest("GET", "http://localhost:3000/complex/inheritance/valid") + + response = client.send_request(request) + + deserialized = response.json() + assert 2 == deserialized['id'] + assert "Siameeee" == deserialized['name'] + assert -1 == deserialized['hates'][1]['id'] + assert "Tomato" == deserialized['hates'][1]['name'] diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_string_tests.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_string_tests.py new file mode 100644 index 00000000000..f439e36b514 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_string_tests.py @@ -0,0 +1,183 @@ +# 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. +# +# -------------------------------------------------------------------------- + +from async_generator import yield_, async_generator +from azure.core.exceptions import HttpResponseError + +from bodystringlowlevel.aio import AutoRestSwaggerBATService +from bodystringlowlevel.rest import string, enum +import pytest +from msrest import Serializer, Deserializer +from base64 import b64decode + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestSwaggerBATService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_null(send_request): + request = string.build_get_null_request() + assert (await send_request(request)).text == '' + + request = string.build_put_null_request(content=None) + await send_request(request) + +@pytest.mark.asyncio +async def test_empty(send_request, send_request_json_response): + request = string.build_get_empty_request() + assert "" == await send_request_json_response(request) + # changing this behavior because of this pr being merged: https://github.com/Azure/autorest.testserver/pull/145/files + request = string.build_put_empty_request(json="") + await send_request(request) + +@pytest.mark.asyncio +async def test_mbcs(send_request, send_request_json_response): + try: + test_str = ( + "\xe5\x95\x8a\xe9\xbd\x84\xe4\xb8\x82\xe7\x8b\x9b\xe7\x8b" + "\x9c\xef\xa7\xb1\xef\xa4\xac\xef\xa7\xb1\xef\xa8\x8c\xef" + "\xa8\xa9\xcb\x8a\xe3\x80\x9e\xe3\x80\xa1\xef\xbf\xa4\xe2" + "\x84\xa1\xe3\x88\xb1\xe2\x80\x90\xe3\x83\xbc\xef\xb9\xa1" + "\xef\xb9\xa2\xef\xb9\xab\xe3\x80\x81\xe3\x80\x93\xe2\x85" + "\xb0\xe2\x85\xb9\xe2\x92\x88\xe2\x82\xac\xe3\x88\xa0\xe3" + "\x88\xa9\xe2\x85\xa0\xe2\x85\xab\xef\xbc\x81\xef\xbf\xa3" + "\xe3\x81\x81\xe3\x82\x93\xe3\x82\xa1\xe3\x83\xb6\xce\x91" + "\xef\xb8\xb4\xd0\x90\xd0\xaf\xd0\xb0\xd1\x8f\xc4\x81\xc9" + "\xa1\xe3\x84\x85\xe3\x84\xa9\xe2\x94\x80\xe2\x95\x8b\xef" + "\xb8\xb5\xef\xb9\x84\xef\xb8\xbb\xef\xb8\xb1\xef\xb8\xb3" + "\xef\xb8\xb4\xe2\x85\xb0\xe2\x85\xb9\xc9\x91\xee\x9f\x87" + "\xc9\xa1\xe3\x80\x87\xe3\x80\xbe\xe2\xbf\xbb\xe2\xba\x81" + "\xee\xa1\x83\xe4\x9c\xa3\xee\xa1\xa4\xe2\x82\xac").decode('utf-8') + + except AttributeError: + test_str = ( + b"\xe5\x95\x8a\xe9\xbd\x84\xe4\xb8\x82\xe7\x8b\x9b\xe7\x8b" + b"\x9c\xef\xa7\xb1\xef\xa4\xac\xef\xa7\xb1\xef\xa8\x8c\xef" + b"\xa8\xa9\xcb\x8a\xe3\x80\x9e\xe3\x80\xa1\xef\xbf\xa4\xe2" + b"\x84\xa1\xe3\x88\xb1\xe2\x80\x90\xe3\x83\xbc\xef\xb9\xa1" + b"\xef\xb9\xa2\xef\xb9\xab\xe3\x80\x81\xe3\x80\x93\xe2\x85" + b"\xb0\xe2\x85\xb9\xe2\x92\x88\xe2\x82\xac\xe3\x88\xa0\xe3" + b"\x88\xa9\xe2\x85\xa0\xe2\x85\xab\xef\xbc\x81\xef\xbf\xa3" + b"\xe3\x81\x81\xe3\x82\x93\xe3\x82\xa1\xe3\x83\xb6\xce\x91" + b"\xef\xb8\xb4\xd0\x90\xd0\xaf\xd0\xb0\xd1\x8f\xc4\x81\xc9" + b"\xa1\xe3\x84\x85\xe3\x84\xa9\xe2\x94\x80\xe2\x95\x8b\xef" + b"\xb8\xb5\xef\xb9\x84\xef\xb8\xbb\xef\xb8\xb1\xef\xb8\xb3" + b"\xef\xb8\xb4\xe2\x85\xb0\xe2\x85\xb9\xc9\x91\xee\x9f\x87" + b"\xc9\xa1\xe3\x80\x87\xe3\x80\xbe\xe2\xbf\xbb\xe2\xba\x81" + b"\xee\xa1\x83\xe4\x9c\xa3\xee\xa1\xa4\xe2\x82\xac").decode('utf-8') + + request = string.build_get_mbcs_request() + assert test_str == await send_request_json_response(request) + + request = string.build_put_mbcs_request(json=test_str) + await send_request(request) + +@pytest.mark.asyncio +async def test_whitespace(send_request, send_request_json_response): + test_str = " Now is the time for all good men to come to the aid of their country " + request = string.build_get_whitespace_request() + assert test_str == await send_request_json_response(request) + + request = string.build_put_whitespace_request(json=test_str) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_not_provided(send_request): + request = string.build_get_not_provided_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_enum_not_expandable(send_request, send_request_json_response): + request = enum.build_get_not_expandable_request() + assert "red color" == await send_request_json_response(request) + + request = enum.build_put_not_expandable_request(json='red color') + await send_request(request) + + request = enum.build_put_not_expandable_request(json='red color') + await send_request(request) + # Autorest v3 is switching behavior here. Old Autorest would have thrown a serialization error, + # but now we allow the user to pass strings as enums, so the raised exception is different. + + request = enum.build_put_not_expandable_request(json='not a color') + with pytest.raises(HttpResponseError): + await send_request(request) + +@pytest.mark.asyncio +async def test_get_base64_encoded(send_request): + request = string.build_get_base64_encoded_request() + assert b64decode((await send_request(request)).text) == 'a string that gets encoded with base64'.encode() + +@pytest.mark.asyncio +async def test_base64_url_encoded(send_request): + # the b64 encoding and decoding is taken from msrest + request = string.build_get_base64_url_encoded_request() + response = (await send_request(request)).text + response = Deserializer.deserialize_base64(response) + assert response == 'a string that gets encoded with base64url'.encode() + + content = Serializer.serialize_base64('a string that gets encoded with base64url'.encode()) + request = string.build_put_base64_url_encoded_request(json=content) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_null_base64_url_encoded(send_request): + request = string.build_get_null_base64_url_encoded_request() + assert (await send_request(request)).text == '' + +@pytest.mark.asyncio +async def test_enum_referenced(send_request, send_request_json_response): + request = enum.build_put_referenced_request(json='red color') + await send_request(request) + + request = enum.build_put_referenced_request(json="red color") + await send_request(request) + + request = enum.build_get_referenced_request() + assert await send_request_json_response(request) == 'red color' + +@pytest.mark.asyncio +async def test_enum_referenced_constant(send_request, send_request_json_response): + request = enum.build_put_referenced_request(json='red color') + await send_request(request) + + request = enum.build_get_referenced_constant_request() + assert await send_request_json_response(request) == {'field1': 'Sample String'} # there's no constant on the response, so just getting field1 diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_time.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_time.py new file mode 100644 index 00000000000..0f67fce0286 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_time.py @@ -0,0 +1,54 @@ +# 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 datetime +from async_generator import yield_, async_generator + +from bodytimelowlevel.aio import AutoRestTimeTestService +from bodytimelowlevel.rest import time +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestTimeTestService(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.mark.asyncio +async def test_get(client): + request = time.build_get_request() + response = await client.send_request(request) + response.raise_for_status() + assert datetime.datetime.strptime(response.json(), '%H:%M:%S').time() == datetime.time(11, 34, 56) + + +@pytest.mark.asyncio +async def test_put(client): + request = time.build_put_request(json=datetime.time(8, 7, 56).strftime("%H:%M:%S")) + response = await client.send_request(request) + response.raise_for_status() + assert response.json() == "Nice job posting time" diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_url.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_url.py new file mode 100644 index 00000000000..7e60653c8a9 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_url.py @@ -0,0 +1,391 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from datetime import datetime +from async_generator import yield_, async_generator +from urllowlevel.aio import AutoRestUrlTestService +from urllowlevel.rest import path_items, paths, queries +from urlmulticollectionformatlowlevel.aio import AutoRestUrlMutliCollectionFormatTestService +from urlmulticollectionformatlowlevel.rest import queries as multi_queries +from msrest.exceptions import ValidationError + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestUrlTestService('', base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.fixture +@async_generator +async def multi_client(): + async with AutoRestUrlMutliCollectionFormatTestService("http://localhost:3000") as client: + await 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.fixture +def make_multi_request(multi_client, base_send_request): + async def _send_request(request): + return await base_send_request(multi_client, request) + return _send_request + +@pytest.fixture +@pytest.mark.asyncio +async def test_array_query(): + return ["ArrayQuery1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + +@pytest.mark.asyncio +async def test_byte_empty_and_null(send_request): + request = paths.build_byte_empty_request() + await send_request(request) + + with pytest.raises(ValidationError): + paths.build_byte_null_request(None) + +@pytest.mark.asyncio +async def test_byte_multi_byte(send_request): + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + request = paths.build_byte_multi_byte_request(u_bytes) + await send_request(request) + +@pytest.mark.asyncio +async def test_date_null(send_request): + with pytest.raises(ValidationError): + paths.build_date_null_request(None) + +@pytest.mark.asyncio +async def test_date_time_null(send_request): + with pytest.raises(ValidationError): + paths.build_date_time_null_request(None) + +@pytest.mark.asyncio +async def test_date_time_valid(send_request): + request = paths.build_date_time_valid_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_date_valid(send_request): + request = paths.build_date_valid_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_unix_time_url(send_request): + request = paths.build_unix_time_url_request(datetime(year=2016, month=4, day=13)) + await send_request(request) + +@pytest.mark.asyncio +async def test_double_decimal(send_request): + request = paths.build_double_decimal_negative_request() + await send_request(request) + request = paths.build_double_decimal_positive_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_float_scientific(send_request): + request = paths.build_float_scientific_negative_request() + await send_request(request) + + request = paths.build_float_scientific_positive_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_get_boolean(send_request): + request = paths.build_get_boolean_false_request() + await send_request(request) + + request = paths.build_get_boolean_true_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_int(send_request): + request = paths.build_get_int_negative_one_million_request() + await send_request(request) + + request = paths.build_get_int_one_million_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_get_long(send_request): + request = paths.build_get_negative_ten_billion_request() + await send_request(request) + + request = paths.build_get_ten_billion_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_string_empty_and_null(send_request): + request = paths.build_string_empty_request() + await send_request(request) + + with pytest.raises(ValidationError): + paths.build_string_null_request(None) + +@pytest.mark.asyncio +async def test_array_csv_in_path(send_request): + test_array = ["ArrayPath1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + request = paths.build_array_csv_in_path_request(test_array) + await send_request(request) + +@pytest.mark.asyncio +async def test_string_url_encoded(send_request): + request = paths.build_string_url_encoded_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_paths_unicode(send_request): + request = paths.build_string_unicode_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_string_url_non_encoded(send_request): + request = paths.build_string_url_non_encoded_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_enum_valid(send_request): + request = paths.build_enum_valid_request("green color") + await send_request(request) + +@pytest.mark.asyncio +async def test_enum_null(send_request): + with pytest.raises(ValidationError): + paths.build_enum_null_request(None) + +@pytest.mark.asyncio +async def test_base64_url(send_request): + request = paths.build_base64_url_request("lorem".encode()) + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_byte(send_request): + request = queries.build_byte_empty_request() + await send_request(request) + + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + request = queries.build_byte_multi_byte_request(byte_query=u_bytes) + await send_request(request) + + request = queries.build_byte_null_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_date(send_request): + request = queries.build_date_null_request() + await send_request(request) + + request = queries.build_date_valid_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_date_time(send_request): + request = queries.build_date_time_null_request() + await send_request(request) + + request = queries.build_date_time_valid_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_double(send_request): + request = queries.build_double_null_request() + await send_request(request) + + request = queries.build_double_decimal_negative_request() + await send_request(request) + + request = queries.build_double_decimal_positive_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_float_scientific(send_request): + request = queries.build_float_scientific_negative_request() + await send_request(request) + + request = queries.build_float_scientific_positive_request() + await send_request(request) + request = queries.build_float_null_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_boolean(send_request): + request = queries.build_get_boolean_false_request() + await send_request(request) + + request = queries.build_get_boolean_true_request() + await send_request(request) + + request = queries.build_get_boolean_null_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_int(send_request): + request = queries.build_get_int_negative_one_million_request() + await send_request(request) + + request = queries.build_get_int_one_million_request() + await send_request(request) + + request = queries.build_get_int_null_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_long(send_request): + request = queries.build_get_negative_ten_billion_request() + await send_request(request) + + request = queries.build_get_ten_billion_request() + await send_request(request) + + request = queries.build_get_long_null_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_string(send_request): + request = queries.build_string_empty_request() + await send_request(request) + + request = queries.build_string_null_request() + await send_request(request) + + request = queries.build_string_url_encoded_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_enum(send_request): + request = queries.build_enum_valid_request(enum_query="green color") + await send_request(request) + + request = queries.build_enum_null_request(enum_query=None) + await send_request(request) + +@pytest.mark.asyncio +async def test_queries_unicode(send_request): + request = queries.build_string_unicode_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_array_string_csv(send_request, test_array_query): + request = queries.build_array_string_csv_empty_request(array_query=[]) + await send_request(request) + + request = queries.build_array_string_csv_null_request(array_query=None) + await send_request(request) + + request = queries.build_array_string_csv_valid_request(array_query=test_array_query) + await send_request(request) + +@pytest.mark.asyncio +async def test_array_string_miscellaneous(send_request, test_array_query): + # request = queries.build_array_string_pipes_valid_request(array_query=test_array_query) + # await send_request(request) + + # request = queries.build_array_string_ssv_valid_request(array_query=test_array_query) + # await send_request(request) + + request = queries.build_array_string_tsv_valid_request(array_query=test_array_query) + await send_request(request) + +@pytest.mark.asyncio +async def test_array_string_multi(make_multi_request, test_array_query): + request = multi_queries.build_array_string_multi_empty_request(array_query=[]) + await make_multi_request(request) + + request = multi_queries.build_array_string_multi_null_request() + await make_multi_request(request) + + request = multi_queries.build_array_string_multi_valid_request(array_query=test_array_query) + await make_multi_request(request) + +@pytest.mark.asyncio +async def test_array_string_no_collection_format(send_request): + request = queries.build_array_string_no_collection_format_empty_request(array_query=['hello', 'nihao', 'bonjour']) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_all_with_values(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + global_string_query = "globalStringQuery" + + request = path_items.build_get_all_with_values_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query="pathItemStringQuery", + global_string_query=global_string_query, + local_string_query="localStringQuery", + ) + + await send_request(request) + +@pytest.mark.asyncio +async def test_get_global_and_local_query_null(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + + request = path_items.build_get_global_and_local_query_null_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query="pathItemStringQuery", + global_string_query=None + ) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_global_query_null(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + + request = path_items.build_get_global_query_null_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query="pathItemStringQuery", + local_string_query="localStringQuery", + ) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_local_path_item_query_null(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + global_string_query = "globalStringQuery" + + request = path_items.build_get_local_path_item_query_null_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query=None, + global_string_query=global_string_query, + local_string_query=None, + ) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_validation.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_validation.py new file mode 100644 index 00000000000..aa4c8be102c --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_validation.py @@ -0,0 +1,156 @@ +# -------------------------------------------------------------------------- +# +# 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 sys + +from msrest.exceptions import ValidationError +from async_generator import yield_, async_generator + +from validationlowlevel.aio import AutoRestValidationTest +from validationlowlevel.rest import * + +import pytest + +@pytest.fixture +@async_generator +async def client(): + async with AutoRestValidationTest( + "abc123", + base_url="http://localhost:3000") as client: + client.api_version = "12-34-5678" + await 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.fixture +def send_request_json_response(client, base_send_request_json_response): + async def _send_request(request): + return await base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def constant_body(): + """This is NOT considering the constant body, this should work with + the commented line. + See https://github.com/Azure/autorest.modelerfour/issues/83 + """ + return { + 'child': { + 'constProperty': 'constant' + }, + 'constChild': { + 'constProperty': 'constant', + 'constProperty2': 'constant2' + }, + 'constInt': 0, + 'constString': 'constant', + 'constStringAsEnum': 'constant_string_as_enum' + } + +@pytest.mark.asyncio +async def test_with_constant_in_path(send_request): + request = build_get_with_constant_in_path_request() + await send_request(request) + +@pytest.mark.asyncio +async def test_post_with_constant_in_body(send_request_json_response, constant_body): + request = build_post_with_constant_in_body_request(json=constant_body) + product = await send_request_json_response(request) + assert product is not None + +@pytest.mark.asyncio +async def test_min_length_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="1", id=100) + await send_request(request) + except ValidationError as err: + assert err.rule == "min_length" + assert err.target == "resource_group_name" + +@pytest.mark.asyncio +async def test_max_length_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="1234567890A", id=100) + await send_request(request) + except ValidationError as err: + assert err.rule == "max_length" + assert err.target == "resource_group_name" + +@pytest.mark.asyncio +async def test_pattern_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="!@#$", id=100) + await send_request(request) + except ValidationError as err: + assert err.rule == "pattern" + assert err.target == "resource_group_name" + +@pytest.mark.asyncio +async def test_multiple_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=105) + await send_request(request) + except ValidationError as err: + assert err.rule == "multiple" + assert err.target == "id" + +@pytest.mark.asyncio +async def test_minimum_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=0) + await send_request(request) + except ValidationError as err: + assert err.rule == "minimum" + assert err.target == "id" + +@pytest.mark.asyncio +async def test_maximum_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=2000) + await send_request(request) + except ValidationError as err: + assert err.rule == "maximum" + assert err.target == "id" + +# NOTE: removed body validation, since it doesn't make sense for LLC as we serialize the body ourselves and pass it in + + +@pytest.mark.xfail(reason="https://github.com/Azure/autorest.modelerfour/issues/90") +@pytest.mark.asyncio +async def test_api_version_validation(send_request): + client = AutoRestValidationTest( + "abc123", + base_url="http://localhost:3000") + client.api_version = "abc" + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=150) + await send_request(request) + except ValidationError as err: + assert err.rule == "pattern" + assert err.target == "self.api_version" diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_xml.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_xml.py new file mode 100644 index 00000000000..14ba1584bfa --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_xml.py @@ -0,0 +1,262 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from async_generator import yield_, async_generator + +from xmlservicelowlevel.aio import AutoRestSwaggerBATXMLService + +import xml.etree.ElementTree as ET +from xmlservicelowlevel.rest import xml +from base64 import b64decode + +import pytest +@pytest.fixture +@async_generator +async def client(): + async with AutoRestSwaggerBATXMLService(base_url="http://localhost:3000") as client: + await 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.fixture +def send_request_text_response(client, base_send_request): + async def _send_request(request): + return (await base_send_request(client, request)).text + return _send_request + + + +@pytest.mark.asyncio +async def test_json_xml(send_request, send_request_text_response): + request = xml.build_json_input_request(json={"id": 42}) + await send_request(request) + + request = xml.build_json_output_request() + assert (await send_request(request)).json()['id'] == 42 + +@pytest.mark.asyncio +async def test_simple(send_request, send_request_text_response): + # Slideshow + + request = xml.build_get_simple_request() + slideshow = ET.fromstring(await send_request_text_response(request)) + assert slideshow.attrib['title'] == "Sample Slide Show" + assert slideshow.attrib['date'] == "Date of publication" + assert slideshow.attrib['author'] == "Yours Truly" + slides = list(slideshow.iterfind('slide')) + assert len(slides) == 2 + + slide1 = slides[0] + assert slide1.attrib['type'] == "all" + assert next(slide1.iterfind('title')).text == "Wake up to WonderWidgets!" + assert len(list(slide1.iterfind('item'))) == 0 + + slide2 = slides[1] + assert slide2.attrib['type'] == "all" + assert next(slide2.iterfind('title')).text == "Overview" + items = list(slide2.iterfind('item')) + assert len(items) == 3 + assert items[0].text == "Why WonderWidgets are great" + assert items[1].text == None + assert items[2].text == "Who buys WonderWidgets" + + request = xml.build_put_simple_request(content=slideshow, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_empty_child_element(send_request, send_request_text_response): + request = xml.build_get_empty_child_element_request() + banana = ET.fromstring(await send_request_text_response(request)) + assert banana.attrib == {}# That's the point of this test, it was an empty node. + request = xml.build_put_empty_child_element_request(content=banana, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_empty_root_list(send_request, send_request_text_response): + request = xml.build_get_empty_root_list_request() + empty = ET.fromstring(await send_request_text_response(request)) + assert empty.tag == 'bananas' + assert empty.attrib == {} + assert await send_request_text_response(request) == "\n" + request = xml.build_put_empty_root_list_request(content=empty, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_root_list_single_item(send_request, send_request_text_response): + request = xml.build_get_root_list_single_item_request() + xml_body = ET.fromstring(await send_request_text_response(request)) + bananas = list(xml_body.iterfind('banana')) + assert len(bananas) == 1 + assert next(bananas[0].iterfind('name')).text == "Cavendish" + request = xml.build_put_root_list_single_item_request(content=xml_body, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_root_list(send_request, send_request_text_response): + request = xml.build_get_root_list_request() + xml_body = ET.fromstring(await send_request_text_response(request)) + bananas = list(xml_body.iterfind('banana')) + assert len(bananas) == 2 + request = xml.build_put_root_list_request(content=xml_body, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_empty_wrapped_lists(send_request, send_request_text_response): + request = xml.build_get_empty_wrapped_lists_request() + bananas = ET.fromstring(await send_request_text_response(request)) + """ + + + + `; + """ + good_apples = [a for a in bananas.iterfind('GoodApples') if a.text] + assert len(good_apples) == 0 + bad_apples = [a for a in bananas.iterfind('BadApples') if a.text] + assert len(bad_apples) == 0 + request = xml.build_put_empty_wrapped_lists_request(content=bananas, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_get_empty(send_request, send_request_text_response): + request = xml.build_get_empty_list_request() + slideshow = ET.fromstring(await send_request_text_response(request)) + request = xml.build_put_empty_list_request(content=slideshow, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_wrapped_lists(send_request, send_request_text_response): + request = xml.build_get_wrapped_lists_request() + bananas = ET.fromstring(await send_request_text_response(request)) + good_apples = bananas.find('GoodApples') + assert [a.text for a in good_apples.iterfind('Apple')] == ['Fuji', 'Gala'] + + bad_apples = bananas.find('BadApples') + assert [a.text for a in bad_apples.iterfind('Apple')] == ['Red Delicious'] + request = xml.build_put_wrapped_lists_request(content=bananas, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_complex_types(send_request, send_request_text_response): + request = xml.build_get_complex_type_ref_no_meta_request() + root = ET.fromstring(await send_request_text_response(request)) + ref_to_model = root.find('RefToModel') + assert ref_to_model.find('ID').text == "myid" + request = xml.build_put_complex_type_ref_no_meta_request(content=root, headers={"Content-Type": "application/xml"}) + await send_request(request) + + request = xml.build_get_complex_type_ref_with_meta_request() + root = ET.fromstring(await send_request_text_response(request)) + ref_to_model = root.find('XMLComplexTypeWithMeta') + assert ref_to_model.find('ID').text == "myid" + request = xml.build_put_complex_type_ref_with_meta_request(content=root, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_list_containers(send_request, send_request_text_response): + request = xml.build_list_containers_request() + xml_body = ET.fromstring(await send_request_text_response(request)) + containers = xml_body.find('Containers') + container_list = list(containers.iterfind('Container')) + assert len(container_list) == 3 + +@pytest.mark.asyncio +async def test_list_blobs(send_request, send_request_text_response): + request = xml.build_list_blobs_request() + xml_body = ET.fromstring(await send_request_text_response(request)) + blobs_xml_body = xml_body.find('Blobs') + blobs = list(blobs_xml_body.iterfind('Blob')) + assert len(blobs) == 5 + assert blobs_xml_body.find('BlobPrefix') is None + blob = blobs[0] + assert blob.find('Name').text == "blob1.txt" + properties = blob.find('Properties') + assert properties.find('Last-Modified').text == 'Wed, 09 Sep 2009 09:20:02 GMT' + assert properties.find('Etag').text == "0x8CBFF45D8A29A19" + assert properties.find('Content-Length').text == "100" + assert properties.find('Content-Type').text == "text/html" + # Check that an empty field in the XML is empty string + assert properties.find('Content-Encoding').text is None + assert properties.find('Content-Language').text == "en-US" + assert properties.find('Content-MD5').text is None + assert properties.find('Cache-Control').text == "no-cache" + assert properties.find('BlobType').text == "BlockBlob" + # Check that a field NOT in the XML is None + assert properties.find('Destination-Snapshot') is None + metadata_body = blob.find('Metadata') + assert metadata_body.find("Color").text == "blue" + assert metadata_body.find("BlobNumber").text == "01" + assert metadata_body.find("SomeMetadataName").text == "SomeMetadataValue" + +@pytest.mark.asyncio +async def test_service_properties(send_request, send_request_text_response): + request = xml.build_get_service_properties_request() + properties = ET.fromstring(await send_request_text_response(request)) + assert properties.find('HourMetrics') is not None + assert properties.find('MinuteMetrics') is not None + request = xml.build_put_service_properties_request(content=properties, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_acls(send_request, send_request_text_response): + request = xml.build_get_acls_request() + acls = ET.fromstring(await send_request_text_response(request)) + signed_identifiers = list(acls.iterfind('SignedIdentifier')) + assert len(signed_identifiers) == 1 + assert signed_identifiers[0].find('Id').text == 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=' + request = xml.build_put_acls_request(content=acls, headers={"Content-Type": "application/xml"}) + await send_request(request) + + +@pytest.mark.asyncio +async def test_xms_text(send_request, send_request_text_response): + request = xml.build_get_xms_text_request() + xml_object = ET.fromstring(await send_request_text_response(request)) + assert xml_object.attrib['language'] == "english" + assert xml_object.text == "I am text" + +@pytest.mark.asyncio +async def test_bytes(send_request, send_request_text_response): + request = xml.build_get_bytes_request() + bytes_object = ET.fromstring(await send_request_text_response(request)) + assert bytes_object.tag == 'ModelWithByteProperty' + assert b64decode(bytes_object.find('Bytes').text) == b"Hello world" + + request = xml.build_put_binary_request(content=bytes_object, headers={"Content-Type": "application/xml"}) + await send_request(request) + +@pytest.mark.asyncio +async def test_url(send_request, send_request_text_response): + request = xml.build_get_uri_request() + url_object = ET.fromstring(await send_request_text_response(request)) + assert url_object.tag == 'ModelWithUrlProperty' + assert url_object.find('Url').text == 'https://myaccount.blob.core.windows.net/' + + request = xml.build_put_uri_request(content=url_object, headers={"Content-Type": "application/xml"}) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/conftest.py b/test/vanilla/low-level/AcceptanceTests/conftest.py new file mode 100644 index 00000000000..51e4afde427 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/conftest.py @@ -0,0 +1,117 @@ +# -------------------------------------------------------------------------- +# +# 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 glob +import sys +import subprocess +import os +import signal +from os.path import dirname, realpath +from unittest import TestLoader, TextTestRunner +from msrest import Serializer, Deserializer + +from os.path import dirname, pardir, join, realpath + +from azure.core.pipeline.policies import SansIOHTTPPolicy + +import pytest + + +cwd = dirname(realpath(__file__)) + +#Ideally this would be in a common helper library shared between the tests +def start_server_process(): + cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) + if os.name == 'nt': #On windows, subprocess creation works without being in the shell + return subprocess.Popen(cmd) + + return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True + +#Ideally this would be in a common helper library shared between the tests +def terminate_server_process(process): + if os.name == 'nt': + process.kill() + else: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups + +@pytest.fixture(scope="session") +def testserver(): + """Start the Autorest testserver.""" + server = start_server_process() + yield + terminate_server_process(server) + +# Ignore collection of async tests for Python 2 +collect_ignore = [] +if sys.version_info < (3,5): + collect_ignore.append("asynctests") + +@pytest.fixture() +def base_send_request(): + def send_request(client, request): + response = client.send_request(request) + response.raise_for_status() + return response + return send_request + +@pytest.fixture() +def base_send_request_json_response(): + def send_request_json_response(client, request): + response = client.send_request(request) + response.raise_for_status() + return response.json() + return send_request_json_response + +@pytest.fixture() +def msrest_serializer(): + return Serializer() + +@pytest.fixture() +def msrest_deserializer(): + return Deserializer() + +class CookiePolicy(SansIOHTTPPolicy): + def __init__(self, *args, **kwargs): + self._current_cookie = None + + def on_request(self, request, **kwargs): + # type: (PipelineRequest, Any) -> None + http_request = request.http_request + if self._current_cookie: + http_request.headers["Cookie"] = self._current_cookie + self._current_cookie = None + + def on_response(self, request, response, **kwargs): + # type: (PipelineRequest, PipelineResponse, Any) -> None + http_response = response.http_response + + if "Set-Cookie" in http_response.headers: + self._current_cookie = http_response.headers["Set-Cookie"] + +@pytest.fixture() +def cookie_policy(): + return CookiePolicy() + diff --git a/test/vanilla/low-level/AcceptanceTests/test_additional_properties.py b/test/vanilla/low-level/AcceptanceTests/test_additional_properties.py new file mode 100644 index 00000000000..a2c1d52a9fe --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_additional_properties.py @@ -0,0 +1,127 @@ +# -------------------------------------------------------------------------- +# +# 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 additionalpropertieslowlevel import AdditionalPropertiesClient +from additionalpropertieslowlevel.rest import pets + +@pytest.fixture +def client(): + with AdditionalPropertiesClient(base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_create_ap_true(send_request_json_response): + json = { + 'birthdate': '2017-12-13T02:29:51Z', + 'complexProperty': { + 'color': 'Red' + }, + "id": 1, + "name": "Puppy", + } + request = pets.build_create_ap_true_request(json=json) + response = send_request_json_response(request) + assert response["birthdate"] == '2017-12-13T02:29:51Z' + +def test_create_cat_ap_true(send_request_json_response): + json = { + 'birthdate': '2017-12-13T02:29:51Z', + 'complexProperty': {'color': 'Red'}, + 'id': 1, + 'name': 'Lisa', + 'friendly': True + } + request = pets.build_create_cat_ap_true_request(json=json) + response = send_request_json_response(request) + assert response['birthdate'] == '2017-12-13T02:29:51Z' + +def test_create_ap_object(send_request_json_response): + json = { + "id": 2, + "name": "Hira", + 'siblings': [{ + 'id': 1, + 'name': 'Puppy', + 'birthdate': '2017-12-13T02:29:51Z', + 'complexProperty': { + 'color': 'Red' + } + }], + 'picture': '//////4=' + } + request = pets.build_create_ap_object_request(json=json) + response = send_request_json_response(request) + assert response['siblings'][0]['birthdate'] == '2017-12-13T02:29:51Z' + +def test_create_ap_string(send_request_json_response): + json = { + "id": 3, + "name": 'Tommy', + 'color': 'red', + 'weight': '10 kg', + 'city': 'Bombay' + } + request = pets.build_create_ap_string_request(json=json) + response = send_request_json_response(request) + assert response['color'] == 'red' + +def test_create_ap_in_properties(send_request_json_response): + json = { + "id": 4, + "name": 'Bunny', + "additionalProperties": { + 'height': 5.61, + 'weight': 599, + 'footsize': 11.5 + } + } + request = pets.build_create_ap_in_properties_request(json=json) + response = send_request_json_response(request) + assert response["additionalProperties"]['weight'] == 599 + +def test_create_ap_in_properties_with_ap_string(send_request_json_response): + json = { + "id": 5, + "name": 'Funny', + "@odata.location":'westus', + 'color': 'red', + 'city': 'Seattle', + 'food': 'tikka masala', + "additionalProperties": { + 'height': 5.61, + 'weight': 599, + 'footsize': 11.5 + } + } + request = pets.build_create_ap_in_properties_with_ap_string_request(json=json) + response = send_request_json_response(request) + assert response['color'] == 'red' + assert response['additionalProperties']['weight'] == 599 \ No newline at end of file diff --git a/test/vanilla/low-level/AcceptanceTests/test_anything.py b/test/vanilla/low-level/AcceptanceTests/test_anything.py new file mode 100644 index 00000000000..dcdf5922fe3 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_anything.py @@ -0,0 +1,68 @@ +# -------------------------------------------------------------------------- +# +# 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 anythinglowlevel import AnythingClient, rest + +@pytest.fixture +def client(): + with AnythingClient(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_get_string(send_request_json_response): + request = rest.build_get_string_request() + assert send_request_json_response(request) == 'anything' + +def test_put_string(send_request): + request = rest.build_put_string_request(json="anything") + send_request(request) + +def test_get_object(send_request_json_response): + request = rest.build_get_object_request() + assert send_request_json_response(request) == {"message": "An object was successfully returned"} + +def test_put_object(send_request): + request = rest.build_put_object_request(json={'foo': 'bar'}) + send_request(request) + +def test_get_array(send_request_json_response): + request = rest.build_get_array_request() + assert send_request_json_response(request) == ['foo', 'bar'] + +def test_put_array(send_request): + request = rest.build_put_array_request(json=['foo', 'bar']) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_array.py b/test/vanilla/low-level/AcceptanceTests/test_array.py new file mode 100644 index 00000000000..a76fd461155 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_array.py @@ -0,0 +1,363 @@ +# -------------------------------------------------------------------------- +# +# 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 json +import isodate +from datetime import date, datetime, timedelta +from base64 import b64encode +from bodyarraylowlevel import AutoRestSwaggerBATArrayService +from bodyarraylowlevel.rest import array +from azure.core.exceptions import DecodeError +import msrest + +import pytest + +@pytest.fixture +def client(): + with AutoRestSwaggerBATArrayService(base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def datetimes(): + datetime1 = isodate.parse_datetime("2000-12-01T00:00:01Z") + datetime2 = isodate.parse_datetime("1980-01-02T00:11:35Z") + datetime3 = isodate.parse_datetime("1492-10-12T10:15:01Z") + return [datetime1, datetime2, datetime3] + +@pytest.fixture +def products(): + prod1 = {"integer": 1, "string": "2"} + prod2 = {"integer": 3, "string": "4"} + prod3 = {"integer": 5, "string": "6"} + return [prod1, prod2, prod3] + +@pytest.fixture +def listdict(): + return [{"1": "one", "2": "two", "3": "three"}, + {"4": "four", "5": "five", "6": "six"}, + {"7": "seven", "8": "eight", "9": "nine"}] + +@pytest.fixture +def send_request(client, base_send_request): + def _send_request(request): + return base_send_request(client, request) + return _send_request + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + + +def test_empty(send_request, send_request_json_response): + request = array.build_get_empty_request() + + assert [] == send_request_json_response(request) + + request = array.build_get_null_request() + response = send_request(request) + assert response.text == '' + + request = array.build_put_empty_request(json=[]) + send_request(request) + +def test_boolean_tfft(send_request, send_request_json_response): + request = array.build_get_boolean_tfft_request() + assert [True, False, False, True] == send_request_json_response(request) + request = array.build_put_boolean_tfft_request(json=[True, False, False, True]) + send_request(request) + +def test_integer_valid(send_request, send_request_json_response): + request = array.build_get_integer_valid_request() + assert [1, -1, 3, 300] == send_request_json_response(request) + request = array.build_put_integer_valid_request(json=[1, -1, 3, 300]) + send_request(request) + +def test_long_valid(send_request, send_request_json_response): + request = array.build_get_long_valid_request() + assert [1, -1, 3, 300] == send_request_json_response(request) + request = array.build_put_long_valid_request(json=[1, -1, 3, 300]) + send_request(request) + +def test_float_valid(send_request, send_request_json_response): + request = array.build_get_float_valid_request() + assert [0, -0.01, -1.2e20] == send_request_json_response(request) + request = array.build_put_float_valid_request(json=[0, -0.01, -1.2e20]) + send_request(request) + +def test_double_valid(send_request, send_request_json_response): + request = array.build_get_double_valid_request() + assert [0, -0.01, -1.2e20] == send_request_json_response(request) + request = array.build_put_double_valid_request(json=[0, -0.01, -1.2e20]) + send_request(request) + +def test_string_valid(send_request, send_request_json_response): + request = array.build_get_string_valid_request() + assert ["foo1", "foo2", "foo3"] == send_request_json_response(request) + request = array.build_put_string_valid_request(json=["foo1", "foo2", "foo3"]) + send_request(request) + +def test_get_string_with_null(send_request_json_response): + request = array.build_get_string_with_null_request() + assert ["foo", None, "foo2"] == send_request_json_response(request) + +def test_get_string_with_invalid(send_request_json_response): + request = array.build_get_string_with_invalid_request() + + # response differs from convenience layer + # this is bc in convenence layer we tell the deserializer to deserialize it fully as a list of string + assert ["foo", 123, "foo2"] == send_request_json_response(request) + +def test_uuid_valid(send_request, send_request_json_response): + request = array.build_get_uuid_valid_request() + assert ["6dcc7237-45fe-45c4-8a6b-3a8a3f625652", "d1399005-30f7-40d6-8da6-dd7c89ad34db", + "f42f6aa1-a5bc-4ddf-907e-5f915de43205"] == send_request_json_response(request) + request = array.build_put_uuid_valid_request(json=["6dcc7237-45fe-45c4-8a6b-3a8a3f625652", "d1399005-30f7-40d6-8da6-dd7c89ad34db", + "f42f6aa1-a5bc-4ddf-907e-5f915de43205"]) + send_request(request) + +def test_get_uuid_invalid_chars(send_request, send_request_json_response): + #Handles invalid characters without error because of no guid class + request = array.build_get_uuid_invalid_chars_request() + assert ["6dcc7237-45fe-45c4-8a6b-3a8a3f625652", "foo"] == send_request_json_response(request) + +def test_date_valid(send_request, send_request_json_response): + def datetime_handler(x): + if isinstance(x, datetime.date): + return x.isoformat() + raise TypeError("Unknown type") + date1 = isodate.parse_date("2000-12-01") + date2 = isodate.parse_date("1980-01-02") + date3 = isodate.parse_date("1492-10-12") + + request = array.build_get_date_valid_request() + assert send_request_json_response(request), [date1, date2 == date3] + request = array.build_put_date_valid_request(json=[str(date1), str(date2), str(date3)]) # dates are not json serializable + send_request(request) + +def test_date_time_valid(send_request, send_request_json_response, datetimes, msrest_serializer): + request = array.build_get_date_time_valid_request() + + assert send_request_json_response(request), [datetimes[0], datetimes[1] == datetimes[2]] + request = array.build_put_date_time_valid_request(json=[msrest_serializer.serialize_iso(datetime) for datetime in datetimes]) + send_request(request) + +def test_date_time_rfc1123_valid(send_request, send_request_json_response, datetimes, msrest_serializer): + request = array.build_get_date_time_rfc1123_valid_request() + assert send_request_json_response(request), [datetimes[0], datetimes[1] == datetimes[2]] + request = array.build_put_date_time_rfc1123_valid_request(json=[msrest_serializer.serialize_rfc(datetime) for datetime in datetimes]) + send_request(request) + +def test_duration_valid(send_request, send_request_json_response): + duration1 = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + duration2 = timedelta(days=5, hours=1) + + request = array.build_get_duration_valid_request() + assert send_request_json_response(request), [duration1 == duration2] + request = array.build_put_duration_valid_request(json=[isodate.duration_isoformat(duration1), isodate.duration_isoformat(duration2)]) + send_request(request) + +def test_byte_valid(send_request, send_request_json_response): + bytes1 = bytearray([0x0FF, 0x0FF, 0x0FF, 0x0FA]) + bytes2 = bytearray([0x01, 0x02, 0x03]) + bytes3 = bytearray([0x025, 0x029, 0x043]) + + request = array.build_get_byte_valid_request() + assert send_request_json_response(request), [bytes1, bytes2 == bytes3] + request = array.build_put_byte_valid_request(json=[b64encode(b).decode() for b in [bytes1, bytes2, bytes3]]) + send_request(request) + +def test_get_byte_invalid_null(send_request_json_response): + request = array.build_get_byte_invalid_null_request() + assert send_request_json_response(request), [bytearray([0x0AB, 0x0AC, 0x0AD]) == None] + +def test_get_complex_null(send_request): + request = array.build_get_complex_null_request() + assert send_request(request).text == '' + +def test_get_complex_empty(send_request_json_response): + request = array.build_get_complex_empty_request() + assert [] == send_request_json_response(request) + +def test_complex_valid(send_request, send_request_json_response, products): + request = array.build_get_complex_valid_request() + assert products == send_request_json_response(request) + request = array.build_put_complex_valid_request(json=products) + send_request(request) + +def test_get_array_valid(send_request, send_request_json_response): + listlist = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] + request = array.build_get_array_valid_request() + assert listlist == send_request_json_response(request) + request = array.build_put_array_valid_request(json=listlist) + send_request(request) + + +def test_dictionary_valid(send_request, send_request_json_response, listdict): + request = array.build_get_dictionary_valid_request() + assert listdict == send_request_json_response(request) + request = array.build_put_dictionary_valid_request(json=listdict) + send_request(request) + +def test_get_complex_item_null(send_request_json_response, products): + products_null = [products[0], None, products[2]] + request = array.build_get_complex_item_null_request() + assert products_null == send_request_json_response(request) + +def test_get_complex_item_empty(send_request_json_response, products): + products_empty = [products[0], {}, products[2]] + + request = array.build_get_complex_item_empty_request() + assert products_empty == send_request_json_response(request) + +def test_get_array_null(send_request): + request = array.build_get_array_null_request() + assert send_request(request).text == '' + +def test_get_array_empty(send_request_json_response): + request = array.build_get_array_empty_request() + assert [] == send_request_json_response(request) + +def test_get_array_item_null(send_request_json_response): + listlist2 = [["1", "2", "3"], None, ["7", "8", "9"]] + request = array.build_get_array_item_null_request() + assert listlist2 == send_request_json_response(request) + +def test_get_array_item_empty(send_request_json_response): + listlist3 = [["1", "2", "3"], [], ["7", "8", "9"]] + request = array.build_get_array_item_empty_request() + assert listlist3 == send_request_json_response(request) + +def test_get_dictionary_and_dictionary_item_null(send_request, send_request_json_response, listdict): + + request = array.build_get_dictionary_null_request() + assert send_request(request).text == '' + + listdict[1] = None + request = array.build_get_dictionary_item_null_request() + assert listdict == send_request_json_response(request) + +def test_get_dictionary_and_dictionary_item_empty(send_request_json_response, listdict): + request = array.build_get_dictionary_empty_request() + assert [] == send_request_json_response(request) + + listdict[1] = {} + request = array.build_get_dictionary_item_empty_request() + assert listdict == send_request_json_response(request) + +def test_array_get_invalid(send_request_json_response): + request = array.build_get_invalid_request() + with pytest.raises(json.decoder.JSONDecodeError): + send_request_json_response(request) + +def test_array_get_boolean_invalid_null(send_request_json_response): + request = array.build_get_boolean_invalid_null_request() + assert send_request_json_response(request), [True, None == False] + +def test_array_get_boolean_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_boolean_invalid_string_request() + assert send_request_json_response(request) == [True, "boolean", False] + +def test_array_get_int_invalid_null(send_request_json_response): + request = array.build_get_int_invalid_null_request() + assert send_request_json_response(request), [1, None == 0] + +def test_array_get_int_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_int_invalid_string_request() + assert send_request_json_response(request) == [1, "integer", 0] + +def test_array_get_long_invalid_null(send_request_json_response): + request = array.build_get_long_invalid_null_request() + assert send_request_json_response(request), [1, None == 0] + +def test_array_get_long_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_long_invalid_string_request() + assert send_request_json_response(request) == [1, "integer", 0] + +def test_array_get_float_invalid_null(send_request_json_response): + request = array.build_get_float_invalid_null_request() + assert send_request_json_response(request), [0.0, None == -1.2e20] + +def test_array_get_float_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_float_invalid_string_request() + assert send_request_json_response(request) == [1, "number", 0] + +def test_array_get_double_invalid_null(send_request_json_response): + request = array.build_get_double_invalid_null_request() + assert send_request_json_response(request), [0.0, None == -1.2e20] + +def test_array_get_double_invalid_string(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_double_invalid_string_request() + assert send_request_json_response(request) == [1, "number", 0] + +def test_array_get_string_with_invalid(send_request_json_response): + request = array.build_get_string_with_invalid_request() + assert send_request_json_response(request), ["foo", "123" == "foo2"] + +def test_array_get_date_invalid_null(send_request_json_response): + request = array.build_get_date_invalid_null_request() + assert send_request_json_response(request), [isodate.parse_date("2012-01-01"), None == isodate.parse_date("1776-07-04")] + +def test_array_get_date_invalid_chars(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_date_invalid_chars_request() + assert send_request_json_response(request) == ["2011-03-22", "date"] + +def test_array_get_date_time_invalid_null(send_request_json_response): + request = array.build_get_date_time_invalid_null_request() + assert send_request_json_response(request), [isodate.parse_datetime("2000-12-01T00:00:01Z") == None] + +def test_array_get_date_time_invalid_chars(send_request_json_response): + # don't raise deserialization error bc we're not msrest deserializing + request = array.build_get_date_time_invalid_chars_request() + assert send_request_json_response(request) == ['2000-12-01t00:00:01z', 'date-time'] + +def test_array_get_base64_url(send_request_json_response, msrest_deserializer): + test_array = ['a string that gets encoded with base64url'.encode(), + 'test string'.encode(), + 'Lorem ipsum'.encode()] + request = array.build_get_base64_url_request() + response = send_request_json_response(request) + assert [msrest_deserializer.deserialize_base64(s) for s in send_request_json_response(request)] == test_array + +def test_array_enum_valid(send_request, send_request_json_response): + request = array.build_get_enum_valid_request() + response = send_request_json_response(request) + assert response == ['foo1', 'foo2', 'foo3'] + request = array.build_put_enum_valid_request(json=response) + send_request(request) + +def test_array_string_enum_valid(send_request, send_request_json_response): + request = array.build_get_string_enum_valid_request() + response = send_request_json_response(request) + assert response == ['foo1', 'foo2', 'foo3'] + request = array.build_put_string_enum_valid_request(json=response) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_bool.py b/test/vanilla/low-level/AcceptanceTests/test_bool.py new file mode 100644 index 00000000000..9493d4ec0fd --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_bool.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from bodybooleanlowlevel import AutoRestBoolTestService +from bodybooleanlowlevel.rest import bool +import pytest +from azure.core.exceptions import DecodeError + +@pytest.fixture +def client(): + with AutoRestBoolTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_model_get_true(send_request_json_response): + request = bool.build_get_true_request() + assert send_request_json_response(request) == True + +def test_model_get_false(send_request_json_response): + request = bool.build_get_false_request() + assert not send_request_json_response(request) + +def test_model_get_null(send_request): + request = bool.build_get_null_request() + assert send_request(request).text == '' + +def test_model_put_false(send_request): + request = bool.build_put_false_request(json=False) # have to pass in bc we don't do constant bodies in request builders + send_request(request) + +def test_model_put_true(send_request): + request = bool.build_put_true_request(json=True) # have to pass in bc we don't do constant bodies in request builders + send_request(request) + +def test_model_get_invalid(send_request): + request = bool.build_get_invalid_request() + assert send_request(request).text == "true1" diff --git a/test/vanilla/low-level/AcceptanceTests/test_byte.py b/test/vanilla/low-level/AcceptanceTests/test_byte.py new file mode 100644 index 00000000000..17079321fab --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_byte.py @@ -0,0 +1,60 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from bodybytelowlevel import AutoRestSwaggerBATByteService +from bodybytelowlevel.rest import byte +from base64 import b64encode +import pytest + +@pytest.fixture +def client(): + with AutoRestSwaggerBATByteService(base_url="http://localhost:3000") 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_non_ascii(send_request): + tests = bytearray([0x0FF, 0x0FE, 0x0FD, 0x0FC, 0x0FB, 0x0FA, 0x0F9, 0x0F8, 0x0F7, 0x0F6]) + request = byte.build_put_non_ascii_request(json=b64encode(tests).decode()) + send_request(request) + + request = byte.build_get_non_ascii_request() + send_request(request) + +def test_get_null(send_request): + request = byte.build_get_null_request() + assert send_request(request).text == '' + +def test_get_empty(send_request): + request = byte.build_get_empty_request() + assert b'""' == send_request(request).content # in convenience layer, we deserialize as bytearray specif + +def test_get_invalid(send_request): + request = byte.build_get_invalid_request() + assert send_request(request).content == b'"::::SWAGGER::::"' diff --git a/test/vanilla/low-level/AcceptanceTests/test_complex.py b/test/vanilla/low-level/AcceptanceTests/test_complex.py new file mode 100644 index 00000000000..f6218b3681e --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_complex.py @@ -0,0 +1,614 @@ +# -------------------------------------------------------------------------- +# +# 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 +import isodate +from datetime import datetime, timedelta, tzinfo +from bodycomplexlowlevel import AutoRestComplexTestService +from bodycomplexlowlevel.rest import ( + basic, + primitive, + readonlyproperty, + array, + dictionary, + polymorphism, + polymorphicrecursive, + inheritance, +) +from azure.core.exceptions import HttpResponseError +from msrest import Serializer, Deserializer +from base64 import b64decode, b64encode + +class UTC(tzinfo): + def utcoffset(self,dt): + return timedelta(hours=0,minutes=0) + + def tzname(self,dt): + return "Z" + + def dst(self,dt): + return timedelta(0) + +import pytest + +@pytest.fixture +def client(): + with AutoRestComplexTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def min_date(): + min_date = datetime.min + return min_date.replace(tzinfo=UTC()) + +def test_basic_get_and_put_valid(send_request, send_request_json_response): + # GET basic/valid + request = basic.build_get_valid_request() + basic_result = send_request_json_response(request) + assert 2 == basic_result['id'] + assert "abc" == basic_result['name'] + assert "YELLOW" == basic_result['color'] + + # PUT basic/valid + json = { + "id": 2, + "name": "abc", + "color": "Magenta", + } + request = basic.build_put_valid_request(json=json) + send_request(request) + json = { + "id": 2, + "name": "abc", + "color": "Magenta", + } + request = basic.build_put_valid_request(json=json) + send_request(request) + +def test_basic_get_empty(send_request, send_request_json_response): + # GET basic/empty + request = basic.build_get_empty_request() + basic_result = send_request_json_response(request) + assert basic_result == {} + +def test_basic_get_null(send_request_json_response): + # GET basic/null + request = basic.build_get_null_request() + basic_result = send_request_json_response(request) + assert basic_result['id'] is None + assert basic_result['name'] is None + +def test_basic_get_not_provided(send_request): + # GET basic/notprovided + request = basic.build_get_not_provided_request() + assert send_request(request).text == '' + +def test_basic_get_invalid(send_request_json_response): + # GET basic/invalid + request = basic.build_get_invalid_request() + basic_result = send_request_json_response(request) + # it's deserialized as invalid bc the id is not a number + # with LLC, we don't care thought + assert basic_result['id'] == 'a' + assert basic_result['name'] == 'abc' + +# COMPLEX TYPE WITH PRIMITIVE PROPERTIES +def test_primitive_get_and_put_int(send_request, send_request_json_response): + # GET primitive/integer + request = primitive.build_get_int_request() + int_result = send_request_json_response(request) + assert -1 == int_result['field1'] + assert 2 == int_result['field2'] + + # PUT primitive/integer + int_request = {'field1':-1, 'field2':2} + request = primitive.build_put_int_request(json=int_request) + send_request(request) + +def test_primitive_get_and_put_long(send_request, send_request_json_response): + # GET primitive/long + request = primitive.build_get_long_request() + long_result = send_request_json_response(request) + assert 1099511627775 == long_result['field1'] + assert -999511627788 == long_result['field2'] + + # PUT primitive/long + json = {'field1':1099511627775, 'field2':-999511627788} + request = primitive.build_put_long_request(json=json) + send_request(request) + +def test_primitive_get_and_put_float(send_request, send_request_json_response): + # GET primitive/float + request = primitive.build_get_float_request() + float_result = send_request_json_response(request) + assert 1.05 == float_result['field1'] + assert -0.003 == float_result['field2'] + + # PUT primitive/float + json = { + "field1": 1.05, + "field2": -0.003 + } + request = primitive.build_put_float_request(json=json) + send_request(request) + +def test_primitive_get_and_put_double(send_request, send_request_json_response): + # GET primitive/double + request = primitive.build_get_double_request() + double_result =send_request_json_response(request) + assert 3e-100 == double_result['field1'] + assert -5e-57 == double_result['field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose'] + + # PUT primitive/double + json = { + "field1": 3e-100, + "field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose": -5e-57 + } + request = primitive.build_put_double_request(json=json) + send_request(request) + +def test_primitive_get_and_put_bool(send_request, send_request_json_response): + # GET primitive/bool + request = primitive.build_get_bool_request() + bool_result = send_request_json_response(request) + assert bool_result['field_true'] + assert not bool_result['field_false'] + + # PUT primitive/bool + json = { + "field_true": True, + "field_false": False + } + request = primitive.build_put_bool_request(json=json) + send_request(request) + +def test_primitive_get_and_put_string(send_request, send_request_json_response): + # GET primitive/string + request = primitive.build_get_string_request() + string_result = send_request_json_response(request) + assert "goodrequest" == string_result['field'] + assert "" == string_result['empty'] + assert string_result['null'] is None + + # PUT primitive/string + json = { + "null": None, + "empty": "", + "field": "goodrequest" + } + request = primitive.build_put_string_request(json=json) + send_request(request) + +def test_primitive_get_and_put_date(send_request, send_request_json_response): + # GET primitive/date + request = primitive.build_get_date_request() + date_result = send_request_json_response(request) + assert isodate.parse_date("0001-01-01") == isodate.parse_date(date_result['field']) + assert isodate.parse_date("2016-02-29") == isodate.parse_date(date_result['leap']) + + json = { + "field": '0001-01-01', + "leap": '2016-02-29' + } + request = primitive.build_put_date_request(json=json) + send_request(request) + +def test_primitive_get_and_put_date_time(send_request, send_request_json_response, min_date): + # GET primitive/datetime + request = primitive.build_get_date_time_request() + datetime_result = send_request_json_response(request) + + assert min_date == Deserializer.deserialize_iso(datetime_result['field']) + + json = { + "field": "0001-01-01T00:00:00Z", + "now": "2015-05-18T18:38:00Z" + } + request = primitive.build_put_date_time_request(json=json) + send_request(request) + +def test_primitive_get_and_put_date_time_rfc1123(send_request, send_request_json_response): + # GET primitive/datetimerfc1123 + request = primitive.build_get_date_time_rfc1123_request() + datetimerfc1123_result = send_request_json_response(request) + + # we are not using the min date of year 1 because of the latest msrest update + # with msrest update, minimal year we can parse is 100, instead of 1 + min_date = datetime(2001, 1, 1) + assert min_date.replace(tzinfo=UTC()) == Deserializer.deserialize_rfc(datetimerfc1123_result['field']) + + # we can still model year 1 though with the latest msrest update + json = { + "field": Serializer.serialize_rfc(isodate.parse_datetime("0001-01-01T00:00:00Z")), + "now": Serializer.serialize_rfc(isodate.parse_datetime("2015-05-18T11:38:00Z")) + } + request = primitive.build_put_date_time_rfc1123_request(json=json) + send_request(request) + +def test_primitive_get_and_put_duration(send_request, send_request_json_response): + # GET primitive/duration + expected = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + request = primitive.build_get_duration_request() + duration_result = send_request_json_response(request) + assert expected == Deserializer.deserialize_duration(duration_result['field']) + + request = primitive.build_put_duration_request(json={"field": Serializer.serialize_duration(expected)}) + send_request(request) + +def test_primitive_get_and_put_byte(send_request, send_request_json_response): + # GET primitive/byte + request = primitive.build_get_byte_request() + byte_result = send_request_json_response(request) + valid_bytes = bytearray([0x0FF, 0x0FE, 0x0FD, 0x0FC, 0x000, 0x0FA, 0x0F9, 0x0F8, 0x0F7, 0x0F6]) + assert valid_bytes == bytearray(b64decode(byte_result['field'])) + + # PUT primitive/byte + request = primitive.build_put_byte_request(json={"field": b64encode(valid_bytes).decode()}) + send_request(request) + +# COMPLEX TYPE WITH READ ONLY PROPERTIES + +def test_readonlyproperty_get_and_put_valid(send_request, send_request_json_response): + # GET readonly/valid + valid_obj = {"size": 2, 'id': '1234'} + request = readonlyproperty.build_get_valid_request() + readonly_result = send_request_json_response(request) + assert readonly_result == valid_obj + + # PUT readonly/valid + request = readonlyproperty.build_put_valid_request(json=2) + assert send_request(request).text == '' + +# COMPLEX TYPE WITH ARRAY PROPERTIES + +def test_array_get_and_put_valid(send_request, send_request_json_response): + # GET array/valid + request = array.build_get_valid_request() + array_result = send_request_json_response(request) + assert 5 == len(array_result['array']) + + array_value = ["1, 2, 3, 4", "", None, "&S#$(*Y", + "The quick brown fox jumps over the lazy dog"] + assert array_result['array'] == array_value + + # PUT array/valid + request = array.build_put_valid_request(json={"array": array_value}) + send_request(request) + +def test_array_get_and_put_empty(send_request, send_request_json_response): + + # GET array/empty + request = array.build_get_empty_request() + array_result = send_request_json_response(request) + assert 0 == len(array_result['array']) + + # PUT array/empty + request = array.build_put_empty_request(json={"array": []}) + send_request(request) + +def test_array_get_not_provided(send_request_json_response): + # Get array/notprovided + request = array.build_get_not_provided_request() + assert send_request_json_response(request) == {} + +# COMPLEX TYPE WITH DICTIONARY PROPERTIES + +def test_dictionary_get_and_put_valid(send_request, send_request_json_response): + # GET dictionary/valid + request = dictionary.build_get_valid_request() + dict_result = send_request_json_response(request) + assert 5 == len(dict_result['defaultProgram']) + + dict_val = {'txt':'notepad', 'bmp':'mspaint', 'xls':'excel', 'exe':'', '':None} + assert dict_val == dict_result['defaultProgram'] + + # PUT dictionary/valid + request = dictionary.build_put_valid_request(json={"defaultProgram": dict_val}) + send_request(request) + +def test_dictionary_get_and_put_empty(send_request, send_request_json_response): + # GET dictionary/empty + request = dictionary.build_get_empty_request() + dict_result = send_request_json_response(request) + assert 0 == len(dict_result['defaultProgram']) + + # PUT dictionary/empty + request = dictionary.build_put_empty_request(json={"defaultProgram": {}}) + send_request(request) + +def test_dictionary_get_and_null(send_request_json_response): + # GET dictionary/null + request = dictionary.build_get_null_request() + dictionary_result = send_request_json_response(request) + assert dictionary_result['defaultProgram'] is None + +def test_dictionary_get_not_provided(send_request_json_response): + # GET dictionary/notprovided + request = dictionary.build_get_not_provided_request() + assert send_request_json_response(request) == {} + + +# COMPLEX TYPES THAT INVOLVE INHERITANCE + +def test_inheritance_get_and_put_valid(send_request, send_request_json_response): + # GET inheritance/valid + request = inheritance.build_get_valid_request() + inheritance_result = send_request_json_response(request) + assert 2 == inheritance_result['id'] + assert "Siameeee" == inheritance_result['name'] + assert -1 == inheritance_result['hates'][1]['id'] + assert "Tomato" == inheritance_result['hates'][1]['name'] + + # PUT inheritance/valid + json = { + 'id': 2, + 'name': "Siameeee", + 'color': "green", + 'breed': "persian", + 'hates': [{"id": 1, "name": "Potato", "food": "tomato"}, + {"id": -1, "name": "Tomato", "food": "french fries"}] + } + request = inheritance.build_put_valid_request(json=json) + send_request(request) + +# COMPLEX TYPES THAT INVOLVE POLYMORPHISM + +def test_get_composed_with_discriminator(send_request_json_response): + request = polymorphism.build_get_composed_with_discriminator_request() + result = send_request_json_response(request) + assert result['sampleSalmon']['fish.type'] == "DotSalmon" + +def test_get_composed_without_discriminator(send_request_json_response): + request = polymorphism.build_get_composed_without_discriminator_request() + result = send_request_json_response(request) + with pytest.raises(KeyError): + result['sampleSalmon']['fish.type'] # shouldn't have a discriminator + +def test_polymorphism_get_and_put_valid(send_request, send_request_json_response): + # GET polymorphism/valid + request = polymorphism.build_get_valid_request() + result = send_request_json_response(request) + assert result is not None + assert result['location'] == "alaska" + assert len(result['siblings']) == 3 + assert result['siblings'][0]['fishtype'] == 'shark' + assert result['siblings'][1]['fishtype'] == 'sawshark' + assert result['siblings'][2]['fishtype'] == 'goblin' + assert result['siblings'][0]['age'] == 6 + assert result['siblings'][1]['age'] == 105 + assert result['siblings'][2]['age'] == 1 + + + # PUT polymorphism/valid + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + }, + { + "fishtype": "goblin", + "species": "scary", + "length": 30.0, + "age": 1, + "birthday": "2015-08-08T00:00:00.000Z", + "jawsize": 5, + "color": "pinkish-gray" + } + ], + "location": "alaska", + "iswild": True + } + request = polymorphism.build_put_valid_request(json=json) + send_request(request) + +def test_polymorphism_put_valid_missing_required(send_request): + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "picture": "//////4=" + } + ], + "location": "alaska", + "iswild": True + } + + request = polymorphism.build_put_valid_missing_required_request(json=json) + + # in convenience layer, this raises a ValidationError (when generated with client side validation) + with pytest.raises(HttpResponseError) as e: + send_request(request) + assert "Reached server in scenario: /complex/polymorphism/missingrequired/invalid" in str(e.value.response.text) + +# COMPLEX TYPES THAT INVOLVE RECURSIVE REFERENCE + +def test_polymorphismrecursive_get_and_put_valid(send_request, send_request_json_response): + # GET polymorphicrecursive/valid + # discriminator checks now just rely on checking the value of the discrimintaor + request = polymorphicrecursive.build_get_valid_request() + result = send_request_json_response(request) + assert result['fishtype'] == 'salmon' + assert result['siblings'][0]['fishtype'] == 'shark' + assert result['siblings'][0]['siblings'][0]['fishtype'] == 'salmon' + assert result['siblings'][0]['siblings'][0]['location'] == "atlantic" + + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + } + ], + "location": "atlantic", + "iswild": True + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "siblings": [], + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + } + ], + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "siblings": [], + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + } + ], + "location": "alaska", + "iswild": True + } + # PUT polymorphicrecursive/valid + request = polymorphicrecursive.build_put_valid_request(json=json) + send_request(request) + + +# Complex types that uses additional properties and polymorphism +def test_polymorphism_get_and_put_complicated(send_request, send_request_json_response): + request = polymorphism.build_get_complicated_request() + response = send_request_json_response(request) + request = polymorphism.build_put_complicated_request(json=response) + send_request(request) + +# Complex types that uses missing discriminator + +def test_polymorphism_get_and_put_missing_discriminator(send_request, send_request_json_response): + json = { + "fishtype": "salmon", + "species": "king", + "length": 1.0, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20.0, + "age": 6, + "birthday": "2012-01-05T01:00:00.000Z" + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10.0, + "age": 105, + "birthday": "1900-01-05T01:00:00.000Z", + "picture": "//////4=" + }, + { + "fishtype": "goblin", + "species": "scary", + "length": 30.0, + "age": 1, + "birthday": "2015-08-08T00:00:00.000Z", + "jawsize": 5, + "color": "pinkish-gray" + } + ], + "location": "alaska", + "iswild": True + } + # Not raise is enough of a test + request = polymorphism.build_put_missing_discriminator_request(json=json) + send_request(request) + + # Dot syntax + request = polymorphism.build_get_dot_syntax_request() + dot_salmon = send_request_json_response(request) + assert dot_salmon['fish.type'] == "DotSalmon" + assert dot_salmon['location'] == "sweden" diff --git a/test/vanilla/low-level/AcceptanceTests/test_config.py b/test/vanilla/low-level/AcceptanceTests/test_config.py new file mode 100644 index 00000000000..9b53312c2ea --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_config.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from azure.core.pipeline.policies import HttpLoggingPolicy +from bodystringlowlevel import AutoRestSwaggerBATService + +def test_http_logging_policy_default(): + with AutoRestSwaggerBATService(base_url="http://localhost:3000") as client: + assert isinstance(client._config.http_logging_policy, HttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == HttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST + +def test_http_logging_policy_custom(): + http_logging_policy = HttpLoggingPolicy(base_url="test") + http_logging_policy = HttpLoggingPolicy() + http_logging_policy.allowed_header_names.update( + {"x-ms-added-header"} + ) + with AutoRestSwaggerBATService(base_url="http://localhost:3000", http_logging_policy=http_logging_policy) as client: + assert isinstance(client._config.http_logging_policy, HttpLoggingPolicy) + assert client._config.http_logging_policy.allowed_header_names == HttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST.union({"x-ms-added-header"}) diff --git a/test/vanilla/low-level/AcceptanceTests/test_content_type.py b/test/vanilla/low-level/AcceptanceTests/test_content_type.py new file mode 100644 index 00000000000..0c27b0a9857 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_content_type.py @@ -0,0 +1,105 @@ +# 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 io +import os +from mediatypeslowlevel import MediaTypesClient +from mediatypeslowlevel.rest import * + +def test_json_body_no_content_type_kwarg(): + request = build_analyze_body_request(json={"source":"foo"}) + assert request.headers["Content-Type"] == "application/json" + assert request.content == '{"source": "foo"}' + + +def test_json_body_content_type_kwarg(): + request = build_analyze_body_request(json=[{"source":"foo"}], content_type="application/json+cloudevents-batch") + assert request.headers["Content-Type"] == "application/json+cloudevents-batch" + assert request.content == '[{"source": "foo"}]' + +def test_string_body_no_content_type_kwarg(): + request = build_analyze_body_request(content="hello") + assert request.headers["Content-Type"] == "text/plain" + +def test_string_body_content_type_kwarg(): + request = build_analyze_body_request(content="hello", content_type="text/plain") + assert request.headers["Content-Type"] == "text/plain" + +def test_io_body_no_content_type_kwarg(): + request = build_analyze_body_request(content=b"PDF") + assert not request.headers.get("Content-Type") + +def test_io_body_content_type_kwarg(): + request = build_analyze_body_request(content=b"PDF", content_type="application/pdf") + assert request.headers["Content-Type"] == "application/pdf" + +def test_stream_no_content_type_kwarg(): + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = build_analyze_body_request(content=stream_data) + assert not request.headers.get("Content-Type") + +def test_stream_content_type_kwarg(): + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = build_analyze_body_request(content=stream_data, content_type="application/json") + assert request.headers["Content-Type"] == "application/json" + +def test_file_description_no_content_type_kwarg(): + with open(__file__) as fd: + request = build_analyze_body_request(content=fd) + assert not request.headers.get("Content-Type") + +def test_file_description_content_type_kwarg(): + with open(__file__) as fd: + request = build_analyze_body_request(content=fd, content_type="application/pdf") + assert request.headers["Content-Type"] == "application/pdf" + +def test_content_type_in_headers_no_content_type_kwarg(): + request = build_analyze_body_request(content="", headers={"Content-Type": "application/exotic"}) + assert request.headers["Content-Type"] == "application/exotic" + +def test_content_type_in_headers_content_type_kwarg(): + request = build_analyze_body_request(content="", headers={"Content-Type": "application/exotic"}, content_type="application/pdf") + assert request.headers["Content-Type"] == "application/pdf" + +def test_stream_unread_until_send_request(): + class FakeStream: + def __init__(self): + self.call_count = 0 + + def streaming_body(self, data): + self.call_count += 1 + yield data + + fake_stream = FakeStream() + request = build_analyze_body_request(content=fake_stream.streaming_body(b"PDF")) + assert not request.headers.get("Content-Type") + assert fake_stream.call_count == 0 + MediaTypesClient().send_request(request) + assert fake_stream.call_count == 1 diff --git a/test/vanilla/low-level/AcceptanceTests/test_date.py b/test/vanilla/low-level/AcceptanceTests/test_date.py new file mode 100644 index 00000000000..7e6fa719e30 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_date.py @@ -0,0 +1,87 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +import datetime +from msrest.exceptions import DeserializationError + +from bodydatelowlevel import AutoRestDateTestService +from bodydatelowlevel.rest import date + +import pytest + +@pytest.fixture +def client(): + with AutoRestDateTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_model_get_and_put_max_date(send_request, send_request_json_response): + max_date = isodate.parse_date("9999-12-31T23:59:59.999999Z") + request = date.build_put_max_date_request(json=str(max_date)) + send_request(request) + + request = date.build_get_max_date_request() + assert max_date == isodate.parse_date(send_request_json_response(request)) + +def test_model_get_and_put_min_date(send_request, send_request_json_response): + min_date = isodate.parse_date("0001-01-01T00:00:00Z") + request = date.build_put_min_date_request(json=str(min_date)) + send_request(request) + + request = date.build_get_min_date_request() + assert min_date == isodate.parse_date(send_request_json_response(request)) + +def test_model_get_null(send_request): + request = date.build_get_null_request() + assert send_request(request).text == '' + +def test_model_get_invalid_date(send_request_json_response): + request = date.build_get_invalid_date_request() + assert datetime.date(2001, 1, 1) == isodate.parse_date(send_request_json_response(request)) + +def test_model_get_overflow_date(send_request_json_response): + request = date.build_get_overflow_date_request() + with pytest.raises(ValueError) as ex: + isodate.parse_date(send_request_json_response(request)) + assert "day is out of range for month" in str(ex.value) + +def test_model_get_underflow_date(send_request_json_response): + request = date.build_get_underflow_date_request() + with pytest.raises(ValueError) as ex: + isodate.parse_date(send_request_json_response(request)) + assert "year 0 is out of range" in str(ex.value) diff --git a/test/vanilla/low-level/AcceptanceTests/test_datetime.py b/test/vanilla/low-level/AcceptanceTests/test_datetime.py new file mode 100644 index 00000000000..21fbe66d287 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_datetime.py @@ -0,0 +1,151 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate + +from msrest.exceptions import DeserializationError, SerializationError + +from bodydatetimelowlevel import AutoRestDateTimeTestService +from bodydatetimelowlevel.rest import datetime + +import pytest + +@pytest.fixture +def client(): + with AutoRestDateTimeTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def get_deserialized_iso(send_request_json_response, msrest_deserializer): + def _get_deserialized_iso(request): + return msrest_deserializer.deserialize_iso(send_request_json_response(request)) + return _get_deserialized_iso + +@pytest.fixture +def get_serialized_iso(msrest_serializer): + def _get_serialized_iso(date): + return msrest_serializer.serialize_iso(date) + return _get_serialized_iso + + +def test_utc_max_date_time(send_request, get_serialized_iso, get_deserialized_iso): + max_date = isodate.parse_datetime("9999-12-31T23:59:59.999Z") + request = datetime.build_get_utc_lowercase_max_date_time_request() + assert max_date == get_deserialized_iso(request) + + request = datetime.build_get_utc_uppercase_max_date_time_request() + assert get_deserialized_iso(request) == max_date + + request = datetime.build_put_utc_max_date_time_request(json=get_serialized_iso(max_date)) + send_request(request) + +def test_utc_max_date_time_7digits(send_request, get_serialized_iso, get_deserialized_iso): + max_date = isodate.parse_datetime("9999-12-31T23:59:59.999999Z") + request = datetime.build_get_utc_uppercase_max_date_time7_digits_request() + assert get_deserialized_iso(request) == max_date + + request = datetime.build_put_utc_max_date_time7_digits_request(json=get_serialized_iso(max_date)) + with pytest.raises(Exception): + # Python doesn't support 7 digits + send_request(request) + +def test_get_utc_min_date_time(send_request, get_serialized_iso, get_deserialized_iso): + min_date = isodate.parse_datetime("0001-01-01T00:00:00Z") + request = datetime.build_get_utc_min_date_time_request() + assert get_deserialized_iso(request) == min_date + + request = datetime.build_put_utc_min_date_time_request(json=get_serialized_iso(min_date)) + send_request(request) + +def test_get_local_negative_offset_min_date_time(send_request, send_request_json_response, get_serialized_iso): + request = datetime.build_get_local_negative_offset_min_date_time_request() + assert '0001-01-01T00:00:00-14:00' == send_request_json_response(request) + + request = datetime.build_put_local_negative_offset_min_date_time_request(json=get_serialized_iso(isodate.parse_datetime("0001-01-01T00:00:00-14:00"))) + send_request(request) + +def test_get_local_no_offset_min_date_time(get_deserialized_iso): + local_no_offset_min_date_time = isodate.parse_datetime("0001-01-01T00:00:00") + request = datetime.build_get_local_no_offset_min_date_time_request() + assert get_deserialized_iso(request) == local_no_offset_min_date_time + +def test_get_local_negative_offset_lowercase_max_date_time(send_request_json_response): + request = datetime.build_get_local_negative_offset_lowercase_max_date_time_request() + assert send_request_json_response(request) == "9999-12-31t23:59:59.999-14:00" + +def test_get_local_negative_offset_uppercase_max_date_time(send_request_json_response): + request = datetime.build_get_local_negative_offset_uppercase_max_date_time_request() + assert send_request_json_response(request) == "9999-12-31T23:59:59.999-14:00" + +def test_local_positive_offset_min_date_time(send_request_json_response, get_serialized_iso): + request = datetime.build_get_local_positive_offset_min_date_time_request() + assert send_request_json_response(request) == "0001-01-01T00:00:00+14:00" + + with pytest.raises(SerializationError): + datetime.build_get_local_positive_offset_min_date_time_request(json=get_serialized_iso(isodate.parse_datetime("0001-01-01T00:00:00+14:00"))) + + +def test_local_positive_offset_max_date_time(send_request_json_response, send_request, get_serialized_iso): + request = datetime.build_get_local_positive_offset_lowercase_max_date_time_request() + assert send_request_json_response(request) == "9999-12-31t23:59:59.999+14:00" + + request = datetime.build_get_local_positive_offset_uppercase_max_date_time_request() + assert send_request_json_response(request) == "9999-12-31T23:59:59.999+14:00" + + request = datetime.build_put_local_positive_offset_max_date_time_request(json=get_serialized_iso(isodate.parse_datetime("9999-12-31T23:59:59.999999+14:00"))) + send_request(request) + +def test_get_null(send_request, get_serialized_iso, get_deserialized_iso): + request = datetime.build_get_null_request() + assert send_request(request).text == '' + +def test_get_overflow(send_request_json_response): + request = datetime.build_get_overflow_request() + assert send_request_json_response(request) == "9999-12-31T23:59:59.999-14:00" + +def test_get_invalid(send_request_json_response): + request = datetime.build_get_invalid_request() + assert send_request_json_response(request) == "201O-18-90D00:89:56.9AX" + +def test_get_underflow(send_request_json_response): + request = datetime.build_get_underflow_request() + assert send_request_json_response(request) == "0000-00-00T00:00:00.000+00:00" + +def test_put_local_negative_offset_max_date_time(get_serialized_iso): + with pytest.raises(SerializationError): + datetime.build_put_local_negative_offset_max_date_time_request(json=get_serialized_iso(isodate.parse_datetime("9999-12-31T23:59:59.999999-14:00"))) diff --git a/test/vanilla/low-level/AcceptanceTests/test_datetime_rfc.py b/test/vanilla/low-level/AcceptanceTests/test_datetime_rfc.py new file mode 100644 index 00000000000..3d49e0dbb7e --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_datetime_rfc.py @@ -0,0 +1,86 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate + +from msrest.exceptions import DeserializationError + +from bodydatetimerfc1123lowlevel import AutoRestRFC1123DateTimeTestService +from bodydatetimerfc1123lowlevel.rest import datetimerfc1123 + +import pytest + +@pytest.fixture +def client(): + with AutoRestRFC1123DateTimeTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_get_null(send_request): + request = datetimerfc1123.build_get_null_request() + assert send_request(request).text == '' + +def test_get_invalid(send_request_json_response): + request = datetimerfc1123.build_get_invalid_request() + assert "Tue, 01 Dec 2000 00:00:0A ABC" == send_request_json_response(request) + +def test_get_underflow(send_request_json_response): + request = datetimerfc1123.build_get_underflow_request() + assert "Tue, 00 Jan 0000 00:00:00 GMT" == send_request_json_response(request) + +def test_get_overflow(send_request_json_response): + request = datetimerfc1123.build_get_overflow_request() + assert "Sat, 1 Jan 10000 00:00:00 GMT" == send_request_json_response(request) + +def test_utc_max_date_time(send_request, msrest_serializer): + max_date = isodate.parse_datetime("9999-12-31T23:59:59.999999Z") + + request = datetimerfc1123.build_get_utc_lowercase_max_date_time_request() + send_request(request) + + request = datetimerfc1123.build_get_utc_uppercase_max_date_time_request() + send_request(request) + + request = datetimerfc1123.build_put_utc_max_date_time_request(json=msrest_serializer.serialize_rfc(max_date)) + send_request(request) + +def test_utc_min_date_time(send_request, msrest_serializer): + min_date = isodate.parse_datetime("0001-01-01T00:00:00Z") + request = datetimerfc1123.build_get_utc_min_date_time_request() + send_request(request) + + request = datetimerfc1123.build_put_utc_min_date_time_request(json=msrest_serializer.serialize_rfc(min_date)) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_dictionary.py b/test/vanilla/low-level/AcceptanceTests/test_dictionary.py new file mode 100644 index 00000000000..7ec99707d21 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_dictionary.py @@ -0,0 +1,380 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +import json +from datetime import timedelta +from bodydictionarylowlevel.rest import dictionary +from bodydictionarylowlevel import AutoRestSwaggerBATDictionaryService + + +import pytest + +@pytest.fixture +def client(): + with AutoRestSwaggerBATDictionaryService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def get_deserialized_dict(send_request_json_response): + def _get_deserialized_dict(request, deserialize_value_callable): + json_response = send_request_json_response(request) + return { + str(idx): deserialize_value_callable(json_response[key]) if json_response[key] else None + for idx, key in enumerate(json_response.keys()) + } + return _get_deserialized_dict + +@pytest.fixture +def get_serialized_dict(): + def _get_serialized_dict(dict, serialize_value_callable): + return { + k: serialize_value_callable(v) for k, v in dict.items() + } + return _get_serialized_dict + + +@pytest.fixture +def test_dict(): + test_product1 = {"integer": 1, "string": "2"} + test_product2 = {"integer": 3, "string": "4"} + test_product3 = {"integer": 5, "string": "6"} + return {"0":test_product1, "1":test_product2, "2":test_product3} + +# Primitive types +def test_boolean_tfft(send_request, send_request_json_response): + tfft = {"0":True, "1":False, "2":False, "3":True} + request = dictionary.build_get_boolean_tfft_request() + assert tfft == send_request_json_response(request) + + request = dictionary.build_put_boolean_tfft_request(json=tfft) + send_request(request) + +def test_get_boolean_invalid(send_request_json_response): + invalid_null_dict = {"0":True, "1":None, "2":False} + request = dictionary.build_get_boolean_invalid_null_request() + assert invalid_null_dict == send_request_json_response(request) + + request = dictionary.build_get_boolean_invalid_string_request() + assert {"0": True, "1": "boolean", "2": False} == send_request_json_response(request) + +def test_integer_valid(send_request, send_request_json_response): + int_valid = {"0":1, "1":-1, "2":3, "3":300} + request = dictionary.build_get_integer_valid_request() + assert int_valid == send_request_json_response(request) + + request = dictionary.build_put_integer_valid_request(json=int_valid) + send_request(request) + +def test_get_int_invalid(send_request_json_response): + int_null_dict = {"0":1, "1":None, "2":0} + request = dictionary.build_get_int_invalid_null_request() + assert int_null_dict == send_request_json_response(request) + + request = dictionary.build_get_int_invalid_string_request() + assert {"0": 1, "1": "integer", "2": 0} == send_request_json_response(request) + +def test_long_valid(send_request, send_request_json_response): + long_valid = {"0":1, "1":-1, "2":3, "3":300} + request = dictionary.build_get_long_valid_request() + assert long_valid == send_request_json_response(request) + + request = dictionary.build_put_long_valid_request(json=long_valid) + send_request(request) + +def test_get_long_invalid(send_request_json_response): + long_null_dict = {"0":1, "1":None, "2":0} + request = dictionary.build_get_long_invalid_null_request() + assert long_null_dict == send_request_json_response(request) + + request = dictionary.build_get_long_invalid_string_request() + assert {"0": 1, "1": "integer", "2": 0} == send_request_json_response(request) + +def test_float_valid(send_request, send_request_json_response): + float_valid = {"0":0, "1":-0.01, "2":-1.2e20} + request = dictionary.build_get_float_valid_request() + assert float_valid == send_request_json_response(request) + + request = dictionary.build_put_float_valid_request(json=float_valid) + send_request(request) + +def test_get_float_invalid(send_request_json_response): + float_null_dict = {"0":0.0, "1":None, "2":-1.2e20} + request = dictionary.build_get_float_invalid_null_request() + assert float_null_dict == send_request_json_response(request) + + request = dictionary.build_get_float_invalid_string_request() + assert {"0": 1, "1": "number", "2": 0} == send_request_json_response(request) + +def test_double_valid(send_request, send_request_json_response): + double_valid = {"0":0, "1":-0.01, "2":-1.2e20} + request = dictionary.build_get_double_valid_request() + assert double_valid == send_request_json_response(request) + + request = dictionary.build_put_double_valid_request(json=double_valid) + send_request(request) + +def test_get_double_invalid(send_request_json_response): + double_null_dict = {"0":0.0, "1":None, "2":-1.2e20} + request = dictionary.build_get_double_invalid_null_request() + assert double_null_dict == send_request_json_response(request) + + request = dictionary.build_get_double_invalid_string_request() + assert {"0": 1, "1": "number", "2": 0} == send_request_json_response(request) + +def test_string_valid(send_request, send_request_json_response): + string_valid = {"0":"foo1", "1":"foo2", "2":"foo3"} + request = dictionary.build_get_string_valid_request() + assert string_valid == send_request_json_response(request) + + request = dictionary.build_put_string_valid_request(json=string_valid) + send_request(request) + +def test_get_string_with_null_and_invalid(send_request_json_response): + string_null_dict = {"0":"foo", "1":None, "2":"foo2"} + string_invalid_dict = {"0":"foo", "1":123, "2":"foo2"} # in llc, we don't know we should serialize this whole thing as string, so serializes 123 as number + request = dictionary.build_get_string_with_null_request() + assert string_null_dict == send_request_json_response(request) + request = dictionary.build_get_string_with_invalid_request() + assert string_invalid_dict == send_request_json_response(request) + +def test_date_valid(send_request, get_serialized_dict, get_deserialized_dict, msrest_serializer, msrest_deserializer): + date1 = isodate.parse_date("2000-12-01T00:00:00Z") + date2 = isodate.parse_date("1980-01-02T00:00:00Z") + date3 = isodate.parse_date("1492-10-12T00:00:00Z") + valid_date_dict = {"0":date1, "1":date2, "2":date3} + + request = dictionary.build_get_date_valid_request() + assert get_deserialized_dict(request, msrest_deserializer.deserialize_date) == valid_date_dict + + request = dictionary.build_put_date_valid_request(json=get_serialized_dict(valid_date_dict, msrest_serializer.serialize_date)) + send_request(request) + +def test_get_date_invalid(send_request_json_response, msrest_deserializer, get_deserialized_dict): + date_null_dict = {"0":isodate.parse_date("2012-01-01"), + "1":None, + "2":isodate.parse_date("1776-07-04")} + request = dictionary.build_get_date_invalid_null_request() + assert date_null_dict == get_deserialized_dict(request, msrest_deserializer.deserialize_date) + + request = dictionary.build_get_date_invalid_chars_request() + assert {"0": "2011-03-22", "1": "date"} == send_request_json_response(request) + +def test_date_time_valid(send_request, get_deserialized_dict, get_serialized_dict, msrest_serializer, msrest_deserializer): + datetime1 = isodate.parse_datetime("2000-12-01T00:00:01Z") + datetime2 = isodate.parse_datetime("1980-01-02T00:11:35+01:00") + datetime3 = isodate.parse_datetime("1492-10-12T10:15:01-08:00") + valid_datetime_dict = {"0":datetime1, "1":datetime2, "2":datetime3} + + request = dictionary.build_get_date_time_valid_request() + assert valid_datetime_dict == get_deserialized_dict(request, msrest_deserializer.deserialize_iso) + + request = dictionary.build_put_date_time_valid_request( + json=get_serialized_dict(valid_datetime_dict, msrest_serializer.serialize_iso) + ) + send_request(request) + +def test_get_date_time_invalid(send_request_json_response, msrest_deserializer, get_deserialized_dict): + datetime_null_dict = {"0":isodate.parse_datetime("2000-12-01T00:00:01Z"), "1":None} + request = dictionary.build_get_date_time_invalid_null_request() + assert datetime_null_dict == get_deserialized_dict(request, msrest_deserializer.deserialize_iso) + + request = dictionary.build_get_date_time_invalid_chars_request() + assert {"0": "2000-12-01t00:00:01z", "1": "date-time"} == send_request_json_response(request) + +def test_date_time_rfc1123_valid(send_request, get_deserialized_dict, get_serialized_dict, msrest_serializer, msrest_deserializer): + rfc_datetime1 = isodate.parse_datetime("2000-12-01T00:00:01Z") + rfc_datetime2 = isodate.parse_datetime("1980-01-02T00:11:35Z") + rfc_datetime3 = isodate.parse_datetime("1492-10-12T10:15:01Z") + valid_rfc_dict = {"0":rfc_datetime1, "1":rfc_datetime2, "2":rfc_datetime3} + + request = dictionary.build_get_date_time_rfc1123_valid_request() + assert valid_rfc_dict == get_deserialized_dict(request, msrest_deserializer.deserialize_rfc) + + request = dictionary.build_put_date_time_rfc1123_valid_request(json=get_serialized_dict(valid_rfc_dict, msrest_serializer.serialize_rfc)) + send_request(request) + +def test_get_duration_valid(send_request, msrest_serializer, msrest_deserializer, get_deserialized_dict, get_serialized_dict): + duration1 = timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11) + duration2 = timedelta(days=5, hours=1) + valid_duration_dict = {"0":duration1, "1":duration2} + + request = dictionary.build_get_duration_valid_request() + assert valid_duration_dict == get_deserialized_dict(request, msrest_deserializer.deserialize_duration) + + request = dictionary.build_put_duration_valid_request(json=get_serialized_dict(valid_duration_dict, msrest_serializer.serialize_duration)) + send_request(request) + +def test_bytes_valid(send_request, msrest_serializer, msrest_deserializer, get_serialized_dict, get_deserialized_dict): + bytes1 = bytearray([0x0FF, 0x0FF, 0x0FF, 0x0FA]) + bytes2 = bytearray([0x01, 0x02, 0x03]) + bytes3 = bytearray([0x025, 0x029, 0x043]) + bytes4 = bytearray([0x0AB, 0x0AC, 0x0AD]) + + bytes_valid = {"0":bytes1, "1":bytes2, "2":bytes3} + request = dictionary.build_put_byte_valid_request(json=get_serialized_dict(bytes_valid, msrest_serializer.serialize_bytearray)) + send_request(request) + + request = dictionary.build_get_byte_valid_request() + assert bytes_valid == get_deserialized_dict(request, msrest_deserializer.deserialize_bytearray) + +def test_get_byte_invalid_null(msrest_deserializer, get_deserialized_dict): + bytes4 = bytearray([0x0AB, 0x0AC, 0x0AD]) + bytes_null = {"0":bytes4, "1":None} + request = dictionary.build_get_byte_invalid_null_request() + assert bytes_null == get_deserialized_dict(request, msrest_deserializer.deserialize_bytearray) +def test_get_base64_url(msrest_deserializer, get_deserialized_dict): + test_dict = {'0': 'a string that gets encoded with base64url'.encode(), + '1': 'test string'.encode(), + '2': 'Lorem ipsum'.encode()} + request = dictionary.build_get_base64_url_request() + assert test_dict == get_deserialized_dict(request, msrest_deserializer.deserialize_base64) + +# Basic dictionary parsing +def test_empty(send_request, send_request_json_response): + + request = dictionary.build_get_empty_request() + assert {} == send_request_json_response(request) + + request = dictionary.build_put_empty_request(json={}) + send_request(request) + +def test_get_null_and_invalid(send_request, send_request_json_response): + + request = dictionary.build_get_null_request() + assert send_request(request).text == '' + + request = dictionary.build_get_invalid_request() + with pytest.raises(json.decoder.JSONDecodeError): + send_request_json_response(request) + +def test_get_null_key_and_value(send_request, send_request_json_response): + # {null:"val1"} is not standard JSON format. C# might work and expects this test to pass, + # but we fail and we're happy with it. + request = dictionary.build_get_null_key_request() + with pytest.raises(json.decoder.JSONDecodeError): + send_request_json_response(request) + + request = dictionary.build_get_null_value_request() + assert {"key1":None} == send_request_json_response(request) + +def test_get_empty_string_key(send_request_json_response): + request = dictionary.build_get_empty_string_key_request() + assert {"":"val1"} == send_request_json_response(request) + +def test_complex_valid(send_request, send_request_json_response, test_dict): + + request = dictionary.build_put_complex_valid_request(json=test_dict) + send_request(request) + + request = dictionary.build_get_complex_valid_request() + assert test_dict == send_request_json_response(request) + +def test_array_valid(send_request, send_request_json_response): + list_dict = {"0":["1","2","3"], "1":["4","5","6"], "2":["7","8","9"]} + + request = dictionary.build_put_array_valid_request(json=list_dict) + send_request(request) + + request = dictionary.build_get_array_valid_request() + assert list_dict == send_request_json_response(request) + +def test_dictionary_valid(send_request, send_request_json_response): + dict_dict = {"0":{"1":"one","2":"two","3":"three"}, + "1":{"4":"four","5":"five","6":"six"}, + "2":{"7":"seven","8":"eight","9":"nine"}} + + request = dictionary.build_put_dictionary_valid_request(json=dict_dict) + send_request(request) + + request = dictionary.build_get_dictionary_valid_request() + assert dict_dict == send_request_json_response(request) + +def test_get_complex_null_and_empty(send_request, send_request_json_response): + + request = dictionary.build_get_complex_null_request() + assert send_request(request).text == '' + + request = dictionary.build_get_complex_empty_request() + assert {} == send_request_json_response(request) + +def test_get_complex_item_null_and_empty(send_request_json_response, test_dict): + test_dict_null = {"0":test_dict["0"], "1":None, "2":test_dict["2"]} + + request = dictionary.build_get_complex_item_null_request() + assert test_dict_null == send_request_json_response(request) + + test_dict_empty = {"0":test_dict["0"], "1": {}, "2":test_dict["2"]} + + request = dictionary.build_get_complex_item_empty_request() + assert send_request_json_response(request) == test_dict_empty + +def test_get_array_empty(send_request, send_request_json_response): + request = dictionary.build_get_array_null_request() + assert send_request(request).text == '' + + request = dictionary.build_get_array_empty_request() + assert {} == send_request_json_response(request) + +def test_get_array_item_null_and_empty(send_request_json_response): + list_dict = {"0":["1","2","3"], "1":None, "2":["7","8","9"]} + request = dictionary.build_get_array_item_null_request() + assert list_dict == send_request_json_response(request) + + # in convenience layer, we deserialize as {[str]}. Since we don't have that in llc, the value for "1" will be None, not an empty list + list_dict = {"0":["1","2","3"], "1":None, "2":["7","8","9"]} + assert list_dict == send_request_json_response(request) + +def test_get_dictionary_null_and_empty(send_request, send_request_json_response): + request = dictionary.build_get_dictionary_null_request() + assert send_request(request).text == '' + + request = dictionary.build_get_dictionary_empty_request() + assert {} == send_request_json_response(request) + +def test_get_dictionary_item_null_and_empty(send_request, send_request_json_response): + dict_dict = {"0":{"1":"one","2":"two","3":"three"}, + "1":None, + "2":{"7":"seven","8":"eight","9":"nine"}} + request = dictionary.build_get_dictionary_item_null_request() + assert dict_dict == send_request_json_response(request) + + dict_dict = {"0":{"1":"one","2":"two","3":"three"}, + "1":{}, + "2":{"7":"seven","8":"eight","9":"nine"}} + request = dictionary.build_get_dictionary_item_empty_request() + assert dict_dict == send_request_json_response(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_duration.py b/test/vanilla/low-level/AcceptanceTests/test_duration.py new file mode 100644 index 00000000000..067d26bb095 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_duration.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from datetime import timedelta +import isodate +from msrest.exceptions import DeserializationError + +from bodydurationlowlevel import AutoRestDurationTestService +from bodydurationlowlevel.rest import duration + +import pytest + +@pytest.fixture +def client(): + with AutoRestDurationTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_get_null_and_invalid(send_request, send_request_json_response): + request = duration.build_get_null_request() + assert send_request(request).text == '' + + request = duration.build_get_invalid_request() + with pytest.raises(isodate.ISO8601Error): + isodate.parse_duration(send_request_json_response(request)) + +def test_positive_duration(send_request, send_request_json_response): + request = duration.build_get_positive_duration_request() + assert isodate.Duration(4, 45005, 0, years=3, months=6) == isodate.parse_duration(send_request_json_response(request)) + + request = duration.build_put_positive_duration_request(json=isodate.duration_isoformat(timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11))) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_extensible_enums.py b/test/vanilla/low-level/AcceptanceTests/test_extensible_enums.py new file mode 100644 index 00000000000..cea19a5f4fa --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_extensible_enums.py @@ -0,0 +1,74 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from os.path import dirname, pardir, join, realpath + +from extensibleenumsswaggerlowlevel import PetStoreInc +from extensibleenumsswaggerlowlevel.rest import pet + +import pytest + +@pytest.fixture +def client(): + with PetStoreInc(base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_get_by_pet_id(send_request_json_response): + # Now enum return are always string (Autorest.Python 3.0) + + request = pet.build_get_by_pet_id_request(pet_id="tommy") + tommy = send_request_json_response(request) + assert tommy["DaysOfWeek"] == "Monday" + assert tommy["IntEnum"] == "1" + + request = pet.build_get_by_pet_id_request(pet_id="casper") + casper = send_request_json_response(request) + assert casper["DaysOfWeek"] == "Weekend" + assert casper["IntEnum"] == "2" + + request = pet.build_get_by_pet_id_request(pet_id="scooby") + scooby = send_request_json_response(request) + assert scooby["DaysOfWeek"] == "Thursday" + # https://github.com/Azure/autorest.csharp/blob/e5f871b7433e0f6ca6a17307fba4a2cfea4942b4/test/vanilla/AcceptanceTests.cs#L429 + # "allowedValues" of "x-ms-enum" is not supported in Python + assert scooby["IntEnum"] == "2.1" # Might be "2" if one day Python is supposed to support "allowedValues" + +def test_add_pet(send_request_json_response): + retriever = { + "name": "Retriever", + "IntEnum": "3", + "DaysOfWeek": "Friday" + } + request = pet.build_add_pet_request(json=retriever) + returned_pet = send_request_json_response(request) + assert returned_pet["DaysOfWeek"] == "Friday" + assert returned_pet["IntEnum"] == "3" + assert returned_pet["name"] == "Retriever" diff --git a/test/vanilla/low-level/AcceptanceTests/test_file.py b/test/vanilla/low-level/AcceptanceTests/test_file.py new file mode 100644 index 00000000000..1c97202b6ea --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_file.py @@ -0,0 +1,91 @@ +# -------------------------------------------------------------------------- +# +# 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 io +from os.path import dirname, pardir, join, realpath +from bodyfilelowlevel import AutoRestSwaggerBATFileService +from bodyfilelowlevel.rest import files + +import pytest + +cwd = dirname(realpath(__file__)) + + +@pytest.fixture +def client(connection_data_block_size): + with AutoRestSwaggerBATFileService( + base_url="http://localhost:3000", connection_data_block_size=connection_data_block_size) as client: + yield client + +@pytest.mark.parametrize('connection_data_block_size', [1000]) +def test_get_file(client): + file_length = 0 + with io.BytesIO() as file_handle: + request = files.build_get_file_request() + with client.send_request(request, stream=True) as response: + assert not response._internal_response._content_consumed + assert not response.is_closed + assert not response.is_stream_consumed + for data in response.iter_raw(): + # assert 0 < len(data) <= stream.block_size + file_length += len(data) + file_handle.write(data) + + assert file_length != 0 + assert response.is_closed + assert response.is_stream_consumed + assert response._internal_response._content_consumed + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + +@pytest.mark.parametrize('connection_data_block_size', [4096]) +def test_get_empty_file(client): + file_length = 0 + with io.BytesIO() as file_handle: + request = files.build_get_empty_file_request() + with client.send_request(request, stream=True) as response: + assert not response._internal_response._content_consumed + + for data in response.iter_raw(): + file_length += len(data) + file_handle.write(data) + + assert file_length == 0 + +@pytest.mark.parametrize('connection_data_block_size', [4096]) +def test_files_long_running(client): + file_length = 0 + request = files.build_get_file_large_request() + with client.send_request(request, stream=True) as response: + for data in response.iter_bytes(): + assert 0 < len(data) <= response._connection_data_block_size + file_length += len(data) + + assert file_length == 3000 * 1024 * 1024 diff --git a/test/vanilla/low-level/AcceptanceTests/test_form_data.py b/test/vanilla/low-level/AcceptanceTests/test_form_data.py new file mode 100644 index 00000000000..851bf7511b2 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_form_data.py @@ -0,0 +1,152 @@ +# -------------------------------------------------------------------------- +# +# 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 subprocess +import sys +import io +import os +import tempfile +from os.path import dirname, pardir, join, realpath + +cwd = dirname(realpath(__file__)) +log_level = int(os.environ.get('PythonLogLevel', 30)) + +tests = realpath(join(cwd, pardir, "Expected", "AcceptanceTests")) +sys.path.append(join(tests, "BodyFormData")) + + +from bodyformdatalowlevel import AutoRestSwaggerBATFormDataService +from bodyformdatalowlevel.rest import formdata +import pytest + +@pytest.fixture +def dummy_file(): + with tempfile.NamedTemporaryFile(mode='w', delete=False) as dummy: + dummy.write("Test file") + # Get outside of the "with", so file can be re-opened on Windows + yield dummy.name + os.remove(dummy.name) + +@pytest.fixture +def client(): + with AutoRestSwaggerBATFormDataService( + base_url="http://localhost:3000", + connection_data_block_size = 2, + retry_total = 50, # Be agressive on this test, sometimes testserver DDOS :-p + retry_backoff_factor = 1.6 + ) as client: + yield client + +def test_file_upload_stream(client): + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + result = io.BytesIO() + with io.BytesIO(test_bytes) as stream_data: + files = { + "fileContent": stream_data, + "fileName": "UploadFile.txt", + } + request = formdata.build_upload_file_request(files=files) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == test_string + +def test_file_upload_file_stream(client, dummy_file): + + name = os.path.basename(dummy_file) + result = io.BytesIO() + with open(dummy_file, 'rb') as upload_data: + files = { + "fileContent": upload_data, + "fileName": name, + } + request = formdata.build_upload_file_request(files=files) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == "Test file" + +def test_file_body_upload(client, dummy_file): + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + + result = io.BytesIO() + with io.BytesIO(test_bytes) as stream_data: + request = formdata.build_upload_file_via_body_request(content=stream_data, headers={"Content-Type": "application/octet-stream"}) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == test_string + + result = io.BytesIO() + with open(dummy_file, 'rb') as upload_data: + request = formdata.build_upload_file_via_body_request(content=upload_data, headers={"Content-Type": "application/octet-stream"}) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == "Test file" + +def test_file_body_upload_generator(client, dummy_file): + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + + def stream_upload(data, length, block_size): + progress = 0 + while True: + block = data.read(block_size) + progress += len(block) + print("Progress... {}%".format(int(progress*100/length))) + if not block: + break + yield block + + result = io.BytesIO() + with io.BytesIO(test_bytes) as stream_data: + streamed_upload = stream_upload(stream_data, len(test_string), 2) + request = formdata.build_upload_file_via_body_request(content=streamed_upload, headers={"Content-Type": "application/octet-stream"}) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == test_string + + result = io.BytesIO() + with open(dummy_file, 'rb') as upload_data: + streamed_upload = stream_upload(upload_data, len("Test file"), 2) + request = formdata.build_upload_file_via_body_request(content=streamed_upload, headers={"Content-Type": "application/octet-stream"}) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + result.write(data) + assert result.getvalue().decode() == "Test file" \ No newline at end of file diff --git a/test/vanilla/low-level/AcceptanceTests/test_header.py b/test/vanilla/low-level/AcceptanceTests/test_header.py new file mode 100644 index 00000000000..8e7d4d0a7c5 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_header.py @@ -0,0 +1,231 @@ +# -------------------------------------------------------------------------- +# +# 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 isodate +from datetime import datetime, timedelta +from base64 import b64decode + +from headerlowlevel import AutoRestSwaggerBATHeaderService +from headerlowlevel.rest import header + +import pytest + +@pytest.fixture +def client(): + with AutoRestSwaggerBATHeaderService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_value_response_header(client, base_send_request): + def _send_request(request): + return base_send_request(client, request).headers['value'] + return _send_request + +# NOTE: in llc, we don't know to deserialize response headers as int / datetime etc. So you'll see they'll just be strings, not ints etc +def test_integer(send_request, send_request_value_response_header): + + request = header.build_param_integer_request(scenario="positive", value=1) + send_request(request) + request = header.build_param_integer_request(scenario="negative", value=-2) + send_request(request) + + request = header.build_response_integer_request(scenario="positive") + assert send_request_value_response_header(request) == "1" + + request = header.build_response_integer_request(scenario="negative") + assert send_request_value_response_header(request) == "-2" + +def test_long(send_request, send_request_value_response_header): + request = header.build_param_long_request(scenario="positive", value=105) + send_request(request) + request = header.build_param_long_request(scenario="negative", value=-2) + send_request(request) + + request = header.build_response_long_request(scenario="positive") + assert send_request_value_response_header(request) == "105" + + request = header.build_response_long_request(scenario="negative") + assert send_request_value_response_header(request) == "-2" + +def test_float(send_request, send_request_value_response_header): + request = header.build_param_float_request(scenario="positive", value=0.07) + send_request(request) + + request = header.build_param_float_request(scenario="negative", value=-3.0) + send_request(request) + + request = header.build_response_float_request(scenario="positive") + assert abs(0.07 - float(send_request_value_response_header(request))) < 0.00001 + + request = header.build_response_float_request(scenario="negative") + assert abs(-3.0 - float(send_request_value_response_header(request))) < 0.00001 + +def test_double(send_request, send_request_value_response_header): + request = header.build_param_double_request(scenario="positive", value=7e120) + send_request(request) + + request = header.build_param_double_request(scenario="negative", value=-3.0) + send_request(request) + + request = header.build_response_double_request(scenario="positive") + assert send_request_value_response_header(request) == "7e+120" + + request = header.build_response_double_request(scenario="negative") + assert send_request_value_response_header(request) == "-3" + +def test_bool(send_request, send_request_value_response_header): + request = header.build_param_bool_request(scenario="true", value=True) + send_request(request) + request = header.build_param_bool_request(scenario="false", value=False) + send_request(request) + + request = header.build_response_bool_request(scenario="true") + assert send_request_value_response_header(request) == 'true' + + request = header.build_response_bool_request(scenario="false") + assert send_request_value_response_header(request) == 'false' + +def test_string(send_request, send_request_value_response_header): + request = header.build_param_string_request(scenario="valid", value="The quick brown fox jumps over the lazy dog") + send_request(request) + + request = header.build_param_string_request(scenario="null", value=None) + send_request(request) + + request = header.build_param_string_request(scenario="empty", value="") + send_request(request) + + request = header.build_response_string_request(scenario="valid") + assert send_request_value_response_header(request) == "The quick brown fox jumps over the lazy dog" + + request = header.build_response_string_request(scenario="null") + assert send_request_value_response_header(request) == "null" # TODO This should be None + + request = header.build_response_string_request(scenario="empty") + assert send_request_value_response_header(request) == "" + +def test_enum(send_request, send_request_value_response_header): + request = header.build_param_enum_request(scenario="valid", value="GREY") + send_request(request) + + request = header.build_param_enum_request(scenario="valid", value="GREY") + send_request(request) + + request = header.build_param_enum_request(scenario="null", value=None) + send_request(request) + + + request = header.build_response_enum_request(scenario="valid") + assert send_request_value_response_header(request) == "GREY" + + # We receive an empty string. + # Starting msrest 0.4.22, we consider that if a string is not in the enum, this not + # a Deserialization issue and we return the string. + # Here we now return empty string without failin **on purpose** + # with pytest.raises(DeserializationError): + request = header.build_response_enum_request(scenario="null") + assert send_request_value_response_header(request) == "" + +def test_date(send_request, send_request_value_response_header): + request = header.build_param_date_request(scenario="valid", value=isodate.parse_date("2010-01-01")) + send_request(request) + request = header.build_param_date_request(scenario="min", value=datetime.min) + send_request(request) + + request = header.build_response_date_request(scenario="valid") + assert send_request_value_response_header(request) == str(isodate.parse_date("2010-01-01")) + + request = header.build_response_date_request(scenario="min") + assert send_request_value_response_header(request) == str(isodate.parse_date("0001-01-01")) + +def test_datetime(send_request, send_request_value_response_header): + request = header.build_param_datetime_request(scenario="valid", value=isodate.parse_datetime("2010-01-01T12:34:56Z")) + send_request(request) + request = header.build_param_datetime_request(scenario="min", value=datetime.min) + send_request(request) + + request = header.build_response_datetime_request(scenario="valid") + assert send_request_value_response_header(request) == '2010-01-01T12:34:56Z' + + request = header.build_response_datetime_request(scenario="min") + assert send_request_value_response_header(request) == '0001-01-01T00:00:00Z' + +def test_datetime_rfc(send_request, send_request_value_response_header): + request = header.build_param_datetime_rfc1123_request(scenario="valid", value=isodate.parse_datetime("2010-01-01T12:34:56Z")) + send_request(request) + + request = header.build_param_datetime_rfc1123_request(scenario="min", value=datetime.min) + send_request(request) + + request = header.build_response_datetime_rfc1123_request(scenario="valid") + assert send_request_value_response_header(request) == "Fri, 01 Jan 2010 12:34:56 GMT" + + # we are not using the min date of year 1 because of the latest msrest update + # with msrest update, minimal year we can parse is 100, instead of 1 + request = header.build_response_datetime_rfc1123_request(scenario="min") + assert send_request_value_response_header(request) == "Mon, 01 Jan 0001 00:00:00 GMT" + +def test_duration(send_request, send_request_value_response_header): + request = header.build_param_duration_request(scenario="valid", value=timedelta(days=123, hours=22, minutes=14, seconds=12, milliseconds=11)) + send_request(request) + + request = header.build_response_duration_request(scenario="valid") + assert send_request_value_response_header(request) == 'P123DT22H14M12.011S' # raw str of the above timedelta + +def test_byte(send_request, send_request_value_response_header): + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + request = header.build_param_byte_request(scenario="valid", value=u_bytes) + send_request(request) + + request = header.build_response_byte_request(scenario="valid") + assert bytearray(b64decode(send_request_value_response_header(request))) == u_bytes + +def test_response_existing_key(send_request): + + request = header.build_param_existing_key_request(user_agent_parameter="overwrite") + send_request(request) + request = header.build_response_existing_key_request() + assert send_request(request).headers['User-Agent'] == "overwrite" + +def test_response_protected_key(send_request): + # This test is only valid for C#, which content-type can't be override this way + #client.header.param_protected_key("text/html") + + # This test has different result compare to C#, which content-type is saved in another place. + request = header.build_response_protected_key_request() + assert send_request(request).headers['Content-Type'] == "text/html; charset=utf-8" + +@pytest.mark.xfail(reason="https://github.com/Azure/azure-sdk-for-python/issues/17757") +def test_custom_request_id(send_request): + custom_headers = {"x-ms-client-request-id": "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"} + request = header.build_custom_request_id_request(headers=custom_headers) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_http.py b/test/vanilla/low-level/AcceptanceTests/test_http.py new file mode 100644 index 00000000000..0eed587778f --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_http.py @@ -0,0 +1,493 @@ +# -------------------------------------------------------------------------- +# +# 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 requests + +from azure.core.exceptions import HttpResponseError +from azure.core.pipeline.policies import ContentDecodePolicy, RetryPolicy, HeadersPolicy, RedirectPolicy + +from httpinfrastructurelowlevel import AutoRestHttpInfrastructureTestService +from httpinfrastructurelowlevel.rest import ( + http_client_failure, + http_failure, + http_redirects, + http_retry, + http_server_failure, + http_success, + multiple_responses, +) + +import pytest + + +@pytest.fixture() +def client(cookie_policy): + """Create a AutoRestHttpInfrastructureTestService client with test server credentials.""" + policies = [ + HeadersPolicy(), + ContentDecodePolicy(), + RedirectPolicy(), + RetryPolicy(), + cookie_policy + ] + with AutoRestHttpInfrastructureTestService(base_url="http://localhost:3000", policies=policies) 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def send_request_assert_status(client, base_send_request): + def _send_request(request, status_code): + response = base_send_request(client, request) + assert response.status_code == status_code + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_message(client, base_send_request): + def _send_request(request, message): + with pytest.raises(HttpResponseError) as ex: + base_send_request(client, request) + assert ex.value.message == message + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_status(client, base_send_request): + def _send_request(request, status_code): + with pytest.raises(HttpResponseError) as ex: + base_send_request(client, request) + assert ex.value.status_code == status_code + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_status_and_message(client, base_send_request): + def _send_request(request, status_code, message): + with pytest.raises(HttpResponseError) as ex: + base_send_request(client, request) + assert ex.value.status_code == status_code + assert ex.value.message == message + assert message in str(ex.value) + return _send_request + +@pytest.fixture +def send_request_assert_raises_with_status_and_response_contains_message(client, base_send_request): + def _send_request(request, status_code, message): + with pytest.raises(HttpResponseError) as ex: + base_send_request(client, request) + assert ex.value.status_code == status_code + assert ex.value.response.json()['message'] == message + return _send_request + +def test_get200_model204(send_request, send_request_assert_status, send_request_assert_raises_with_status_and_response_contains_message): + # a lot of these tests raised in high level bc we made some 200 status codes errors in high level + # can't do this in low level, so these don't actually raise + request = multiple_responses.build_get200_model204_no_model_default_error200_valid_request() + send_request_assert_status(request, 200) + + request = multiple_responses.build_get200_model204_no_model_default_error201_invalid_request() + send_request_assert_status(request, 201) + + request = multiple_responses.build_get200_model204_no_model_default_error202_none_request() + send_request_assert_status(request, 202) + + request = multiple_responses.build_get200_model204_no_model_default_error204_valid_request() + + assert send_request(request).text == '' + + request = multiple_responses.build_get200_model204_no_model_default_error400_valid_request() + send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + +def test_get200_model201(send_request_json_response, send_request_assert_status, send_request_assert_raises_with_status_and_response_contains_message): + request = multiple_responses.build_get200_model201_model_default_error200_valid_request() + send_request_assert_status(request, 200) + + request = multiple_responses.build_get200_model201_model_default_error201_valid_request() + b_model = send_request_json_response(request) + assert b_model is not None + assert b_model['statusCode'] == "201" + assert b_model['textStatusCode'] == "Created" + + request = multiple_responses.build_get200_model201_model_default_error400_valid_request() + send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + +def test_get200_model_a201_model_c404(send_request_json_response, send_request_assert_raises_with_status_and_response_contains_message, send_request_assert_raises_with_status): + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error200_valid_request() + a_model = send_request_json_response(request) + assert a_model['statusCode']== "200" + + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error201_valid_request() + + c_model = send_request_json_response(request) + assert c_model['httpCode'] == "201" + + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error404_valid_request() + send_request_assert_raises_with_status(request, 404) # in high level, this doesn't raise and returns a model since we've made 404 a valid status code. can't do that in llc + + request = multiple_responses.build_get200_model_a201_model_c404_model_d_default_error400_valid_request() + send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + +def test_get202_none204(send_request, send_request_assert_raises_with_status, send_request_assert_raises_with_status_and_response_contains_message): + request = multiple_responses.build_get202_none204_none_default_error202_none_request() + send_request(request) + + request = multiple_responses.build_get202_none204_none_default_error204_none_request() + send_request(request) + + request = multiple_responses.build_get202_none204_none_default_error400_valid_request() + send_request_assert_raises_with_status_and_response_contains_message(request, 400, "client error") + + request = multiple_responses.build_get202_none204_none_default_none202_invalid_request() + send_request(request) + + request = multiple_responses.build_get202_none204_none_default_none204_none_request() + send_request(request) + + request = multiple_responses.build_get202_none204_none_default_none400_none_request() + send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get202_none204_none_default_none400_invalid_request() + send_request_assert_raises_with_status(request, 400) + +def test_get_default_model_a200(send_request, send_request_assert_status): + request = multiple_responses.build_get_default_model_a200_valid_request() + send_request_assert_status(request, 200) + + request = multiple_responses.build_get_default_model_a200_none_request() + assert send_request(request).text == '' + + request = multiple_responses.build_get_default_model_a200_valid_request() + send_request(request) + request = multiple_responses.build_get_default_model_a200_none_request() + send_request(request) + +def test_get_default_none200(send_request): + request = multiple_responses.build_get_default_none200_invalid_request() + send_request(request) + + requst = multiple_responses.build_get_default_none200_none_request() + send_request(request) + +def test_get_default_none400(send_request_assert_raises_with_status): + request = multiple_responses.build_get_default_none400_invalid_request() + send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get_default_none400_none_request() + send_request_assert_raises_with_status(request, 400) + +def test_get200_model_a200(send_request, send_request_assert_status): + request = multiple_responses.build_get200_model_a200_none_request() + assert send_request(request).text == '' + + request = multiple_responses.build_get200_model_a200_valid_request() + send_request_assert_status(request, 200) + + request = multiple_responses.build_get200_model_a200_invalid_request() + send_request_assert_status(request, 200) # in high level it's supposed to deserialize as exception model "MyException", can't do that in LLC + +def test_get200_model_a400(send_request_assert_raises_with_status): + request = multiple_responses.build_get200_model_a400_none_request() + send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get200_model_a400_valid_request() + send_request_assert_raises_with_status(request, 400) + + request = multiple_responses.build_get200_model_a400_invalid_request() + send_request_assert_raises_with_status(request, 400) + +def test_get200_model_a202(send_request_assert_status): + request = multiple_responses.build_get200_model_a202_valid_request() + send_request_assert_status(request, 202) # raises in HLC bc we've marked all status codes that are not "200" as errors + +def test_server_error_status_codes_501(send_request_assert_raises_with_status): + request = http_server_failure.build_head501_request() + send_request_assert_raises_with_status(request, requests.codes.not_implemented) + + request = http_server_failure.build_get501_request() + send_request_assert_raises_with_status(request, requests.codes.not_implemented) + +def test_server_error_status_codes_505(send_request_assert_raises_with_status): + request = http_server_failure.build_post505_request() + send_request_assert_raises_with_status(request, requests.codes.http_version_not_supported) + + request = http_server_failure.build_delete505_request() + send_request_assert_raises_with_status(request, requests.codes.http_version_not_supported) + +def test_retry_status_codes_408(send_request): + request = http_retry.build_head408_request() + send_request(request) + +def test_retry_status_codes_502(send_request): + request = http_retry.build_get502_request() + send_request(request) + + # TODO, 4042586: Support options operations in swagger modeler + #client.http_retry.options429() + +def test_retry_status_codes_500(send_request): + request = http_retry.build_put500_request() + send_request(request) + request = http_retry.build_patch500_request() + send_request(request) + +def test_retry_status_codes_503(send_request): + request = http_retry.build_post503_request() + send_request(request) + + request = http_retry.build_delete503_request() + send_request(request) + +def test_retry_status_codes_504(send_request): + request = http_retry.build_put504_request() + send_request(request) + + request = http_retry.build_patch504_request() + send_request(request) + +def test_error_status_codes_400(send_request_assert_raises_with_status): + request = http_client_failure.build_head400_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_get400_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.bad_request, + # client.http_client_failure.options400) + + request = http_client_failure.build_put400_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_patch400_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_post400_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) + + request = http_client_failure.build_delete400_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) + +def test_error_status_codes_401(send_request_assert_raises_with_status): + request = http_client_failure.build_head401_request() + send_request_assert_raises_with_status(request, requests.codes.unauthorized) + +def test_error_status_codes_402(send_request_assert_raises_with_status): + request = http_client_failure.build_get402_request() + send_request_assert_raises_with_status(request, requests.codes.payment_required) + +def test_error_status_codes_403(send_request_assert_raises_with_status): + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.forbidden, + # client.http_client_failure.options403) + + request = http_client_failure.build_get403_request() + send_request_assert_raises_with_status(request, requests.codes.forbidden) + +def test_error_status_codes_404(send_request_assert_raises_with_status): + request = http_client_failure.build_put404_request() + send_request_assert_raises_with_status(request, requests.codes.not_found) + +def test_error_status_codes_405(send_request_assert_raises_with_status): + request = http_client_failure.build_patch405_request() + send_request_assert_raises_with_status(request, requests.codes.method_not_allowed) + +def test_error_status_codes_406(send_request_assert_raises_with_status): + request = http_client_failure.build_post406_request() + send_request_assert_raises_with_status(request, requests.codes.not_acceptable) + +def test_error_status_codes_407(send_request_assert_raises_with_status): + request = http_client_failure.build_delete407_request() + send_request_assert_raises_with_status(request, requests.codes.proxy_authentication_required) + +def test_error_status_codes_409(send_request_assert_raises_with_status): + request = http_client_failure.build_put409_request() + send_request_assert_raises_with_status(request, requests.codes.conflict) + +def test_error_status_codes_410(send_request_assert_raises_with_status): + request = http_client_failure.build_head410_request() + send_request_assert_raises_with_status(request, requests.codes.gone) + +def test_error_status_codes_411(send_request_assert_raises_with_status): + + request = http_client_failure.build_get411_request() + send_request_assert_raises_with_status(request, requests.codes.length_required) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_raises_with_status(requests.codes.precondition_failed, + # client.http_client_failure.options412) + + request = http_client_failure.build_get412_request() + send_request_assert_raises_with_status(request, requests.codes.precondition_failed) + + request = http_client_failure.build_put413_request() + send_request_assert_raises_with_status(request, requests.codes.request_entity_too_large) + + request = http_client_failure.build_patch414_request() + send_request_assert_raises_with_status(request, requests.codes.request_uri_too_large) + + request = http_client_failure.build_post415_request() + send_request_assert_raises_with_status(request, requests.codes.unsupported_media) + + request = http_client_failure.build_get416_request() + send_request_assert_raises_with_status(request, requests.codes.requested_range_not_satisfiable) + + request = http_client_failure.build_delete417_request() + send_request_assert_raises_with_status(request, requests.codes.expectation_failed) + + request = http_client_failure.build_head429_request() + send_request_assert_raises_with_status(request, 429) + +def test_redirect_to_300(send_request_assert_status): + request = http_redirects.build_get300_request() + send_request_assert_status(request, 200) + +def test_redirect_to_301(send_request_assert_status): + request = http_redirects.build_head301_request() + send_request_assert_status(request, 200) + + + request = http_redirects.build_get301_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_put301_request() + send_request_assert_status(request, requests.codes.moved_permanently) + +def test_redirect_to_302(send_request_assert_status): + request = http_redirects.build_head302_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_get302_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_patch302_request() + send_request_assert_status(request, requests.codes.found) + +def test_redicret_to_303(send_request_assert_status): + request = http_redirects.build_post303_request() + send_request_assert_status(request, 200) + +def test_redirect_to_307(send_request_assert_status): + request = http_redirects.build_head307_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_get307_request() + send_request_assert_status(request, 200) + + # TODO, 4042586: Support options operations in swagger modeler + #self.assert_status(200, client.http_redirects.options307) + request = http_redirects.build_put307_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_post307_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_patch307_request() + send_request_assert_status(request, 200) + + request = http_redirects.build_delete307_request() + send_request_assert_status(request, 200) + +def test_bad_request_status_assert(send_request_assert_raises_with_message): + request = http_failure.build_get_empty_error_request() + send_request_assert_raises_with_message(request, "Operation returned an invalid status 'Bad Request'") + +def test_no_error_model_status_assert(send_request_assert_raises_with_status_and_response_contains_message): + request = http_failure.build_get_no_model_error_request() + send_request_assert_raises_with_status_and_response_contains_message(request, requests.codes.bad_request, "NoErrorModel") + +def test_success_status_codes_200(send_request): + request = http_success.build_head200_request() + send_request(request) + request = http_success.build_get200_request() + assert send_request(request).text + + request = http_success.build_put200_request() + send_request(request) + + request = http_success.build_post200_request() + send_request(request) + + request = http_success.build_patch200_request() + send_request(request) + + request = http_success.build_delete200_request() + send_request(request) + + # TODO, 4042586: Support options operations in swagger modeler + #assert client.http_success.options200() + +def test_success_status_codes_201(send_request): + request = http_success.build_put201_request() + send_request(request) + + request = http_success.build_post201_request() + send_request(request) + +def test_success_status_codes_202(send_request): + request = http_success.build_put202_request() + send_request(request) + + request = http_success.build_post202_request() + send_request(request) + + request = http_success.build_patch202_request() + send_request(request) + + request = http_success.build_delete202_request() + send_request(request) + +def test_success_status_codes_204(send_request): + request = http_success.build_head204_request() + send_request(request) + + request = http_success.build_put204_request() + send_request(request) + + request = http_success.build_post204_request() + send_request(request) + + request = http_success.build_delete204_request() + send_request(request) + + request = http_success.build_patch204_request() + send_request(request) + +def test_success_status_codes_404(send_request_assert_raises_with_status): + # raises bc in high level we're able to mark 404 as a valid status code, but can't do that in llc + request = http_success.build_head404_request() + send_request_assert_raises_with_status(request, 404) + +def test_empty_no_content(send_request_assert_raises_with_status): + request = http_failure.build_get_no_model_empty_request() + send_request_assert_raises_with_status(request, requests.codes.bad_request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_integer.py b/test/vanilla/low-level/AcceptanceTests/test_integer.py new file mode 100644 index 00000000000..f83e23eb774 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_integer.py @@ -0,0 +1,102 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from datetime import datetime +from bodyintegerlowlevel import AutoRestIntegerTestService +from bodyintegerlowlevel.rest import int as int_rest + +import pytest +import calendar +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +@pytest.fixture +def client(): + with AutoRestIntegerTestService(base_url="http://localhost:3000") 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_max_min_32_bit(send_request): + request = int_rest.build_put_max32_request(json=2147483647) # sys.maxint + send_request(request) + + request = int_rest.build_put_min32_request(json=-2147483648) + send_request(request) + +def test_max_min_64_bit(send_request): + request = int_rest.build_put_max64_request(json=9223372036854776000) # sys.maxsize + send_request(request) + + request = int_rest.build_put_min64_request(json=-9223372036854776000) + send_request(request) + +def test_get_null_and_invalid(send_request): + request = int_rest.build_get_null_request() + send_request(request) + + request = int_rest.build_get_invalid_request() + assert send_request(request).text == '123jkl' + +def test_get_overflow(send_request): + # Testserver excepts these to fail, but they won't in Python and it's ok. + + request = int_rest.build_get_overflow_int32_request() + send_request(request) + + request = int_rest.build_get_overflow_int64_request() + send_request(request) + +def test_get_underflow(send_request): + request = int_rest.build_get_underflow_int32_request() + send_request(request) + + request = int_rest.build_get_underflow_int64_request() + send_request(request) + +def test_unix_time_date(send_request): + unix_date = datetime(year=2016, month=4, day=13) + + input = calendar.timegm(unix_date.utctimetuple()) + request = int_rest.build_put_unix_time_date_request(json=int(input)) + send_request(request) + + request = int_rest.build_get_unix_time_request() + assert unix_date.utctimetuple() == datetime.fromtimestamp(send_request(request).json(), TZ_UTC).utctimetuple() + +def test_get_null_and_invalid_unix_time(send_request): + request = int_rest.build_get_null_unix_time_request() + assert send_request(request).text == '' + + request = int_rest.build_get_invalid_unix_time_request() + assert send_request(request).text == '123jkl' diff --git a/test/vanilla/low-level/AcceptanceTests/test_media_types.py b/test/vanilla/low-level/AcceptanceTests/test_media_types.py new file mode 100644 index 00000000000..84cc7c90c75 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_media_types.py @@ -0,0 +1,58 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from mediatypeslowlevel import MediaTypesClient +from mediatypeslowlevel.rest import build_analyze_body_request, build_content_type_with_encoding_request + +import pytest + +@pytest.fixture +def client(): + with MediaTypesClient() 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_pdf(send_request_json_response): + request = build_analyze_body_request(content=b"PDF", content_type="application/pdf") + assert send_request_json_response(request) == "Nice job with PDF" + +def test_json(send_request_json_response): + request = build_analyze_body_request(json={"source":"foo"}) + assert send_request_json_response(request) == "Nice job with JSON" + +def test_content_type_with_encoding(send_request_json_response): + request = build_content_type_with_encoding_request(content="hello", content_type='text/plain; encoding=UTF-8') + assert send_request_json_response(request) == "Nice job sending content type with encoding" diff --git a/test/vanilla/low-level/AcceptanceTests/test_model_flattening.py b/test/vanilla/low-level/AcceptanceTests/test_model_flattening.py new file mode 100644 index 00000000000..3fe02df1da1 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_model_flattening.py @@ -0,0 +1,293 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +from modelflatteninglowlevel import AutoRestResourceFlatteningTestService, rest + +import pytest + +@pytest.fixture() +def client(): + with AutoRestResourceFlatteningTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + + +def test_flattening_array(send_request, send_request_json_response): + #Array + request = rest.build_get_array_request() + result = send_request_json_response(request) + assert 3 == len(result) + # Resource 1 + assert "1" == result[0]['id'] + assert "OK" == result[0]['properties']['provisioningStateValues'] + assert "Product1" == result[0]['properties']['p.name'] + assert "Flat" == result[0]['properties']['type'] + assert "Building 44" == result[0]['location'] + assert "Resource1" == result[0]['name'] + assert "Succeeded" == result[0]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result[0]['type'] + assert "value1" == result[0]['tags']["tag1"] + assert "value3" == result[0]['tags']["tag2"] + # Resource 2 + assert "2" == result[1]['id'] + assert "Resource2" == result[1]['name'] + assert "Building 44" == result[1]['location'] + # Resource 3 + assert "3" == result[2]['id'] + assert "Resource3" == result[2]['name'] + + json = [ + { + 'tags': { + 'tag1': 'value1', + 'tag2': 'value3' + }, + 'location': 'West US' + }, + { + 'location': 'Building 44' + } + ] + request = rest.build_put_array_request(json=json) + send_request(request) + +def test_flattening_dictionary(send_request, send_request_json_response): + + request = rest.build_get_dictionary_request() + result = send_request_json_response(request) + assert 3 == len(result) + # Resource 1 + assert "1" == result["Product1"]['id'] + assert "OK" == result["Product1"]['properties']['provisioningStateValues'] + assert "Product1" == result["Product1"]['properties']['p.name'] + assert "Flat" == result["Product1"]['properties']['type'] + assert "Building 44" == result["Product1"]['location'] + assert "Resource1" == result["Product1"]['name'] + assert "Succeeded" == result["Product1"]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result["Product1"]['type'] + assert "value1" == result["Product1"]['tags']["tag1"] + assert "value3" == result["Product1"]['tags']["tag2"] + # Resource 2 + assert "2" == result["Product2"]['id'] + assert "Resource2" == result["Product2"]['name'] + assert "Building 44" == result["Product2"]['location'] + # Resource 3 + assert "3" == result["Product3"]['id'] + assert "Resource3" == result["Product3"]['name'] + + json = { + "Resource1": { + "tags": { + "tag1": "value1", + "tag2": "value3" + }, + "location": "West US", + "properties": { + "p.name": "Product1", + "type": "Flat" + } + }, + "Resource2": { + "location": "Building 44", + "properties": { + "p.name": "Product2", + "type": "Flat" + } + } + } + + request = rest.build_put_dictionary_request(json=json) + send_request(request) + +def test_flattening_complex_object(send_request, send_request_json_response): + + #ResourceCollection + request = rest.build_get_resource_collection_request() + result = send_request_json_response(request) + + #dictionaryofresources + assert 3 == len(result['dictionaryofresources']) + # Resource 1 + assert "1" == result['dictionaryofresources']["Product1"]['id'] + assert "OK" == result['dictionaryofresources']["Product1"]['properties']['provisioningStateValues'] + assert "Product1" == result['dictionaryofresources']["Product1"]['properties']['p.name'] + assert "Flat" == result['dictionaryofresources']["Product1"]['properties']['type'] + assert "Building 44" == result['dictionaryofresources']["Product1"]['location'] + assert "Resource1" == result['dictionaryofresources']["Product1"]['name'] + assert "Succeeded" == result['dictionaryofresources']["Product1"]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result['dictionaryofresources']["Product1"]['type'] + assert "value1" == result['dictionaryofresources']["Product1"]['tags']["tag1"] + assert "value3" == result['dictionaryofresources']["Product1"]['tags']["tag2"] + # Resource 2 + assert "2" == result['dictionaryofresources']["Product2"]['id'] + assert "Resource2" == result['dictionaryofresources']["Product2"]['name'] + assert "Building 44" == result['dictionaryofresources']["Product2"]['location'] + # Resource 3 + assert "3" == result['dictionaryofresources']["Product3"]['id'] + assert "Resource3" == result['dictionaryofresources']["Product3"]['name'] + + #arrayofresources + assert 3 == len(result['arrayofresources']) + # Resource 1 + assert "4" == result['arrayofresources'][0]['id'] + assert "OK" == result['arrayofresources'][0]['properties']['provisioningStateValues'] + assert "Product4" == result['arrayofresources'][0]['properties']['p.name'] + assert "Flat" == result['arrayofresources'][0]['properties']['type'] + assert "Building 44" == result['arrayofresources'][0]['location'] + assert "Resource4" == result['arrayofresources'][0]['name'] + assert "Succeeded" == result['arrayofresources'][0]['properties']['provisioningState'] + assert "Microsoft.Web/sites" == result['arrayofresources'][0]['type'] + assert "value1" == result['arrayofresources'][0]['tags']["tag1"] + assert "value3" == result['arrayofresources'][0]['tags']["tag2"] + # Resource 2 + assert "5" == result['arrayofresources'][1]['id'] + assert "Resource5" == result['arrayofresources'][1]['name'] + assert "Building 44" == result['arrayofresources'][1]['location'] + # Resource 3 + assert "6" == result['arrayofresources'][2]['id'] + assert "Resource6" == result['arrayofresources'][2]['name'] + + #productresource + assert "7" == result['productresource']['id'] + assert "Resource7" == result['productresource']['name'] + + json = { + "productresource": { + "location": "India", + "properties": { + "p.name": "Azure", + "type": "Flat" + } + }, + "arrayofresources": [ + { + "tags": { + "tag1": "value1", + "tag2": "value3" + }, + "location": "West US", + "properties": { + "p.name": "Product1", + "type": "Flat" + } + }, + { + "location": "East US", + "properties": { + "p.name": "Product2", + "type": "Flat" + } + } + ], + "dictionaryofresources": { + "Resource1": { + "tags": { + "tag1": "value1", + "tag2": "value3" + }, + "location": "West US", + "properties": { + "p.name": "Product1", + "type": "Flat" + } + }, + "Resource2": { + "location": "Building 44", + "properties": { + "p.name": "Product2", + "type": "Flat" + } + } + } + } + request = rest.build_put_resource_collection_request(json=json) + send_request(request) + +def test_model_flattening_simple(send_request_json_response): + json = { + "base_product_id": "123", + "base_product_description": "product description", + "details": { + "max_product_display_name": "max name", + "max_product_capacity": "Large", + "max_product_image": { + "generic_value": "https://generic", + "@odata.value": "http://foo" + } + } + } + request = rest.build_put_simple_product_request(json=json) + result = send_request_json_response(request) + assert json == result + +def test_model_flattening_with_parameter_flattening(send_request_json_response): + + json = { + "base_product_id": "123", + "base_product_description": "product description", + "details": { + "max_product_display_name": "max name", + "max_product_capacity": "Large", + "max_product_image": { + "@odata.value": "http://foo" + } + } + } + + request = rest.build_post_flattened_simple_product_request(json=json) + result = send_request_json_response(request) + assert result == json + +def test_model_flattening_with_grouping(send_request_json_response): + json = { + "base_product_id": "123", + "base_product_description": "product description", + "details": { + "max_product_display_name": "max name", + "max_product_capacity": "Large", + "max_product_image": { + "@odata.value": "http://foo" + } + } + } + request = rest.build_put_simple_product_with_grouping_request( + name='groupproduct', + json=json + ) + result = send_request_json_response(request) + assert result == json diff --git a/test/vanilla/low-level/AcceptanceTests/test_multiple_inheritance.py b/test/vanilla/low-level/AcceptanceTests/test_multiple_inheritance.py new file mode 100644 index 00000000000..45231e54645 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_multiple_inheritance.py @@ -0,0 +1,85 @@ +# 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. +# +# -------------------------------------------------------------------------- + + +from multipleinheritancelowlevel import MultipleInheritanceServiceClient +from multipleinheritancelowlevel.rest import * +import pytest + +@pytest.fixture +def client(): + with MultipleInheritanceServiceClient(base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_get_pet(send_request_json_response): + request = build_get_pet_request() + assert {"name": "Peanut"} == send_request_json_response(request) + +def test_put_pet(send_request_json_response): + request = build_put_pet_request(json={"name": "Butter"}) + result = send_request_json_response(request) + assert result == "Pet was correct!" + +def test_get_horse(send_request_json_response): + request = build_get_horse_request() + assert {"name": "Fred", "isAShowHorse": True} == send_request_json_response(request) + +def test_put_horse(send_request_json_response): + request = build_put_horse_request(json={"name": "General", "isAShowHorse": False}) + result = send_request_json_response(request) + assert result == "Horse was correct!" + +def test_get_feline(send_request_json_response): + request = build_get_feline_request() + assert {"meows": True, "hisses": True} == send_request_json_response(request) + +def test_put_feline(send_request_json_response): + request = build_put_feline_request(json={"meows": False, "hisses": True}) + result = send_request_json_response(request) + assert result == "Feline was correct!" + +def test_get_cat(send_request_json_response): + request = build_get_cat_request() + assert {"name": "Whiskers", "likesMilk": True, "meows": True, "hisses": True} == send_request_json_response(request) + +def test_put_cat(send_request_json_response): + request = build_put_cat_request(json={"name": "Boots", "likesMilk": False, "meows": True, "hisses": False}) + assert send_request_json_response(request) == "Cat was correct!" + +def test_get_kitten(send_request_json_response): + request = build_get_kitten_request() + assert {"name": "Gatito", "likesMilk": True, "meows": True, "hisses": True, "eatsMiceYet": False} == send_request_json_response(request) + +def test_put_kitten(send_request_json_response): + request = build_put_kitten_request(json={"name": "Kitty", "likesMilk": False, "meows": True, "hisses": False, "eatsMiceYet": True}) + assert "Kitten was correct!" == send_request_json_response(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_non_string_enums.py b/test/vanilla/low-level/AcceptanceTests/test_non_string_enums.py new file mode 100644 index 00000000000..108650e9015 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_non_string_enums.py @@ -0,0 +1,57 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- +from nonstringenumslowlevel import NonStringEnumsClient +from nonstringenumslowlevel.rest import int, float + +import pytest +import json + +@pytest.fixture +def client(): + with NonStringEnumsClient() as client: + yield client + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_put_int_enum(send_request_json_response): + request = int.build_put_request(json=200) + assert send_request_json_response(request) == "Nice job posting an int enum" + +def test_get_int_enum(send_request_json_response): + request = int.build_get_request() + assert send_request_json_response(request) == 429 + +def test_put_float_enum(send_request_json_response): + request = float.build_put_request(json=200.4) + assert send_request_json_response(request) == "Nice job posting a float enum" + +def test_get_float_enum(send_request_json_response): + request = float.build_get_request() + assert send_request_json_response(request) == 429.1 diff --git a/test/vanilla/low-level/AcceptanceTests/test_number.py b/test/vanilla/low-level/AcceptanceTests/test_number.py new file mode 100644 index 00000000000..86119391184 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_number.py @@ -0,0 +1,135 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from decimal import Decimal +import pytest + +from bodynumberlowlevel import AutoRestNumberTestService +from bodynumberlowlevel.rest import number + +import pytest + +@pytest.fixture +def client(): + with AutoRestNumberTestService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_big_float(send_request, send_request_json_response): + request = number.build_put_big_float_request(json=3.402823e+20) + send_request(request) + + request = number.build_get_big_float_request() + assert send_request_json_response(request) == 3.402823e+20 + +def test_small_float(send_request, send_request_json_response): + request = number.build_put_small_float_request(json=3.402823e-20) + send_request(request) + + request = number.build_get_small_float_request() + assert send_request_json_response(request) == 3.402823e-20 + +def test_big_double(send_request, send_request_json_response): + request = number.build_put_big_double_request(json=2.5976931e+101) + send_request(request) + + request = number.build_get_big_double_request() + assert send_request_json_response(request) == 2.5976931e+101 + +def test_small_double(send_request, send_request_json_response): + request = number.build_put_small_double_request(json=2.5976931e-101) + send_request(request) + + request = number.build_get_small_double_request() + assert send_request_json_response(request) == 2.5976931e-101 + +def test_big_double_negative_decimal(send_request, send_request_json_response): + request = number.build_get_big_double_negative_decimal_request(json=-99999999.99) + send_request(request) + + request = number.build_get_big_double_negative_decimal_request() + assert send_request_json_response(request) == -99999999.99 + +def test_big_double_positive_decimal(send_request, send_request_json_response): + request = number.build_put_big_double_positive_decimal_request(json=99999999.99) + send_request(request) + + request = number.build_get_big_double_positive_decimal_request() + assert send_request_json_response(request) == 99999999.99 + +def test_big_decimal(send_request, send_request_json_response): + request = number.build_put_big_decimal_request(json=2.5976931e+101) + send_request(request) + + request = number.build_get_big_decimal_request() + assert send_request_json_response(request) == 2.5976931e+101 + +def test_small_decimal(send_request, send_request_json_response): + request = number.build_put_small_decimal_request(json=2.5976931e-101) + send_request(request) + + request = number.build_get_small_decimal_request() + assert send_request_json_response(request) == 2.5976931e-101 + +def test_get_big_decimal_negative_decimal(send_request, send_request_json_response): + request = number.build_put_big_decimal_negative_decimal_request(json=-99999999.99) + + request = number.build_get_big_decimal_negative_decimal_request() + assert send_request_json_response(request) == -99999999.99 + +def test_get_big_decimal_positive_decimal(send_request, send_request_json_response): + request = number.build_put_big_decimal_positive_decimal_request(json=99999999.99) + send_request(request) + + request = number.build_get_big_decimal_positive_decimal_request() + assert send_request_json_response(request) == 99999999.99 + +def test_get_null(send_request): + request = number.build_get_null_request() + assert send_request(request).text == '' + +def test_get_invalid_decimal(send_request): + request = number.build_get_invalid_decimal_request() + assert send_request(request).text == '9223372036854775910.980089k' + +def test_get_invalid_double(send_request): + request = number.build_get_invalid_double_request() + assert send_request(request).text == '9223372036854775910.980089k' + +def test_get_invalid_float(send_request): + request = number.build_get_invalid_float_request() + assert send_request(request).text == '2147483656.090096789909j' diff --git a/test/vanilla/low-level/AcceptanceTests/test_object_type.py b/test/vanilla/low-level/AcceptanceTests/test_object_type.py new file mode 100644 index 00000000000..0d3e9cd790a --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_object_type.py @@ -0,0 +1,56 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from objecttypelowlevel import ObjectTypeClient +from objecttypelowlevel.rest import build_get_request, build_put_request +from azure.core.exceptions import HttpResponseError + +import pytest + +@pytest.fixture +def client(): + with ObjectTypeClient(base_url="http://localhost:3000") 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_get_object(send_request): + request = build_get_request() + assert send_request(request).json() == {"message": "An object was successfully returned"} + +def test_put_object_success(send_request): + request = build_put_request(json={"foo": "bar"}) + assert send_request(request).text == '' + +def test_put_object_fail(send_request): + request = build_put_request(json={"should": "fail"}) + with pytest.raises(HttpResponseError) as ex: + send_request(request) + assert ex.value.response.json()['message'] == 'The object you passed was incorrect' \ No newline at end of file diff --git a/test/vanilla/low-level/AcceptanceTests/test_required_optional.py b/test/vanilla/low-level/AcceptanceTests/test_required_optional.py new file mode 100644 index 00000000000..1d0539eaa5b --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_required_optional.py @@ -0,0 +1,194 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +import io +from azure.core.exceptions import HttpResponseError +from msrest.exceptions import ValidationError + +from requiredoptionallowlevel import AutoRestRequiredOptionalTestService +from requiredoptionallowlevel.rest import implicit, explicit + +import pytest + +@pytest.fixture +def client_required(): + with AutoRestRequiredOptionalTestService( + "required_path", + "required_query", + base_url="http://localhost:3000") as client: + client._config.required_global_path = "required_path" + client._config.required_global_query = "required_query" + yield client + +@pytest.fixture +def send_request_required_client(client_required, base_send_request): + def _send_request(request): + return base_send_request(client_required, request) + return _send_request + +@pytest.fixture +def client(): + with AutoRestRequiredOptionalTestService( + "required_path", + "required_query", + base_url="http://localhost:3000") as client: + client._config.required_global_path = None + client._config.required_global_query = None + yield client + +@pytest.fixture +def send_request_client(client, base_send_request): + def _send_request(request): + return base_send_request(client, request) + return _send_request +# NOTE: in the LLC version, we can't raise as many ValidationErrors as the high level convenience layer does. +# This is because we're not serializing bodies at all, so msrest doesn't have a chance to throw the validation error + + +# These clients have a required global path and query +def test_put_optional(send_request_required_client): + request = implicit.build_put_optional_query_request(query_parameter=None) + send_request_required_client(request) + + request = implicit.build_put_optional_body_request(json=None) + send_request_required_client(request) + + request = implicit.build_put_optional_header_request(query_parameter=None) + send_request_required_client(request) + +def test_get_optional_global_query(send_request_required_client): + request = implicit.build_get_optional_global_query_request(optional_global_query=None) + send_request_required_client(request) + +def test_post_optional_integer(send_request_required_client): + request = explicit.build_post_optional_integer_parameter_request(json=None) + send_request_required_client(request) + + + request = explicit.build_post_optional_integer_property_request(json={"value": None}) + send_request_required_client(request) + + request = explicit.build_post_optional_integer_header_request(header_parameter=None) + send_request_required_client(request) + +def test_post_optional_string(send_request_required_client): + request = explicit.build_post_optional_string_parameter_request(json=None) + send_request_required_client(request) + + + request = explicit.build_post_optional_string_property_request(json={"value": None}) + send_request_required_client(request) + + request = explicit.build_post_optional_string_header_request(body_parameter=None) + send_request_required_client(request) + +def test_post_optional_class(send_request_required_client): + request = explicit.build_post_optional_class_parameter_request() + send_request_required_client(request) + + request = explicit.build_post_optional_class_property_request(json={"value": None}) + send_request_required_client(request) + +def test_post_optional_array(send_request_required_client): + request = explicit.build_post_optional_array_parameter_request(json=None) + send_request_required_client(request) + + request = explicit.build_post_optional_array_property_request(json={"value": None}) + send_request_required_client(request) + + request = explicit.build_post_optional_array_header_request(header_parameter=None) + send_request_required_client(request) + +def test_implicit_get_required(send_request_client): + with pytest.raises(ValidationError): + request = implicit.build_get_required_path_request(path_parameter=None) + send_request_client(request) + + with pytest.raises(ValidationError): + request = implicit.build_get_required_global_path_request(required_global_path=None) + send_request_client(request) + + with pytest.raises(ValidationError): + request = implicit.build_get_required_global_query_request(required_global_query=None) + send_request_client(request) + +def test_post_required_string(send_request_client): + with pytest.raises(ValidationError): + request = explicit.build_post_required_string_header_request(header_parameter=None) + send_request_client(request) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_string_parameter_request() + send_request_client(request) + + assert "Not Found" in str(ex.value) + + with pytest.raises(HttpResponseError)as ex: + request = explicit.build_post_required_string_property_request(json={"value": None}) + send_request_client(request) + assert "Not Found" in str(ex.value) + +def test_post_required_array(send_request_client): + with pytest.raises(ValidationError): + request = explicit.build_post_required_array_header_request(header_parameter=None) + send_request_client(request) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_array_parameter_request() + send_request_client(request) + assert "Not Found" in str(ex.value) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_array_property_request(json={"value": None}) + send_request_client(request) + assert "Not Found" in str(ex.value) + +def test_post_required_class(send_request_client): + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_class_parameter_request() + send_request_client(request) + assert "Not Found" in str(ex.value) + + with pytest.raises(HttpResponseError) as ex: + request = explicit.build_post_required_class_property_request(json={"value": None}) + send_request_client(request) + assert "Not Found" in str(ex.value) + +def test_explict_put_optional_binary_body(send_request_client): + request = explicit.build_put_optional_binary_body_request() + send_request_client(request) + +def test_explict_put_required_binary_body(client): + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = explicit.build_put_required_binary_body_request(content=stream_data) + client.send_request(request, stream=True) + +def test_implicit_put_optional_binary_body(send_request_client): + request = explicit.build_put_optional_binary_body_request() + send_request_client(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_send_request.py b/test/vanilla/low-level/AcceptanceTests/test_send_request.py new file mode 100644 index 00000000000..22eedfc8df2 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_send_request.py @@ -0,0 +1,173 @@ +# -------------------------------------------------------------------------- +# +# 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 io +import json + +from azure.core.rest import HttpRequest + +from os.path import dirname, pardir, join, realpath +import pytest + +cwd = dirname(realpath(__file__)) + + +class TestSendRequest(object): + + def test_send_request_with_body_get_model_deserialize(self): + from bodycomplexlowlevel import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + ) + + response = client.send_request(request) + response.raise_for_status() + + deserialized = response.json() + assert 2 == deserialized['id'] + assert "Siameeee" == deserialized['name'] + assert -1 == deserialized['hates'][1]['id'] + assert "Tomato" == deserialized['hates'][1]['name'] + + def test_send_request_with_stream_get_direct_json(self): + from bodycomplexlowlevel import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + request = HttpRequest("GET", "/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + with client.send_request(request, stream=True) as response: + response.raise_for_status() + data = ''.join([chunk for chunk in response.iter_text()]) + json_response = json.loads(data) + assert 2 == json_response['id'] + assert "Siameeee" == json_response['name'] + assert - 1 == json_response['hates'][1]['id'] + assert "Tomato" == json_response['hates'][1]['name'] + + def test_send_request_with_body_put_json_dumps(self): + from bodycomplexlowlevel import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://localhost:3000") + + siamese_body = { + "id": 2, + "name": "Siameeee", + "color": "green", + "hates": + [ + { + "id": 1, + "name": "Potato", + "food": "tomato" + }, + { + "id": -1, + "name": "Tomato", + "food": "french fries" + } + ], + "breed": "persian" + } + + request = HttpRequest("PUT", "/complex/inheritance/valid", + json=siamese_body + ) + assert request.headers['Content-Type'] == "application/json" + response = client.send_request(request) + response.raise_for_status() + assert response.status_code == 200 + + def test_send_request_get_stream(self): + from bodyfilelowlevel import AutoRestSwaggerBATFileService + + client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000", connection_data_block_size=1000) + file_length = 0 + with io.BytesIO() as file_handle: + + request = HttpRequest("GET", "/files/stream/nonempty", + headers={ + 'Accept': 'image/png, application/json' + }, + ) + + with client.send_request(request, stream=True) as response: + response.raise_for_status() + for data in response.iter_bytes(): + file_length += len(data) + file_handle.write(data) + + assert file_length != 0 + + sample_file = realpath( + join(cwd, pardir, pardir, pardir, pardir, + "node_modules", "@microsoft.azure", "autorest.testserver", "routes", "sample.png")) + + with open(sample_file, 'rb') as data: + sample_data = hash(data.read()) + assert sample_data == hash(file_handle.getvalue()) + + def test_send_request_put_stream(self): + from bodyformdatalowlevel import AutoRestSwaggerBATFormDataService + + client = AutoRestSwaggerBATFormDataService( + base_url="http://localhost:3000", + ) + + test_string = "Upload file test case" + test_bytes = bytearray(test_string, encoding='utf-8') + with io.BytesIO(test_bytes) as stream_data: + request = HttpRequest("PUT", '/formdata/stream/uploadfile', + content=stream_data, + headers={"Content-Type": "application/octet-stream"} + ) + with client.send_request(request, stream=True) as response: + response.raise_for_status() + + def test_send_request_full_url(self): + from bodycomplexlowlevel import AutoRestComplexTestService + + client = AutoRestComplexTestService(base_url="http://fakeUrl") + + request = HttpRequest("GET", "http://localhost:3000/complex/inheritance/valid", + headers={ + 'Accept': 'application/json' + }, + ) + + response = client.send_request(request) + response.raise_for_status() + + deserialized = response.json() + assert 2 == deserialized['id'] + assert "Siameeee" == deserialized['name'] + assert -1 == deserialized['hates'][1]['id'] + assert "Tomato" == deserialized['hates'][1]['name'] diff --git a/test/vanilla/low-level/AcceptanceTests/test_string_tests.py b/test/vanilla/low-level/AcceptanceTests/test_string_tests.py new file mode 100644 index 00000000000..f9e5d7cbe85 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_string_tests.py @@ -0,0 +1,171 @@ +# 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. +# +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError + +from bodystringlowlevel import AutoRestSwaggerBATService +from bodystringlowlevel.rest import string, enum +import pytest +from msrest import Serializer, Deserializer +from base64 import b64decode + +@pytest.fixture +def client(): + with AutoRestSwaggerBATService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +def test_null(send_request): + request = string.build_get_null_request() + assert send_request(request).text == '' + + request = string.build_put_null_request(content=None) + send_request(request) + +def test_empty(send_request, send_request_json_response): + request = string.build_get_empty_request() + assert "" == send_request_json_response(request) + # changing this behavior because of this pr being merged: https://github.com/Azure/autorest.testserver/pull/145/files + request = string.build_put_empty_request(json="") + send_request(request) + +def test_mbcs(send_request, send_request_json_response): + try: + test_str = ( + "\xe5\x95\x8a\xe9\xbd\x84\xe4\xb8\x82\xe7\x8b\x9b\xe7\x8b" + "\x9c\xef\xa7\xb1\xef\xa4\xac\xef\xa7\xb1\xef\xa8\x8c\xef" + "\xa8\xa9\xcb\x8a\xe3\x80\x9e\xe3\x80\xa1\xef\xbf\xa4\xe2" + "\x84\xa1\xe3\x88\xb1\xe2\x80\x90\xe3\x83\xbc\xef\xb9\xa1" + "\xef\xb9\xa2\xef\xb9\xab\xe3\x80\x81\xe3\x80\x93\xe2\x85" + "\xb0\xe2\x85\xb9\xe2\x92\x88\xe2\x82\xac\xe3\x88\xa0\xe3" + "\x88\xa9\xe2\x85\xa0\xe2\x85\xab\xef\xbc\x81\xef\xbf\xa3" + "\xe3\x81\x81\xe3\x82\x93\xe3\x82\xa1\xe3\x83\xb6\xce\x91" + "\xef\xb8\xb4\xd0\x90\xd0\xaf\xd0\xb0\xd1\x8f\xc4\x81\xc9" + "\xa1\xe3\x84\x85\xe3\x84\xa9\xe2\x94\x80\xe2\x95\x8b\xef" + "\xb8\xb5\xef\xb9\x84\xef\xb8\xbb\xef\xb8\xb1\xef\xb8\xb3" + "\xef\xb8\xb4\xe2\x85\xb0\xe2\x85\xb9\xc9\x91\xee\x9f\x87" + "\xc9\xa1\xe3\x80\x87\xe3\x80\xbe\xe2\xbf\xbb\xe2\xba\x81" + "\xee\xa1\x83\xe4\x9c\xa3\xee\xa1\xa4\xe2\x82\xac").decode('utf-8') + + except AttributeError: + test_str = ( + b"\xe5\x95\x8a\xe9\xbd\x84\xe4\xb8\x82\xe7\x8b\x9b\xe7\x8b" + b"\x9c\xef\xa7\xb1\xef\xa4\xac\xef\xa7\xb1\xef\xa8\x8c\xef" + b"\xa8\xa9\xcb\x8a\xe3\x80\x9e\xe3\x80\xa1\xef\xbf\xa4\xe2" + b"\x84\xa1\xe3\x88\xb1\xe2\x80\x90\xe3\x83\xbc\xef\xb9\xa1" + b"\xef\xb9\xa2\xef\xb9\xab\xe3\x80\x81\xe3\x80\x93\xe2\x85" + b"\xb0\xe2\x85\xb9\xe2\x92\x88\xe2\x82\xac\xe3\x88\xa0\xe3" + b"\x88\xa9\xe2\x85\xa0\xe2\x85\xab\xef\xbc\x81\xef\xbf\xa3" + b"\xe3\x81\x81\xe3\x82\x93\xe3\x82\xa1\xe3\x83\xb6\xce\x91" + b"\xef\xb8\xb4\xd0\x90\xd0\xaf\xd0\xb0\xd1\x8f\xc4\x81\xc9" + b"\xa1\xe3\x84\x85\xe3\x84\xa9\xe2\x94\x80\xe2\x95\x8b\xef" + b"\xb8\xb5\xef\xb9\x84\xef\xb8\xbb\xef\xb8\xb1\xef\xb8\xb3" + b"\xef\xb8\xb4\xe2\x85\xb0\xe2\x85\xb9\xc9\x91\xee\x9f\x87" + b"\xc9\xa1\xe3\x80\x87\xe3\x80\xbe\xe2\xbf\xbb\xe2\xba\x81" + b"\xee\xa1\x83\xe4\x9c\xa3\xee\xa1\xa4\xe2\x82\xac").decode('utf-8') + + request = string.build_get_mbcs_request() + assert test_str == send_request_json_response(request) + + request = string.build_put_mbcs_request(json=test_str) + send_request(request) + +def test_whitespace(send_request, send_request_json_response): + test_str = " Now is the time for all good men to come to the aid of their country " + request = string.build_get_whitespace_request() + assert test_str == send_request_json_response(request) + + request = string.build_put_whitespace_request(json=test_str) + send_request(request) + +def test_get_not_provided(send_request): + request = string.build_get_not_provided_request() + assert send_request(request).text == '' + +def test_enum_not_expandable(send_request, send_request_json_response): + request = enum.build_get_not_expandable_request() + assert "red color" == send_request_json_response(request) + + request = enum.build_put_not_expandable_request(json='red color') + send_request(request) + + request = enum.build_put_not_expandable_request(json='red color') + send_request(request) + # Autorest v3 is switching behavior here. Old Autorest would have thrown a serialization error, + # but now we allow the user to pass strings as enums, so the raised exception is different. + + request = enum.build_put_not_expandable_request(json='not a color') + with pytest.raises(HttpResponseError): + send_request(request) + +def test_get_base64_encoded(send_request): + request = string.build_get_base64_encoded_request() + assert b64decode(send_request(request).text) == 'a string that gets encoded with base64'.encode() + +def test_base64_url_encoded(send_request): + # the b64 encoding and decoding is taken from msrest + request = string.build_get_base64_url_encoded_request() + response = send_request(request).text + response = Deserializer.deserialize_base64(response) + assert response == 'a string that gets encoded with base64url'.encode() + + content = Serializer.serialize_base64('a string that gets encoded with base64url'.encode()) + request = string.build_put_base64_url_encoded_request(json=content) + send_request(request) + +def test_get_null_base64_url_encoded(send_request): + request = string.build_get_null_base64_url_encoded_request() + assert send_request(request).text == '' + +def test_enum_referenced(send_request, send_request_json_response): + request = enum.build_put_referenced_request(json='red color') + send_request(request) + + request = enum.build_put_referenced_request(json="red color") + send_request(request) + + request = enum.build_get_referenced_request() + assert send_request_json_response(request) == 'red color' + +def test_enum_referenced_constant(send_request, send_request_json_response): + request = enum.build_put_referenced_request(json='red color') + send_request(request) + + request = enum.build_get_referenced_constant_request() + response = send_request_json_response(request) + assert response == {'field1': 'Sample String'} # there's no constant on the response, so just getting field1 diff --git a/test/vanilla/low-level/AcceptanceTests/test_time.py b/test/vanilla/low-level/AcceptanceTests/test_time.py new file mode 100644 index 00000000000..34f044d6342 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_time.py @@ -0,0 +1,50 @@ +# 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 datetime + +from bodytimelowlevel import AutoRestTimeTestService +from bodytimelowlevel.rest import time +import pytest + +@pytest.fixture +def client(): + with AutoRestTimeTestService(base_url="http://localhost:3000") as client: + yield client + +def test_get(client): + request = time.build_get_request() + response = client.send_request(request) + response.raise_for_status() + assert datetime.datetime.strptime(response.json(), '%H:%M:%S').time() == datetime.time(11, 34, 56) + + +def test_put(client): + request = time.build_put_request(json=datetime.time(8, 7, 56).strftime("%H:%M:%S")) + response = client.send_request(request) + response.raise_for_status() + assert response.json() == "Nice job posting time" diff --git a/test/vanilla/low-level/AcceptanceTests/test_url.py b/test/vanilla/low-level/AcceptanceTests/test_url.py new file mode 100644 index 00000000000..d1979995146 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_url.py @@ -0,0 +1,348 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +from datetime import datetime +from urllowlevel import AutoRestUrlTestService +from urllowlevel.rest import queries, paths, path_items +from urlmulticollectionformatlowlevel import AutoRestUrlMutliCollectionFormatTestService +from urlmulticollectionformatlowlevel.rest import queries as multiqueries +from msrest.exceptions import ValidationError + +import pytest + +@pytest.fixture +def client(): + with AutoRestUrlTestService('', base_url="http://localhost:3000") as client: + yield client + +@pytest.fixture +def multi_client(): + with AutoRestUrlMutliCollectionFormatTestService("http://localhost:3000") 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 + +@pytest.fixture +def make_multi_request(multi_client, base_send_request): + def _send_request(request): + return base_send_request(multi_client, request) + return _send_request + +@pytest.fixture +def test_array_query(): + return ["ArrayQuery1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + +def test_byte_empty_and_null(send_request): + request = paths.build_byte_empty_request() + send_request(request) + + with pytest.raises(ValidationError): + paths.build_byte_null_request(None) + +def test_byte_multi_byte(send_request): + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + request = paths.build_byte_multi_byte_request(u_bytes) + send_request(request) + +def test_date_null(send_request): + with pytest.raises(ValidationError): + paths.build_date_null_request(None) + +def test_date_time_null(send_request): + with pytest.raises(ValidationError): + paths.build_date_time_null_request(None) + +def test_date_time_valid(send_request): + request = paths.build_date_time_valid_request() + send_request(request) + +def test_date_valid(send_request): + request = paths.build_date_valid_request() + send_request(request) + +def test_unix_time_url(send_request): + request = paths.build_unix_time_url_request(datetime(year=2016, month=4, day=13)) + send_request(request) + +def test_double_decimal(send_request): + request = paths.build_double_decimal_negative_request() + send_request(request) + request = paths.build_double_decimal_positive_request() + send_request(request) + +def test_float_scientific(send_request): + request = paths.build_float_scientific_negative_request() + send_request(request) + + request = paths.build_float_scientific_positive_request() + send_request(request) + +def test_get_boolean(send_request): + request = paths.build_get_boolean_false_request() + send_request(request) + + request = paths.build_get_boolean_true_request() + send_request(request) + +def test_int(send_request): + request = paths.build_get_int_negative_one_million_request() + send_request(request) + + request = paths.build_get_int_one_million_request() + send_request(request) + +def test_get_long(send_request): + request = paths.build_get_negative_ten_billion_request() + send_request(request) + + request = paths.build_get_ten_billion_request() + send_request(request) + +def test_string_empty_and_null(send_request): + request = paths.build_string_empty_request() + send_request(request) + + with pytest.raises(ValidationError): + paths.build_string_null_request(None) + +def test_array_csv_in_path(send_request): + test_array = ["ArrayPath1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + request = paths.build_array_csv_in_path_request(test_array) + send_request(request) + +def test_string_url_encoded(send_request): + request = paths.build_string_url_encoded_request() + send_request(request) + +def test_paths_unicode(send_request): + request = paths.build_string_unicode_request() + send_request(request) + +def test_string_url_non_encoded(send_request): + request = paths.build_string_url_non_encoded_request() + send_request(request) + +def test_enum_valid(send_request): + request = paths.build_enum_valid_request("green color") + send_request(request) + +def test_enum_null(send_request): + with pytest.raises(ValidationError): + paths.build_enum_null_request(None) + +def test_base64_url(send_request): + request = paths.build_base64_url_request("lorem".encode()) + send_request(request) + +def test_queries_byte(send_request): + request = queries.build_byte_empty_request() + send_request(request) + + u_bytes = bytearray(u"\u554A\u9F44\u4E02\u72DB\u72DC\uF9F1\uF92C\uF9F1\uFA0C\uFA29", encoding='utf-8') + request = queries.build_byte_multi_byte_request(byte_query=u_bytes) + send_request(request) + + request = queries.build_byte_null_request() + send_request(request) + +def test_queries_date(send_request): + request = queries.build_date_null_request() + send_request(request) + + request = queries.build_date_valid_request() + send_request(request) + +def test_queries_date_time(send_request): + request = queries.build_date_time_null_request() + send_request(request) + + request = queries.build_date_time_valid_request() + send_request(request) + +def test_queries_double(send_request): + request = queries.build_double_null_request() + send_request(request) + + request = queries.build_double_decimal_negative_request() + send_request(request) + + request = queries.build_double_decimal_positive_request() + send_request(request) + +def test_queries_float_scientific(send_request): + request = queries.build_float_scientific_negative_request() + send_request(request) + + request = queries.build_float_scientific_positive_request() + send_request(request) + request = queries.build_float_null_request() + send_request(request) + +def test_queries_boolean(send_request): + request = queries.build_get_boolean_false_request() + send_request(request) + + request = queries.build_get_boolean_true_request() + send_request(request) + + request = queries.build_get_boolean_null_request() + send_request(request) + +def test_queries_int(send_request): + request = queries.build_get_int_negative_one_million_request() + send_request(request) + + request = queries.build_get_int_one_million_request() + send_request(request) + + request = queries.build_get_int_null_request() + send_request(request) + +def test_queries_long(send_request): + request = queries.build_get_negative_ten_billion_request() + send_request(request) + + request = queries.build_get_ten_billion_request() + send_request(request) + + request = queries.build_get_long_null_request() + send_request(request) + +def test_queries_string(send_request): + request = queries.build_string_empty_request() + send_request(request) + + request = queries.build_string_null_request() + send_request(request) + + request = queries.build_string_url_encoded_request() + send_request(request) + +def test_queries_enum(send_request): + request = queries.build_enum_valid_request(enum_query="green color") + send_request(request) + + request = queries.build_enum_null_request(enum_query=None) + send_request(request) + +def test_queries_unicode(send_request): + request = queries.build_string_unicode_request() + send_request(request) + +def test_array_string_csv(send_request, test_array_query): + request = queries.build_array_string_csv_empty_request(array_query=[]) + send_request(request) + + request = queries.build_array_string_csv_null_request(array_query=None) + send_request(request) + + request = queries.build_array_string_csv_valid_request(array_query=test_array_query) + send_request(request) + +def test_array_string_miscellaneous(send_request, test_array_query): + request = queries.build_array_string_pipes_valid_request(array_query=test_array_query) + send_request(request) + + request = queries.build_array_string_ssv_valid_request(array_query=test_array_query) + send_request(request) + + request = queries.build_array_string_tsv_valid_request(array_query=test_array_query) + send_request(request) + +def test_array_string_multi(make_multi_request, test_array_query): + request = multiqueries.build_array_string_multi_empty_request(array_query=[]) + make_multi_request(request) + + request = multiqueries.build_array_string_multi_null_request() + make_multi_request(request) + + request = multiqueries.build_array_string_multi_valid_request(array_query=test_array_query) + make_multi_request(request) + +def test_array_string_no_collection_format(send_request): + request = queries.build_array_string_no_collection_format_empty_request(array_query=['hello', 'nihao', 'bonjour']) + send_request(request) + +def test_get_all_with_values(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + global_string_query = "globalStringQuery" + + request = path_items.build_get_all_with_values_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query="pathItemStringQuery", + global_string_query=global_string_query, + local_string_query="localStringQuery", + ) + + send_request(request) + +def test_get_global_and_local_query_null(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + + request = path_items.build_get_global_and_local_query_null_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query="pathItemStringQuery", + global_string_query=None + ) + send_request(request) + +def test_get_global_query_null(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + + request = path_items.build_get_global_query_null_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query="pathItemStringQuery", + local_string_query="localStringQuery", + ) + send_request(request) + +def test_get_local_path_item_query_null(send_request): + # In LLC, we have to pass in global variables to individual operations; we don't have access to the client in the request builders + global_string_path = "globalStringPath" + global_string_query = "globalStringQuery" + + request = path_items.build_get_local_path_item_query_null_request( + path_item_string_path="pathItemStringPath", + global_string_path=global_string_path, + local_string_path="localStringPath", + path_item_string_query=None, + global_string_query=global_string_query, + local_string_query=None, + ) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_validation.py b/test/vanilla/low-level/AcceptanceTests/test_validation.py new file mode 100644 index 00000000000..8b5b274ea0f --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_validation.py @@ -0,0 +1,143 @@ +# -------------------------------------------------------------------------- +# +# 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 sys + +from msrest.exceptions import ValidationError + +from validationlowlevel import AutoRestValidationTest +from validationlowlevel.rest import * + +import pytest + +@pytest.fixture +def client(): + with AutoRestValidationTest("abc123", base_url="http://localhost:3000") as client: + client.api_version = "12-34-5678" + yield client + +@pytest.fixture +def send_request(client, base_send_request): + def _send_request(request): + return base_send_request(client, request) + return _send_request + +@pytest.fixture +def send_request_json_response(client, base_send_request_json_response): + def _send_request(request): + return base_send_request_json_response(client, request) + return _send_request + +@pytest.fixture +def constant_body(): + """This is NOT considering the constant body, this should work with + the commented line. + See https://github.com/Azure/autorest.modelerfour/issues/83 + """ + return { + 'child': { + 'constProperty': 'constant' + }, + 'constChild': { + 'constProperty': 'constant', + 'constProperty2': 'constant2' + }, + 'constInt': 0, + 'constString': 'constant', + 'constStringAsEnum': 'constant_string_as_enum' + } + +def test_with_constant_in_path(send_request): + request = build_get_with_constant_in_path_request() + send_request(request) + +def test_post_with_constant_in_body(send_request_json_response, constant_body): + request = build_post_with_constant_in_body_request(json=constant_body) + product = send_request_json_response(request) + assert product is not None + +def test_min_length_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="1", id=100) + send_request(request) + except ValidationError as err: + assert err.rule == "min_length" + assert err.target == "resource_group_name" + +def test_max_length_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="1234567890A", id=100) + send_request(request) + except ValidationError as err: + assert err.rule == "max_length" + assert err.target == "resource_group_name" + +def test_pattern_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="!@#$", id=100) + send_request(request) + except ValidationError as err: + assert err.rule == "pattern" + assert err.target == "resource_group_name" + +def test_multiple_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=105) + send_request(request) + except ValidationError as err: + assert err.rule == "multiple" + assert err.target == "id" + +def test_minimum_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=0) + send_request(request) + except ValidationError as err: + assert err.rule == "minimum" + assert err.target == "id" + +def test_maximum_validation(send_request): + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=2000) + send_request(request) + except ValidationError as err: + assert err.rule == "maximum" + assert err.target == "id" + +# NOTE: removed body validation, since it doesn't make sense for LLC as we serialize the body ourselves and pass it in + + +@pytest.mark.xfail(reason="https://github.com/Azure/autorest.modelerfour/issues/90") +def test_api_version_validation(send_request): + client = AutoRestValidationTest( + "abc123", + base_url="http://localhost:3000") + client.api_version = "abc" + try: + request = build_validation_of_method_parameters_request(subscription_id="abc123", resource_group_name="123", id=150) + send_request(request) + except ValidationError as err: + assert err.rule == "pattern" + assert err.target == "self.api_version" diff --git a/test/vanilla/low-level/AcceptanceTests/test_xml.py b/test/vanilla/low-level/AcceptanceTests/test_xml.py new file mode 100644 index 00000000000..df9546c6d63 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_xml.py @@ -0,0 +1,240 @@ +# -------------------------------------------------------------------------- +# +# 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 xml.etree.ElementTree as ET +from xmlservicelowlevel import AutoRestSwaggerBATXMLService +from xmlservicelowlevel.rest import xml +from base64 import b64decode + +import pytest + + +@pytest.fixture +def client(): + with AutoRestSwaggerBATXMLService(base_url="http://localhost:3000") 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 + +@pytest.fixture +def send_request_text_response(client, base_send_request): + def _send_request(request): + return base_send_request(client, request).text + return _send_request + +def test_json_xml(send_request): + request = xml.build_json_input_request(json={"id": 42}) + send_request(request) + + request = xml.build_json_output_request() + assert send_request(request).json()['id'] == 42 + +def test_simple(send_request, send_request_text_response): + # Slideshow + + request = xml.build_get_simple_request() + slideshow = ET.fromstring(send_request_text_response(request)) + assert slideshow.attrib['title'] == "Sample Slide Show" + assert slideshow.attrib['date'] == "Date of publication" + assert slideshow.attrib['author'] == "Yours Truly" + slides = list(slideshow.iterfind('slide')) + assert len(slides) == 2 + + slide1 = slides[0] + assert slide1.attrib['type'] == "all" + assert next(slide1.iterfind('title')).text == "Wake up to WonderWidgets!" + assert len(list(slide1.iterfind('item'))) == 0 + + slide2 = slides[1] + assert slide2.attrib['type'] == "all" + assert next(slide2.iterfind('title')).text == "Overview" + items = list(slide2.iterfind('item')) + assert len(items) == 3 + assert items[0].text == "Why WonderWidgets are great" + assert items[1].text == None + assert items[2].text == "Who buys WonderWidgets" + + request = xml.build_put_simple_request(content=slideshow, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_empty_child_element(send_request, send_request_text_response): + request = xml.build_get_empty_child_element_request() + banana = ET.fromstring(send_request_text_response(request)) + assert banana.attrib == {}# That's the point of this test, it was an empty node. + request = xml.build_put_empty_child_element_request(content=banana, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_empty_root_list(send_request, send_request_text_response): + request = xml.build_get_empty_root_list_request() + empty = ET.fromstring(send_request_text_response(request)) + assert empty.tag == 'bananas' + assert empty.attrib == {} + assert send_request_text_response(request) == "\n" + request = xml.build_put_empty_root_list_request(content=empty, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_root_list_single_item(send_request, send_request_text_response): + request = xml.build_get_root_list_single_item_request() + xml_body = ET.fromstring(send_request_text_response(request)) + bananas = list(xml_body.iterfind('banana')) + assert len(bananas) == 1 + assert next(bananas[0].iterfind('name')).text == "Cavendish" + request = xml.build_put_root_list_single_item_request(content=xml_body, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_root_list(send_request, send_request_text_response): + request = xml.build_get_root_list_request() + xml_body = ET.fromstring(send_request_text_response(request)) + bananas = list(xml_body.iterfind('banana')) + assert len(bananas) == 2 + request = xml.build_put_root_list_request(content=xml_body, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_empty_wrapped_lists(send_request, send_request_text_response): + request = xml.build_get_empty_wrapped_lists_request() + bananas = ET.fromstring(send_request_text_response(request)) + """ + + + + `; + """ + good_apples = [a for a in bananas.iterfind('GoodApples') if a.text] + assert len(good_apples) == 0 + bad_apples = [a for a in bananas.iterfind('BadApples') if a.text] + assert len(bad_apples) == 0 + request = xml.build_put_empty_wrapped_lists_request(content=bananas, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_get_empty(send_request, send_request_text_response): + request = xml.build_get_empty_list_request() + slideshow = ET.fromstring(send_request_text_response(request)) + request = xml.build_put_empty_list_request(content=slideshow, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_wrapped_lists(send_request, send_request_text_response): + request = xml.build_get_wrapped_lists_request() + bananas = ET.fromstring(send_request_text_response(request)) + good_apples = bananas.find('GoodApples') + assert [a.text for a in good_apples.iterfind('Apple')] == ['Fuji', 'Gala'] + + bad_apples = bananas.find('BadApples') + assert [a.text for a in bad_apples.iterfind('Apple')] == ['Red Delicious'] + request = xml.build_put_wrapped_lists_request(content=bananas, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_complex_types(send_request, send_request_text_response): + request = xml.build_get_complex_type_ref_no_meta_request() + root = ET.fromstring(send_request_text_response(request)) + ref_to_model = root.find('RefToModel') + assert ref_to_model.find('ID').text == "myid" + request = xml.build_put_complex_type_ref_no_meta_request(content=root, headers={"Content-Type": "application/xml"}) + send_request(request) + + request = xml.build_get_complex_type_ref_with_meta_request() + root = ET.fromstring(send_request_text_response(request)) + ref_to_model = root.find('XMLComplexTypeWithMeta') + assert ref_to_model.find('ID').text == "myid" + request = xml.build_put_complex_type_ref_with_meta_request(content=root, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_list_containers(send_request_text_response): + request = xml.build_list_containers_request() + xml_body = ET.fromstring(send_request_text_response(request)) + containers = xml_body.find('Containers') + container_list = list(containers.iterfind('Container')) + assert len(container_list) == 3 + +def test_list_blobs(send_request_text_response): + request = xml.build_list_blobs_request() + xml_body = ET.fromstring(send_request_text_response(request)) + blobs_xml_body = xml_body.find('Blobs') + blobs = list(blobs_xml_body.iterfind('Blob')) + assert len(blobs) == 5 + assert blobs_xml_body.find('BlobPrefix') is None + blob = blobs[0] + assert blob.find('Name').text == "blob1.txt" + properties = blob.find('Properties') + assert properties.find('Last-Modified').text == 'Wed, 09 Sep 2009 09:20:02 GMT' + assert properties.find('Etag').text == "0x8CBFF45D8A29A19" + assert properties.find('Content-Length').text == "100" + assert properties.find('Content-Type').text == "text/html" + # Check that an empty field in the XML is empty string + assert properties.find('Content-Encoding').text is None + assert properties.find('Content-Language').text == "en-US" + assert properties.find('Content-MD5').text is None + assert properties.find('Cache-Control').text == "no-cache" + assert properties.find('BlobType').text == "BlockBlob" + # Check that a field NOT in the XML is None + assert properties.find('Destination-Snapshot') is None + metadata_body = blob.find('Metadata') + assert metadata_body.find("Color").text == "blue" + assert metadata_body.find("BlobNumber").text == "01" + assert metadata_body.find("SomeMetadataName").text == "SomeMetadataValue" + +def test_service_properties(send_request, send_request_text_response): + request = xml.build_get_service_properties_request() + properties = ET.fromstring(send_request_text_response(request)) + assert properties.find('HourMetrics') is not None + assert properties.find('MinuteMetrics') is not None + request = xml.build_put_service_properties_request(content=properties, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_acls(send_request, send_request_text_response): + request = xml.build_get_acls_request() + acls = ET.fromstring(send_request_text_response(request)) + signed_identifiers = list(acls.iterfind('SignedIdentifier')) + assert len(signed_identifiers) == 1 + assert signed_identifiers[0].find('Id').text == 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=' + request = xml.build_put_acls_request(content=acls, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_xms_text(send_request_text_response): + request = xml.build_get_xms_text_request() + xml_object = ET.fromstring(send_request_text_response(request)) + assert xml_object.attrib['language'] == "english" + assert xml_object.text == "I am text" + +def test_bytes(send_request_text_response, send_request): + request = xml.build_get_bytes_request() + bytes_object = ET.fromstring(send_request_text_response(request)) + assert bytes_object.tag == 'ModelWithByteProperty' + assert b64decode(bytes_object.find('Bytes').text) == b"Hello world" + + request = xml.build_put_binary_request(content=bytes_object, headers={"Content-Type": "application/xml"}) + send_request(request) + +def test_url(send_request_text_response, send_request): + request = xml.build_get_uri_request() + url_object = ET.fromstring(send_request_text_response(request)) + assert url_object.tag == 'ModelWithUrlProperty' + assert url_object.find('Url').text == 'https://myaccount.blob.core.windows.net/' + + request = xml.build_put_uri_request(content=url_object, headers={"Content-Type": "application/xml"}) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_zzz.py b/test/vanilla/low-level/AcceptanceTests/test_zzz.py new file mode 100644 index 00000000000..aea2212acb5 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_zzz.py @@ -0,0 +1,92 @@ +# -------------------------------------------------------------------------- +# +# 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 sys +import datetime +import os +import platform +import warnings + +from reportlowlevel import AutoRestReportService, rest + + +class TestAcceptance(object): + + def test_ensure_coverage(self): + client = AutoRestReportService(base_url="http://localhost:3000") + request = rest.build_get_report_request(qualifier=platform.python_version()) + report = client.send_request(request).json() + + request = rest.build_get_optional_report_request(qualifier=platform.python_version()) + optional_report = client.send_request(request).json() + + # Add tests that wont be supported due to the nature of Python here + not_supported = {} + + # Please add missing features or failing tests here + missing_features_or_bugs = { + 'ConstantsInBody': 1, # https://github.com/Azure/autorest.modelerfour/issues/83 + } + + print("Coverage:") + self._print_report(report, not_supported, missing_features_or_bugs) + + missing_features_or_bugs = { + "putDateTimeMaxLocalNegativeOffset": 1, # Python doesn't support year 1000 + "putDateTimeMinLocalPositiveOffset": 1, # Python doesn't support BC time + '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: + missing_features_or_bugs[name] = 1; # https://github.com/Azure/azure-sdk-for-python/pull/9322 + if "Multiapi" in name: + # multiapi 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) + + + def _print_report(self, report, not_supported=None, missing_features_or_bugs=None): + if not_supported: + report.update(not_supported) + for s in not_supported.keys(): + print("IGNORING {0}".format(s)) + + if missing_features_or_bugs: + report.update(missing_features_or_bugs) + for s in missing_features_or_bugs.keys(): + print("PENDING {0}".format(s)) + + failed = [k for k, v in report.items() if v == 0] + for s in failed: + print("FAILED TO EXECUTE {0}".format(s)) + + total_tests = len(report) + warnings.warn ("The test coverage is {0}/{1}.".format(total_tests - len(failed), total_tests)) + + assert 0 == len(failed) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/__init__.py new file mode 100644 index 00000000000..59ee9cbbd8d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/__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 ._additional_properties_client import AdditionalPropertiesClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AdditionalPropertiesClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_additional_properties_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_additional_properties_client.py new file mode 100644 index 00000000000..8517d126884 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_additional_properties_client.py @@ -0,0 +1,91 @@ +# 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 AdditionalPropertiesClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AdditionalPropertiesClient(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AdditionalPropertiesClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `additionalpropertieslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from additionalpropertieslowlevel.rest import pets + >>> request = pets.build_create_ap_true_request(json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AdditionalPropertiesClient + 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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_configuration.py new file mode 100644 index 00000000000..39a60241f8e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_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 AdditionalPropertiesClientConfiguration(Configuration): + """Configuration for AdditionalPropertiesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AdditionalPropertiesClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "additionalpropertiesclient/{}".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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/_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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/__init__.py new file mode 100644 index 00000000000..3482290582e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/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 ._additional_properties_client import AdditionalPropertiesClient + +__all__ = ["AdditionalPropertiesClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/_additional_properties_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/_additional_properties_client.py new file mode 100644 index 00000000000..8d50c5e0c3b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/_additional_properties_client.py @@ -0,0 +1,77 @@ +# 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 AdditionalPropertiesClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AdditionalPropertiesClient: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AdditionalPropertiesClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `additionalpropertieslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from additionalpropertieslowlevel.rest import pets + >>> request = pets.build_create_ap_true_request(json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AdditionalPropertiesClient": + 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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..c431b41cf3a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/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 AdditionalPropertiesClientConfiguration(Configuration): + """Configuration for AdditionalPropertiesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AdditionalPropertiesClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "additionalpropertiesclient/{}".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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/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/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/__init__.py new file mode 100644 index 00000000000..65128f19617 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/__init__.py @@ -0,0 +1,31 @@ +# 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_create_ap_true_request + from ._request_builders_py3 import build_create_cat_ap_true_request + from ._request_builders_py3 import build_create_ap_object_request + from ._request_builders_py3 import build_create_ap_string_request + from ._request_builders_py3 import build_create_ap_in_properties_request + from ._request_builders_py3 import build_create_ap_in_properties_with_ap_string_request +except (SyntaxError, ImportError): + from ._request_builders import build_create_ap_true_request # type: ignore + from ._request_builders import build_create_cat_ap_true_request # type: ignore + from ._request_builders import build_create_ap_object_request # type: ignore + from ._request_builders import build_create_ap_string_request # type: ignore + from ._request_builders import build_create_ap_in_properties_request # type: ignore + from ._request_builders import build_create_ap_in_properties_with_ap_string_request # type: ignore + +__all__ = [ + "build_create_ap_true_request", + "build_create_cat_ap_true_request", + "build_create_ap_object_request", + "build_create_ap_string_request", + "build_create_ap_in_properties_request", + "build_create_ap_in_properties_with_ap_string_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/_request_builders.py new file mode 100644 index 00000000000..760d99eb0bc --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/_request_builders.py @@ -0,0 +1,400 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_create_ap_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/true') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_cat_ap_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a CatAPTrue which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "friendly": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "friendly": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/true-subclass') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/type/object') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "str (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "str (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/type/string') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_in_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/in/properties') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_create_ap_in_properties_with_ap_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "str (optional)" + }, + "@odata.location": "str", + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "str (optional)" + }, + "@odata.location": "str", + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/additionalProperties/in/properties/with/additionalProperties/string') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/_request_builders_py3.py new file mode 100644 index 00000000000..16f4ef86104 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/additionalpropertieslowlevel/rest/pets/_request_builders_py3.py @@ -0,0 +1,349 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_create_ap_true_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/true") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_cat_ap_true_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a CatAPTrue which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "friendly": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "friendly": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/true-subclass") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_object_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "any (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/type/object") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_string_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "str (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "str (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/type/string") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_in_properties_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/in/properties") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_create_ap_in_properties_with_ap_string_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Create a Pet which contains more properties than what is defined. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "": { + "str": "str (optional)" + }, + "@odata.location": "str", + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "": { + "str": "str (optional)" + }, + "@odata.location": "str", + "additionalProperties": { + "str": "float (optional)" + }, + "id": "int", + "name": "str (optional)", + "status": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/additionalProperties/in/properties/with/additionalProperties/string") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/setup.py new file mode 100644 index 00000000000..dd067c7050e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AdditionalPropertiesLowLevel/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 = "additionalpropertiesclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AdditionalPropertiesClient", + author_email="", + url="", + keywords=["Swagger", "AdditionalPropertiesClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/__init__.py new file mode 100644 index 00000000000..a21610becba --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/__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 ._anything_client import AnythingClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AnythingClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_anything_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_anything_client.py new file mode 100644 index 00000000000..adb25c54a81 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_anything_client.py @@ -0,0 +1,91 @@ +# 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 AnythingClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AnythingClient(object): + """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AnythingClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `anythinglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from anythinglowlevel.rest import build_get_object_request + >>> request = build_get_object_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AnythingClient + 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/AnythingLowLevel/anythinglowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_configuration.py new file mode 100644 index 00000000000..20dd340ae21 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_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 AnythingClientConfiguration(Configuration): + """Configuration for AnythingClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AnythingClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "anythingclient/{}".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/AnythingLowLevel/anythinglowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/_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/AnythingLowLevel/anythinglowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/aio/__init__.py new file mode 100644 index 00000000000..44f32de2d0a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/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 ._anything_client import AnythingClient + +__all__ = ["AnythingClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/aio/_anything_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/aio/_anything_client.py new file mode 100644 index 00000000000..f57c2dcc503 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/aio/_anything_client.py @@ -0,0 +1,77 @@ +# 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 AnythingClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AnythingClient: + """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AnythingClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `anythinglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from anythinglowlevel.rest import build_get_object_request + >>> request = build_get_object_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AnythingClient": + 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/AnythingLowLevel/anythinglowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/aio/_configuration.py new file mode 100644 index 00000000000..b5720beca20 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/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 AnythingClientConfiguration(Configuration): + """Configuration for AnythingClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AnythingClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "anythingclient/{}".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/AnythingLowLevel/anythinglowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/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/AnythingLowLevel/anythinglowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/__init__.py new file mode 100644 index 00000000000..cc874f11a17 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/__init__.py @@ -0,0 +1,31 @@ +# 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_get_object_request + from ._request_builders_py3 import build_put_object_request + from ._request_builders_py3 import build_get_string_request + from ._request_builders_py3 import build_put_string_request + from ._request_builders_py3 import build_get_array_request + from ._request_builders_py3 import build_put_array_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_object_request # type: ignore + from ._request_builders import build_put_object_request # type: ignore + from ._request_builders import build_get_string_request # type: ignore + from ._request_builders import build_put_string_request # type: ignore + from ._request_builders import build_get_array_request # type: ignore + from ._request_builders import build_put_array_request # type: ignore + +__all__ = [ + "build_get_object_request", + "build_put_object_request", + "build_get_string_request", + "build_put_string_request", + "build_get_array_request", + "build_put_array_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..b4575e09e9c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/_request_builders.py @@ -0,0 +1,256 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/anything/object') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_object_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/anything/object') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an string as anything. Returns string 'foo'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/anything/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in 'anything' for a 200, anything else for an object + error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in 'anything' for a 200, anything else for an object + error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/anything/string') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/anything/array') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/anything/array') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..f82693f4d82 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/anythinglowlevel/rest/_request_builders_py3.py @@ -0,0 +1,203 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_object_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/anything/object") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_object_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/anything/object") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an string as anything. Returns string 'foo'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/anything/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in 'anything' for a 200, anything else for an object + error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in 'anything' for a 200, anything else for an object + error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/anything/string") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/anything/array") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in ['foo', 'bar'] for a 200, anything else for an + object error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/anything/array") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/setup.py new file mode 100644 index 00000000000..e194649ced4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/AnythingLowLevel/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 = "anythingclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AnythingClient", + author_email="", + url="", + keywords=["Swagger", "AnythingClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/__init__.py new file mode 100644 index 00000000000..190f217ea03 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/__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 ._auto_rest_swagger_bat_array_service import AutoRestSwaggerBATArrayService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATArrayService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_auto_rest_swagger_bat_array_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_auto_rest_swagger_bat_array_service.py new file mode 100644 index 00000000000..f46a2052bba --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_auto_rest_swagger_bat_array_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATArrayServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATArrayService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATArrayServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyarraylowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyarraylowlevel.rest import array + >>> request = array.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATArrayService + 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/BodyArrayLowLevel/bodyarraylowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_configuration.py new file mode 100644 index 00000000000..31838f4dc03 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_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 AutoRestSwaggerBATArrayServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATArrayService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATArrayServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatarrayservice/{}".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/BodyArrayLowLevel/bodyarraylowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/_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/BodyArrayLowLevel/bodyarraylowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/aio/__init__.py new file mode 100644 index 00000000000..e697d2465ee --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/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 ._auto_rest_swagger_bat_array_service import AutoRestSwaggerBATArrayService + +__all__ = ["AutoRestSwaggerBATArrayService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/aio/_auto_rest_swagger_bat_array_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/aio/_auto_rest_swagger_bat_array_service.py new file mode 100644 index 00000000000..7d4780bfc9c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/aio/_auto_rest_swagger_bat_array_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATArrayServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATArrayService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATArrayServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyarraylowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyarraylowlevel.rest import array + >>> request = array.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATArrayService": + 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/BodyArrayLowLevel/bodyarraylowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/aio/_configuration.py new file mode 100644 index 00000000000..99fd3c7c6ab --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/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 AutoRestSwaggerBATArrayServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATArrayService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATArrayServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatarrayservice/{}".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/BodyArrayLowLevel/bodyarraylowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/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/BodyArrayLowLevel/bodyarraylowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/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/BodyArrayLowLevel/bodyarraylowlevel/rest/array/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/__init__.py new file mode 100644 index 00000000000..a715b62d9ae --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/__init__.py @@ -0,0 +1,220 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_boolean_tfft_request + from ._request_builders_py3 import build_put_boolean_tfft_request + from ._request_builders_py3 import build_get_boolean_invalid_null_request + from ._request_builders_py3 import build_get_boolean_invalid_string_request + from ._request_builders_py3 import build_get_integer_valid_request + from ._request_builders_py3 import build_put_integer_valid_request + from ._request_builders_py3 import build_get_int_invalid_null_request + from ._request_builders_py3 import build_get_int_invalid_string_request + from ._request_builders_py3 import build_get_long_valid_request + from ._request_builders_py3 import build_put_long_valid_request + from ._request_builders_py3 import build_get_long_invalid_null_request + from ._request_builders_py3 import build_get_long_invalid_string_request + from ._request_builders_py3 import build_get_float_valid_request + from ._request_builders_py3 import build_put_float_valid_request + from ._request_builders_py3 import build_get_float_invalid_null_request + from ._request_builders_py3 import build_get_float_invalid_string_request + from ._request_builders_py3 import build_get_double_valid_request + from ._request_builders_py3 import build_put_double_valid_request + from ._request_builders_py3 import build_get_double_invalid_null_request + from ._request_builders_py3 import build_get_double_invalid_string_request + from ._request_builders_py3 import build_get_string_valid_request + from ._request_builders_py3 import build_put_string_valid_request + from ._request_builders_py3 import build_get_enum_valid_request + from ._request_builders_py3 import build_put_enum_valid_request + from ._request_builders_py3 import build_get_string_enum_valid_request + from ._request_builders_py3 import build_put_string_enum_valid_request + from ._request_builders_py3 import build_get_string_with_null_request + from ._request_builders_py3 import build_get_string_with_invalid_request + from ._request_builders_py3 import build_get_uuid_valid_request + from ._request_builders_py3 import build_put_uuid_valid_request + from ._request_builders_py3 import build_get_uuid_invalid_chars_request + from ._request_builders_py3 import build_get_date_valid_request + from ._request_builders_py3 import build_put_date_valid_request + from ._request_builders_py3 import build_get_date_invalid_null_request + from ._request_builders_py3 import build_get_date_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_valid_request + from ._request_builders_py3 import build_put_date_time_valid_request + from ._request_builders_py3 import build_get_date_time_invalid_null_request + from ._request_builders_py3 import build_get_date_time_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_put_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_get_duration_valid_request + from ._request_builders_py3 import build_put_duration_valid_request + from ._request_builders_py3 import build_get_byte_valid_request + from ._request_builders_py3 import build_put_byte_valid_request + from ._request_builders_py3 import build_get_byte_invalid_null_request + from ._request_builders_py3 import build_get_base64_url_request + from ._request_builders_py3 import build_get_complex_null_request + from ._request_builders_py3 import build_get_complex_empty_request + from ._request_builders_py3 import build_get_complex_item_null_request + from ._request_builders_py3 import build_get_complex_item_empty_request + from ._request_builders_py3 import build_get_complex_valid_request + from ._request_builders_py3 import build_put_complex_valid_request + from ._request_builders_py3 import build_get_array_null_request + from ._request_builders_py3 import build_get_array_empty_request + from ._request_builders_py3 import build_get_array_item_null_request + from ._request_builders_py3 import build_get_array_item_empty_request + from ._request_builders_py3 import build_get_array_valid_request + from ._request_builders_py3 import build_put_array_valid_request + from ._request_builders_py3 import build_get_dictionary_null_request + from ._request_builders_py3 import build_get_dictionary_empty_request + from ._request_builders_py3 import build_get_dictionary_item_null_request + from ._request_builders_py3 import build_get_dictionary_item_empty_request + from ._request_builders_py3 import build_get_dictionary_valid_request + from ._request_builders_py3 import build_put_dictionary_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_boolean_tfft_request # type: ignore + from ._request_builders import build_put_boolean_tfft_request # type: ignore + from ._request_builders import build_get_boolean_invalid_null_request # type: ignore + from ._request_builders import build_get_boolean_invalid_string_request # type: ignore + from ._request_builders import build_get_integer_valid_request # type: ignore + from ._request_builders import build_put_integer_valid_request # type: ignore + from ._request_builders import build_get_int_invalid_null_request # type: ignore + from ._request_builders import build_get_int_invalid_string_request # type: ignore + from ._request_builders import build_get_long_valid_request # type: ignore + from ._request_builders import build_put_long_valid_request # type: ignore + from ._request_builders import build_get_long_invalid_null_request # type: ignore + from ._request_builders import build_get_long_invalid_string_request # type: ignore + from ._request_builders import build_get_float_valid_request # type: ignore + from ._request_builders import build_put_float_valid_request # type: ignore + from ._request_builders import build_get_float_invalid_null_request # type: ignore + from ._request_builders import build_get_float_invalid_string_request # type: ignore + from ._request_builders import build_get_double_valid_request # type: ignore + from ._request_builders import build_put_double_valid_request # type: ignore + from ._request_builders import build_get_double_invalid_null_request # type: ignore + from ._request_builders import build_get_double_invalid_string_request # type: ignore + from ._request_builders import build_get_string_valid_request # type: ignore + from ._request_builders import build_put_string_valid_request # type: ignore + from ._request_builders import build_get_enum_valid_request # type: ignore + from ._request_builders import build_put_enum_valid_request # type: ignore + from ._request_builders import build_get_string_enum_valid_request # type: ignore + from ._request_builders import build_put_string_enum_valid_request # type: ignore + from ._request_builders import build_get_string_with_null_request # type: ignore + from ._request_builders import build_get_string_with_invalid_request # type: ignore + from ._request_builders import build_get_uuid_valid_request # type: ignore + from ._request_builders import build_put_uuid_valid_request # type: ignore + from ._request_builders import build_get_uuid_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_valid_request # type: ignore + from ._request_builders import build_put_date_valid_request # type: ignore + from ._request_builders import build_get_date_invalid_null_request # type: ignore + from ._request_builders import build_get_date_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_valid_request # type: ignore + from ._request_builders import build_put_date_time_valid_request # type: ignore + from ._request_builders import build_get_date_time_invalid_null_request # type: ignore + from ._request_builders import build_get_date_time_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_get_duration_valid_request # type: ignore + from ._request_builders import build_put_duration_valid_request # type: ignore + from ._request_builders import build_get_byte_valid_request # type: ignore + from ._request_builders import build_put_byte_valid_request # type: ignore + from ._request_builders import build_get_byte_invalid_null_request # type: ignore + from ._request_builders import build_get_base64_url_request # type: ignore + from ._request_builders import build_get_complex_null_request # type: ignore + from ._request_builders import build_get_complex_empty_request # type: ignore + from ._request_builders import build_get_complex_item_null_request # type: ignore + from ._request_builders import build_get_complex_item_empty_request # type: ignore + from ._request_builders import build_get_complex_valid_request # type: ignore + from ._request_builders import build_put_complex_valid_request # type: ignore + from ._request_builders import build_get_array_null_request # type: ignore + from ._request_builders import build_get_array_empty_request # type: ignore + from ._request_builders import build_get_array_item_null_request # type: ignore + from ._request_builders import build_get_array_item_empty_request # type: ignore + from ._request_builders import build_get_array_valid_request # type: ignore + from ._request_builders import build_put_array_valid_request # type: ignore + from ._request_builders import build_get_dictionary_null_request # type: ignore + from ._request_builders import build_get_dictionary_empty_request # type: ignore + from ._request_builders import build_get_dictionary_item_null_request # type: ignore + from ._request_builders import build_get_dictionary_item_empty_request # type: ignore + from ._request_builders import build_get_dictionary_valid_request # type: ignore + from ._request_builders import build_put_dictionary_valid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_boolean_tfft_request", + "build_put_boolean_tfft_request", + "build_get_boolean_invalid_null_request", + "build_get_boolean_invalid_string_request", + "build_get_integer_valid_request", + "build_put_integer_valid_request", + "build_get_int_invalid_null_request", + "build_get_int_invalid_string_request", + "build_get_long_valid_request", + "build_put_long_valid_request", + "build_get_long_invalid_null_request", + "build_get_long_invalid_string_request", + "build_get_float_valid_request", + "build_put_float_valid_request", + "build_get_float_invalid_null_request", + "build_get_float_invalid_string_request", + "build_get_double_valid_request", + "build_put_double_valid_request", + "build_get_double_invalid_null_request", + "build_get_double_invalid_string_request", + "build_get_string_valid_request", + "build_put_string_valid_request", + "build_get_enum_valid_request", + "build_put_enum_valid_request", + "build_get_string_enum_valid_request", + "build_put_string_enum_valid_request", + "build_get_string_with_null_request", + "build_get_string_with_invalid_request", + "build_get_uuid_valid_request", + "build_put_uuid_valid_request", + "build_get_uuid_invalid_chars_request", + "build_get_date_valid_request", + "build_put_date_valid_request", + "build_get_date_invalid_null_request", + "build_get_date_invalid_chars_request", + "build_get_date_time_valid_request", + "build_put_date_time_valid_request", + "build_get_date_time_invalid_null_request", + "build_get_date_time_invalid_chars_request", + "build_get_date_time_rfc1123_valid_request", + "build_put_date_time_rfc1123_valid_request", + "build_get_duration_valid_request", + "build_put_duration_valid_request", + "build_get_byte_valid_request", + "build_put_byte_valid_request", + "build_get_byte_invalid_null_request", + "build_get_base64_url_request", + "build_get_complex_null_request", + "build_get_complex_empty_request", + "build_get_complex_item_null_request", + "build_get_complex_item_empty_request", + "build_get_complex_valid_request", + "build_put_complex_valid_request", + "build_get_array_null_request", + "build_get_array_empty_request", + "build_get_array_item_null_request", + "build_get_array_item_empty_request", + "build_get_array_valid_request", + "build_put_array_valid_request", + "build_get_dictionary_null_request", + "build_get_dictionary_empty_request", + "build_get_dictionary_item_null_request", + "build_get_dictionary_item_empty_request", + "build_get_dictionary_valid_request", + "build_put_dictionary_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/_request_builders.py new file mode 100644 index 00000000000..3283a2aab3c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/_request_builders.py @@ -0,0 +1,2949 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null array value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid array [1, 2, 3. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty array value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bool (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/tfft') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "bool (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/tfft') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, null, false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bool (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/true.null.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [true, 'boolean', false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bool (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/boolean/true.boolean.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "int (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/integer/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "long (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "long (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "long (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "long (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/long/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "float (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/float/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "float (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/double/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/enum/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/enum/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string-enum/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string-enum/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo', null, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo.null.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string array value ['foo', 123, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/string/foo.123.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uuid_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_uuid_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uuid_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/uuid/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "date (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "date (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2012-01-01', null, '1776-07-04']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "date (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2011-03-22', 'date']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "date (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "datetime (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2000-12-01t00:00:01z', null]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time-rfc1123/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "datetime (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/date-time-rfc1123/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "timedelta (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/duration/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "timedelta (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/duration/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bytearray (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "bytearray (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bytearray (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/byte/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bytes (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/prim/base64url/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty array of complex type []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/complex/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + [ + "str (optional)" + ] + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "str": "str (optional)" + } + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/array/dictionary/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/_request_builders_py3.py new file mode 100644 index 00000000000..230e7c18eb7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/bodyarraylowlevel/rest/array/_request_builders_py3.py @@ -0,0 +1,2392 @@ +# 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 datetime +from typing import Any, Dict, List, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null array value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid array [1, 2, 3. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty array value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_tfft_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bool (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/tfft") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_boolean_tfft_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [true, false, false, true]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "bool (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/tfft") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, null, false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bool (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/true.null.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [true, 'boolean', false]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bool (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/boolean/true.boolean.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_integer_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_integer_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "int (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_int_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "int (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/integer/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "long (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value empty [1, -1, 3, 300]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "long (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get long array value [1, null, 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "long (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get long array value [1, 'integer', 0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "long (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/long/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_valid_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "float (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/float/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_valid_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value [0, -0.01, 1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "float (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float array value [0.0, null, -1.2e20]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean array value [1.0, 'number', 0.0]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "float (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/double/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_valid_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_enum_valid_request(**kwargs: Any) -> HttpRequest: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/enum/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_enum_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/enum/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_enum_valid_request(**kwargs: Any) -> HttpRequest: + """Get enum array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string-enum/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_enum_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['foo1', 'foo2', 'foo3']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string-enum/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_with_null_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo', null, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo.null.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_with_invalid_request(**kwargs: Any) -> HttpRequest: + """Get string array value ['foo', 123, 'foo2']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/string/foo.123.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_uuid_valid_request(**kwargs: Any) -> HttpRequest: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_uuid_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', + 'd1399005-30f7-40d6-8da6-dd7c89ad34db', 'f42f6aa1-a5bc-4ddf-907e-5f915de43205']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_uuid_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/uuid/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "date (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['2000-12-01', '1980-01-02', '1492-10-12']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "date (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2012-01-01', null, '1776-07-04']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "date (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2011-03-22', 'date']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "date (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', + '1492-10-12T10:15:01-08:00']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "datetime (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2000-12-01t00:00:01z', null]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date array value ['2000-12-01t00:00:01z', 'date-time']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_rfc1123_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', + 'Wed, 12 Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "datetime (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time-rfc1123/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 + Oct 1492 10:15:01 GMT']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "datetime (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/date-time-rfc1123/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_valid_request(**kwargs: Any) -> HttpRequest: + """Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "timedelta (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/duration/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S']. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "timedelta (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/duration/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_valid_request(**kwargs: Any) -> HttpRequest: + """Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded + in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bytearray (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each + elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "bytearray (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bytearray (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/byte/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_request(**kwargs: Any) -> HttpRequest: + """Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with + the items base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + "bytes (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/prim/base64url/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_null_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty array of complex type []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_null_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, + 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_valid_request(**kwargs: Any) -> HttpRequest: + """Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, + {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, + 'string': '4'}, {'integer': 5, 'string': '6'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "integer": "int (optional)", + "string": "str (optional)" + } + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/complex/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_null_request(**kwargs: Any) -> HttpRequest: + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_empty_request(**kwargs: Any) -> HttpRequest: + """Get an empty array []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + [ + "str (optional)" + ] + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + [ + "str (optional)" + ] + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value []. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, null, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "str": "str (optional)" + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': + 'three'}, {'4': 'four', '5': 'five', '6': 'six'}, {'7': 'seven', '8': 'eight', '9': 'nine'}]. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "str": "str (optional)" + } + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/array/dictionary/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/setup.py new file mode 100644 index 00000000000..91869cd4bbe --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyArrayLowLevel/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 = "autorestswaggerbatarrayservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATArrayService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATArrayService"], + 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/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/__init__.py new file mode 100644 index 00000000000..256cf61c086 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/__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 ._auto_rest_bool_test_service import AutoRestBoolTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestBoolTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_auto_rest_bool_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_auto_rest_bool_test_service.py new file mode 100644 index 00000000000..bf859a66d1c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_auto_rest_bool_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestBoolTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestBoolTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestBoolTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodybooleanlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybooleanlowlevel.rest import bool + >>> request = bool.build_get_true_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestBoolTestService + 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/BodyBooleanLowLevel/bodybooleanlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_configuration.py new file mode 100644 index 00000000000..db8c41b81b2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_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 AutoRestBoolTestServiceConfiguration(Configuration): + """Configuration for AutoRestBoolTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestBoolTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestbooltestservice/{}".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/BodyBooleanLowLevel/bodybooleanlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/_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/BodyBooleanLowLevel/bodybooleanlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/aio/__init__.py new file mode 100644 index 00000000000..e2ea692d64e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/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 ._auto_rest_bool_test_service import AutoRestBoolTestService + +__all__ = ["AutoRestBoolTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/aio/_auto_rest_bool_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/aio/_auto_rest_bool_test_service.py new file mode 100644 index 00000000000..3ffacfa65f4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/aio/_auto_rest_bool_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestBoolTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestBoolTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestBoolTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodybooleanlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybooleanlowlevel.rest import bool + >>> request = bool.build_get_true_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestBoolTestService": + 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/BodyBooleanLowLevel/bodybooleanlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..759e32fbf2e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/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 AutoRestBoolTestServiceConfiguration(Configuration): + """Configuration for AutoRestBoolTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestBoolTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestbooltestservice/{}".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/BodyBooleanLowLevel/bodybooleanlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/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/BodyBooleanLowLevel/bodybooleanlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/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/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/__init__.py new file mode 100644 index 00000000000..a4fff07ee74 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/__init__.py @@ -0,0 +1,31 @@ +# 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_get_true_request + from ._request_builders_py3 import build_put_true_request + from ._request_builders_py3 import build_get_false_request + from ._request_builders_py3 import build_put_false_request + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_true_request # type: ignore + from ._request_builders import build_put_true_request # type: ignore + from ._request_builders import build_get_false_request # type: ignore + from ._request_builders import build_put_false_request # type: ignore + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_true_request", + "build_put_true_request", + "build_get_false_request", + "build_put_false_request", + "build_get_null_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/_request_builders.py new file mode 100644 index 00000000000..36751ee14b5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/_request_builders.py @@ -0,0 +1,236 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/true') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set Boolean value true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/true') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get false Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set Boolean value false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/false') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/bool/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/_request_builders_py3.py new file mode 100644 index 00000000000..ed359dc12ed --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/bodybooleanlowlevel/rest/bool/_request_builders_py3.py @@ -0,0 +1,183 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_true_request(**kwargs: Any) -> HttpRequest: + """Get true Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/true") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_true_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set Boolean value true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/true") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_false_request(**kwargs: Any) -> HttpRequest: + """Get false Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_false_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set Boolean value false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/false") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid Boolean value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/bool/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/setup.py new file mode 100644 index 00000000000..4710c12d52d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyBooleanLowLevel/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 = "autorestbooltestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestBoolTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestBoolTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/__init__.py new file mode 100644 index 00000000000..f60315f8034 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/__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 ._auto_rest_swagger_bat_byte_service import AutoRestSwaggerBATByteService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATByteService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_auto_rest_swagger_bat_byte_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_auto_rest_swagger_bat_byte_service.py new file mode 100644 index 00000000000..b5566458f7a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_auto_rest_swagger_bat_byte_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATByteServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATByteService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATByteServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodybytelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybytelowlevel.rest import byte + >>> request = byte.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATByteService + 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/BodyByteLowLevel/bodybytelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_configuration.py new file mode 100644 index 00000000000..ff076785142 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_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 AutoRestSwaggerBATByteServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATByteService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATByteServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatbyteservice/{}".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/BodyByteLowLevel/bodybytelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/_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/BodyByteLowLevel/bodybytelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/aio/__init__.py new file mode 100644 index 00000000000..73629ef64cc --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/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 ._auto_rest_swagger_bat_byte_service import AutoRestSwaggerBATByteService + +__all__ = ["AutoRestSwaggerBATByteService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/aio/_auto_rest_swagger_bat_byte_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/aio/_auto_rest_swagger_bat_byte_service.py new file mode 100644 index 00000000000..0bedc77e190 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/aio/_auto_rest_swagger_bat_byte_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATByteServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATByteService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATByteServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodybytelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodybytelowlevel.rest import byte + >>> request = byte.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATByteService": + 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/BodyByteLowLevel/bodybytelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..9262696cc4f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/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 AutoRestSwaggerBATByteServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATByteService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATByteServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatbyteservice/{}".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/BodyByteLowLevel/bodybytelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/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/BodyByteLowLevel/bodybytelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/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/BodyByteLowLevel/bodybytelowlevel/rest/byte/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/__init__.py new file mode 100644 index 00000000000..9fdaa4a2115 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/__init__.py @@ -0,0 +1,28 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_get_non_ascii_request + from ._request_builders_py3 import build_put_non_ascii_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_get_non_ascii_request # type: ignore + from ._request_builders import build_put_non_ascii_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_empty_request", + "build_get_non_ascii_request", + "build_put_non_ascii_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/_request_builders.py new file mode 100644 index 00000000000..65c5d6c1130 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/_request_builders.py @@ -0,0 +1,191 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null byte value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty byte value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_non_ascii_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/nonAscii') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_non_ascii_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bytearray (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/nonAscii') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid byte value ':::SWAGGER::::'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/byte/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/_request_builders_py3.py new file mode 100644 index 00000000000..9706522a6b1 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/bodybytelowlevel/rest/byte/_request_builders_py3.py @@ -0,0 +1,146 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null byte value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty byte value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_non_ascii_request(**kwargs: Any) -> HttpRequest: + """Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/nonAscii") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_non_ascii_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Base64-encoded non-ascii byte string hex(FF FE FD FC FB FA + F9 F8 F7 F6). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bytearray (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/nonAscii") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid byte value ':::SWAGGER::::'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/byte/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/setup.py new file mode 100644 index 00000000000..7d370392696 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyByteLowLevel/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 = "autorestswaggerbatbyteservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATByteService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATByteService"], + 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/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/__init__.py new file mode 100644 index 00000000000..0a4e9592113 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/__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 ._auto_rest_complex_test_service import AutoRestComplexTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestComplexTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_auto_rest_complex_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_auto_rest_complex_test_service.py new file mode 100644 index 00000000000..1fd035f7043 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_auto_rest_complex_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestComplexTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestComplexTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestComplexTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodycomplexlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodycomplexlowlevel.rest import basic + >>> request = basic.build_get_valid_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestComplexTestService + 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/BodyComplexLowLevel/bodycomplexlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_configuration.py new file mode 100644 index 00000000000..191dd324133 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_configuration.py @@ -0,0 +1,51 @@ +# 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 AutoRestComplexTestServiceConfiguration(Configuration): + """Configuration for AutoRestComplexTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestComplexTestServiceConfiguration, self).__init__(**kwargs) + + self.api_version = "2016-02-29" + kwargs.setdefault("sdk_moniker", "autorestcomplextestservice/{}".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/BodyComplexLowLevel/bodycomplexlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/_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/BodyComplexLowLevel/bodycomplexlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/aio/__init__.py new file mode 100644 index 00000000000..6d4a74e4674 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/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 ._auto_rest_complex_test_service import AutoRestComplexTestService + +__all__ = ["AutoRestComplexTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/aio/_auto_rest_complex_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/aio/_auto_rest_complex_test_service.py new file mode 100644 index 00000000000..12aa5705aef --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/aio/_auto_rest_complex_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestComplexTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestComplexTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestComplexTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodycomplexlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodycomplexlowlevel.rest import basic + >>> request = basic.build_get_valid_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestComplexTestService": + 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/BodyComplexLowLevel/bodycomplexlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..123b229d719 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/aio/_configuration.py @@ -0,0 +1,41 @@ +# 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 AutoRestComplexTestServiceConfiguration(Configuration): + """Configuration for AutoRestComplexTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestComplexTestServiceConfiguration, self).__init__(**kwargs) + + self.api_version = "2016-02-29" + kwargs.setdefault("sdk_moniker", "autorestcomplextestservice/{}".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/BodyComplexLowLevel/bodycomplexlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/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/BodyComplexLowLevel/bodycomplexlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/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/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/__init__.py new file mode 100644 index 00000000000..11147632432 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/__init__.py @@ -0,0 +1,28 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_not_provided_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_not_provided_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/_request_builders.py new file mode 100644 index 00000000000..e77974ba988 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/_request_builders.py @@ -0,0 +1,245 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "array": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "array": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "array": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty array. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty array. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "array": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with array property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "array": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/array/notprovided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/_request_builders_py3.py new file mode 100644 index 00000000000..dc5b4b80daa --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/array/_request_builders_py3.py @@ -0,0 +1,200 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "array": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with array property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an array with 4 items: "1, 2, 3, 4", "", null, + "&S#$(*Y", "The quick brown fox jumps over the lazy dog". + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "array": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "array": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with array property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty array. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty array. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "array": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get complex types with array property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "array": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/array/notprovided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/__init__.py new file mode 100644 index 00000000000..2ea66984c02 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/__init__.py @@ -0,0 +1,31 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_not_provided_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_invalid_request", + "build_get_empty_request", + "build_get_null_request", + "build_get_not_provided_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/_request_builders.py new file mode 100644 index 00000000000..a98f11ac103 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/_request_builders.py @@ -0,0 +1,280 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Please put {id: 2, name: 'abc', color: 'Magenta'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put {id: 2, name: 'abc', color: 'Magenta'}. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put {id: 2, name: 'abc', color: 'Magenta'}. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-29" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type that is invalid for the local strong type. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type that is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type whose properties are null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a basic complex type while the server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/basic/notprovided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/_request_builders_py3.py new file mode 100644 index 00000000000..c63558ac3f5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/basic/_request_builders_py3.py @@ -0,0 +1,228 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex type {id: 2, name: 'abc', color: 'YELLOW'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Please put {id: 2, name: 'abc', color: 'Magenta'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put {id: 2, name: 'abc', color: 'Magenta'}. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put {id: 2, name: 'abc', color: 'Magenta'}. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "2016-02-29" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type that is invalid for the local strong type. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type that is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type whose properties are null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get a basic complex type while the server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "color": "str (optional)", + "id": "int (optional)", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/basic/notprovided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/__init__.py new file mode 100644 index 00000000000..9d06b6a145a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/__init__.py @@ -0,0 +1,31 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_not_provided_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_null_request", + "build_get_not_provided_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/_request_builders.py new file mode 100644 index 00000000000..00227a1d9b8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/_request_builders.py @@ -0,0 +1,286 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty dictionary. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty dictionary. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property which is null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with dictionary property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/dictionary/typed/notprovided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/_request_builders_py3.py new file mode 100644 index 00000000000..8494b01a9c5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/dictionary/_request_builders_py3.py @@ -0,0 +1,233 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with dictionary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a dictionary with 5 key-value pairs: + "txt":"notepad", "bmp":"mspaint", "xls":"excel", "exe":"", "":null. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with dictionary property which is empty. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put an empty dictionary. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put an empty dictionary. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property which is null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get complex types with dictionary property while server doesn't provide a response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "defaultProgram": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/dictionary/typed/notprovided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/__init__.py new file mode 100644 index 00000000000..37b2d0a112d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/__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_get_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/_request_builders.py new file mode 100644 index 00000000000..13132c7e08c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/_request_builders.py @@ -0,0 +1,61 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """get_valid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "helper": { + "propBH1": "str (optional)" + }, + "kind": "kind", + "propB1": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/flatten/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/_request_builders_py3.py new file mode 100644 index 00000000000..18d9acc87d9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/flattencomplex/_request_builders_py3.py @@ -0,0 +1,48 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """get_valid. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "helper": { + "propBH1": "str (optional)" + }, + "kind": "kind", + "propB1": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/flatten/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/__init__.py new file mode 100644 index 00000000000..83d94e4e60b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/__init__.py @@ -0,0 +1,19 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/_request_builders.py new file mode 100644 index 00000000000..2cd7ce59041 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/_request_builders.py @@ -0,0 +1,110 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "breed": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/inheritance/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a siamese with id=2, name="Siameee", + color=green, breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and + food="tomato", and the 2nd one named "Tomato" with id=-1 and food="french fries". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a siamese with id=2, name="Siameee", color=green, + breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and + the 2nd one named "Tomato" with id=-1 and food="french fries". + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "breed": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/inheritance/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/_request_builders_py3.py new file mode 100644 index 00000000000..465a8995886 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/inheritance/_request_builders_py3.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 typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "breed": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/inheritance/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that extend others. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a siamese with id=2, name="Siameee", + color=green, breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and + food="tomato", and the 2nd one named "Tomato" with id=-1 and food="french fries". + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a siamese with id=2, name="Siameee", color=green, + breed=persion, which hates 2 dogs, the 1st one named "Potato" with id=1 and food="tomato", and + the 2nd one named "Tomato" with id=-1 and food="french fries". + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "breed": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/inheritance/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/__init__.py new file mode 100644 index 00000000000..83d94e4e60b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/__init__.py @@ -0,0 +1,19 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/_request_builders.py new file mode 100644 index 00000000000..d43d1db412c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/_request_builders.py @@ -0,0 +1,222 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphicrecursive/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :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 + + fishtype = 'Salmon' or 'Shark' + + # JSON input template you can fill out and use as your `json` input. + json = { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphicrecursive/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/_request_builders_py3.py new file mode 100644 index 00000000000..0c1ae8b5f4f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphicrecursive/_request_builders_py3.py @@ -0,0 +1,201 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphicrecursive/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic and have recursive references. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + "fishtype": "salmon", + "species": "king", + "length": 1, + "age": 1, + "location": "alaska", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6, + "siblings": [ + { + "fishtype": "salmon", + "species": "coho", + "length": 2, + "age": 2, + "location": "atlantic", + "iswild": true, + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "length": 10, + "age": 105 + } + ] + }. + :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 + + fishtype = 'Salmon' or 'Shark' + + # JSON input template you can fill out and use as your `json` input. + json = { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphicrecursive/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/__init__.py new file mode 100644 index 00000000000..3ea2d60203f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/__init__.py @@ -0,0 +1,40 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request + from ._request_builders_py3 import build_get_dot_syntax_request + from ._request_builders_py3 import build_get_composed_with_discriminator_request + from ._request_builders_py3 import build_get_composed_without_discriminator_request + from ._request_builders_py3 import build_get_complicated_request + from ._request_builders_py3 import build_put_complicated_request + from ._request_builders_py3 import build_put_missing_discriminator_request + from ._request_builders_py3 import build_put_valid_missing_required_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + from ._request_builders import build_get_dot_syntax_request # type: ignore + from ._request_builders import build_get_composed_with_discriminator_request # type: ignore + from ._request_builders import build_get_composed_without_discriminator_request # type: ignore + from ._request_builders import build_get_complicated_request # type: ignore + from ._request_builders import build_put_complicated_request # type: ignore + from ._request_builders import build_put_missing_discriminator_request # type: ignore + from ._request_builders import build_put_valid_missing_required_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", + "build_get_dot_syntax_request", + "build_get_composed_with_discriminator_request", + "build_get_composed_without_discriminator_request", + "build_get_complicated_request", + "build_put_complicated_request", + "build_put_missing_discriminator_request", + "build_put_valid_missing_required_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/_request_builders.py new file mode 100644 index 00000000000..d5029a1886f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/_request_builders.py @@ -0,0 +1,603 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :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 + + fishtype = 'Salmon' or 'Shark' + + # JSON input template you can fill out and use as your `json` input. + json = { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dot_syntax_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic, JSON key contains a dot. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fish.type": "fish.type", + "species": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/dotsyntax') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_composed_with_discriminator_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, with discriminator specified. Deserialization must NOT fail and use the + discriminator type specified on the wire. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishes": [ + { + "fish.type": "fish.type", + "species": "str (optional)" + } + ], + "salmons": [ + { + "iswild": "bool (optional)", + "location": "str (optional)" + } + ], + "sampleFish": { + "fish.type": "fish.type", + "species": "str (optional)" + }, + "sampleSalmon": { + "iswild": "bool (optional)", + "location": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/composedWithDiscriminator') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_composed_without_discriminator_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, without discriminator specified on wire. Deserialization must NOT fail and use + the explicit type of the property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishes": [ + { + "fish.type": "fish.type", + "species": "str (optional)" + } + ], + "salmons": [ + { + "iswild": "bool (optional)", + "location": "str (optional)" + } + ], + "sampleFish": { + "fish.type": "fish.type", + "species": "str (optional)" + }, + "sampleSalmon": { + "iswild": "bool (optional)", + "location": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/composedWithoutDiscriminator') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complicated_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "iswild": "bool (optional)", + "location": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/complicated') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complicated_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + fishtype = 'SmartSalmon' + + # JSON input template you can fill out and use as your `json` input. + json = { + "iswild": "bool (optional)", + "location": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/complicated') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_missing_discriminator_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic, omitting the discriminator. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + fishtype = 'SmartSalmon' + + # JSON input template you can fill out and use as your `json` input. + json = { + "iswild": "bool (optional)", + "location": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "iswild": "bool (optional)", + "location": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/missingdiscriminator') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_missing_required_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the + request should not be allowed from the client. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :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 + + fishtype = 'Salmon' or 'Shark' + + # JSON input template you can fill out and use as your `json` input. + json = { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/polymorphism/missingrequired/invalid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/_request_builders_py3.py new file mode 100644 index 00000000000..c4859fd5ab0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/polymorphism/_request_builders_py3.py @@ -0,0 +1,526 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put a salmon that looks like this: + { + 'fishtype':'Salmon', + 'location':'alaska', + 'iswild':true, + 'species':'king', + 'length':1.0, + 'siblings':[ + { + 'fishtype':'Shark', + 'age':6, + 'birthday': '2012-01-05T01:00:00Z', + 'length':20.0, + 'species':'predator', + }, + { + 'fishtype':'Sawshark', + 'age':105, + 'birthday': '1900-01-05T01:00:00Z', + 'length':10.0, + 'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'), + 'species':'dangerous', + }, + { + 'fishtype': 'goblin', + 'age': 1, + 'birthday': '2015-08-08T00:00:00Z', + 'length': 30.0, + 'species': 'scary', + 'jawsize': 5 + } + ] + };. + :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 + + fishtype = 'Salmon' or 'Shark' + + # JSON input template you can fill out and use as your `json` input. + json = { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dot_syntax_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic, JSON key contains a dot. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fish.type": "fish.type", + "species": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/dotsyntax") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_composed_with_discriminator_request(**kwargs: Any) -> HttpRequest: + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, with discriminator specified. Deserialization must NOT fail and use the + discriminator type specified on the wire. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishes": [ + { + "fish.type": "fish.type", + "species": "str (optional)" + } + ], + "salmons": [ + { + "iswild": "bool (optional)", + "location": "str (optional)" + } + ], + "sampleFish": { + "fish.type": "fish.type", + "species": "str (optional)" + }, + "sampleSalmon": { + "iswild": "bool (optional)", + "location": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/composedWithDiscriminator") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_composed_without_discriminator_request(**kwargs: Any) -> HttpRequest: + """Get complex object composing a polymorphic scalar property and array property with polymorphic + element type, without discriminator specified on wire. Deserialization must NOT fail and use + the explicit type of the property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "fishes": [ + { + "fish.type": "fish.type", + "species": "str (optional)" + } + ], + "salmons": [ + { + "iswild": "bool (optional)", + "location": "str (optional)" + } + ], + "sampleFish": { + "fish.type": "fish.type", + "species": "str (optional)" + }, + "sampleSalmon": { + "iswild": "bool (optional)", + "location": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/composedWithoutDiscriminator") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complicated_request(**kwargs: Any) -> HttpRequest: + """Get complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "iswild": "bool (optional)", + "location": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/complicated") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complicated_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic, but not at the root of the hierarchy; also have + additional properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + fishtype = 'SmartSalmon' + + # JSON input template you can fill out and use as your `json` input. + json = { + "iswild": "bool (optional)", + "location": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/complicated") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_missing_discriminator_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic, omitting the discriminator. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + fishtype = 'SmartSalmon' + + # JSON input template you can fill out and use as your `json` input. + json = { + "iswild": "bool (optional)", + "location": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "iswild": "bool (optional)", + "location": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/missingdiscriminator") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_valid_missing_required_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that are polymorphic, attempting to omit required 'birthday' field - the + request should not be allowed from the client. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please attempt put a sawshark that looks like this, the + client should not allow this data to be sent: + { + "fishtype": "sawshark", + "species": "snaggle toothed", + "length": 18.5, + "age": 2, + "birthday": "2013-06-01T01:00:00Z", + "location": "alaska", + "picture": base64(FF FF FF FF FE), + "siblings": [ + { + "fishtype": "shark", + "species": "predator", + "birthday": "2012-01-05T01:00:00Z", + "length": 20, + "age": 6 + }, + { + "fishtype": "sawshark", + "species": "dangerous", + "picture": base64(FF FF FF FF FE), + "length": 10, + "age": 105 + } + ] + }. + :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 + + fishtype = 'Salmon' or 'Shark' + + # JSON input template you can fill out and use as your `json` input. + json = { + "fishtype": "fishtype", + "length": "float", + "siblings": [ + "..." + ], + "species": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/polymorphism/missingrequired/invalid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/__init__.py new file mode 100644 index 00000000000..4de6eb2c665 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/__init__.py @@ -0,0 +1,79 @@ +# 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_get_int_request + from ._request_builders_py3 import build_put_int_request + from ._request_builders_py3 import build_get_long_request + from ._request_builders_py3 import build_put_long_request + from ._request_builders_py3 import build_get_float_request + from ._request_builders_py3 import build_put_float_request + from ._request_builders_py3 import build_get_double_request + from ._request_builders_py3 import build_put_double_request + from ._request_builders_py3 import build_get_bool_request + from ._request_builders_py3 import build_put_bool_request + from ._request_builders_py3 import build_get_string_request + from ._request_builders_py3 import build_put_string_request + from ._request_builders_py3 import build_get_date_request + from ._request_builders_py3 import build_put_date_request + from ._request_builders_py3 import build_get_date_time_request + from ._request_builders_py3 import build_put_date_time_request + from ._request_builders_py3 import build_get_date_time_rfc1123_request + from ._request_builders_py3 import build_put_date_time_rfc1123_request + from ._request_builders_py3 import build_get_duration_request + from ._request_builders_py3 import build_put_duration_request + from ._request_builders_py3 import build_get_byte_request + from ._request_builders_py3 import build_put_byte_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_int_request # type: ignore + from ._request_builders import build_put_int_request # type: ignore + from ._request_builders import build_get_long_request # type: ignore + from ._request_builders import build_put_long_request # type: ignore + from ._request_builders import build_get_float_request # type: ignore + from ._request_builders import build_put_float_request # type: ignore + from ._request_builders import build_get_double_request # type: ignore + from ._request_builders import build_put_double_request # type: ignore + from ._request_builders import build_get_bool_request # type: ignore + from ._request_builders import build_put_bool_request # type: ignore + from ._request_builders import build_get_string_request # type: ignore + from ._request_builders import build_put_string_request # type: ignore + from ._request_builders import build_get_date_request # type: ignore + from ._request_builders import build_put_date_request # type: ignore + from ._request_builders import build_get_date_time_request # type: ignore + from ._request_builders import build_put_date_time_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_request # type: ignore + from ._request_builders import build_get_duration_request # type: ignore + from ._request_builders import build_put_duration_request # type: ignore + from ._request_builders import build_get_byte_request # type: ignore + from ._request_builders import build_put_byte_request # type: ignore + +__all__ = [ + "build_get_int_request", + "build_put_int_request", + "build_get_long_request", + "build_put_long_request", + "build_get_float_request", + "build_put_float_request", + "build_get_double_request", + "build_put_double_request", + "build_get_bool_request", + "build_put_bool_request", + "build_get_string_request", + "build_put_string_request", + "build_get_date_request", + "build_put_date_request", + "build_get_date_time_request", + "build_put_date_time_request", + "build_get_date_time_rfc1123_request", + "build_put_date_time_rfc1123_request", + "build_get_duration_request", + "build_put_duration_request", + "build_get_byte_request", + "build_put_byte_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/_request_builders.py new file mode 100644 index 00000000000..5ab94d41df3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/_request_builders.py @@ -0,0 +1,1014 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_int_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "int (optional)", + "field2": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/integer') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_int_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put -1 and 2. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put -1 and 2. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "int (optional)", + "field2": "int (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/integer') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "long (optional)", + "field2": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1099511627775 and -999511627788. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1099511627775 and -999511627788. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "long (optional)", + "field2": "long (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/long') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "float (optional)", + "field2": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1.05 and -0.003. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1.05 and -0.003. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "float (optional)", + "field2": "float (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/float') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "float (optional)", + "field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/double') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "float (optional)", + "field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose": "float (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/double') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field_false": "bool (optional)", + "field_true": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put true and false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put true and false. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field_false": "bool (optional)", + "field_true": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/bool') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "empty": "str (optional)", + "field": "str (optional)", + "null": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'goodrequest', '', and null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'goodrequest', '', and null. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "empty": "str (optional)", + "field": "str (optional)", + "null": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/string') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "date (optional)", + "leap": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01' and '2016-02-29'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01' and '2016-02-29'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "date (optional)", + "leap": "date (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/date') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetime') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetimerfc1123') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 + May 2015 11:38:00 GMT'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May + 2015 11:38:00 GMT'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/datetimerfc1123') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "timedelta (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/duration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'P123DT22H14M12.011S'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'P123DT22H14M12.011S'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "timedelta (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/duration') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "bytearray (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/byte') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 + F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 F8 + F7 F6). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "bytearray (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/primitive/byte') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/_request_builders_py3.py new file mode 100644 index 00000000000..e5568cd2c70 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/primitive/_request_builders_py3.py @@ -0,0 +1,833 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_int_request(**kwargs: Any) -> HttpRequest: + """Get complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "int (optional)", + "field2": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/integer") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_int_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with integer properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put -1 and 2. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put -1 and 2. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "int (optional)", + "field2": "int (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/integer") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_request(**kwargs: Any) -> HttpRequest: + """Get complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "long (optional)", + "field2": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with long properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1099511627775 and -999511627788. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1099511627775 and -999511627788. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "long (optional)", + "field2": "long (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/long") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_request(**kwargs: Any) -> HttpRequest: + """Get complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "float (optional)", + "field2": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with float properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 1.05 and -0.003. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 1.05 and -0.003. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "float (optional)", + "field2": "float (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/float") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_request(**kwargs: Any) -> HttpRequest: + """Get complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field1": "float (optional)", + "field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/double") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with double properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 3e-100 and + -0.000000000000000000000000000000000000000000000000000000005. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field1": "float (optional)", + "field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose": "float (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/double") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_bool_request(**kwargs: Any) -> HttpRequest: + """Get complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field_false": "bool (optional)", + "field_true": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_bool_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with bool properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put true and false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put true and false. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field_false": "bool (optional)", + "field_true": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/bool") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_request(**kwargs: Any) -> HttpRequest: + """Get complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "empty": "str (optional)", + "field": "str (optional)", + "null": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with string properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'goodrequest', '', and null. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'goodrequest', '', and null. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "empty": "str (optional)", + "field": "str (optional)", + "null": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/string") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_request(**kwargs: Any) -> HttpRequest: + """Get complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "date (optional)", + "leap": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with date properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01' and '2016-02-29'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01' and '2016-02-29'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "date (optional)", + "leap": "date (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/date") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_request(**kwargs: Any) -> HttpRequest: + """Get complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with datetime properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put '0001-01-01T12:00:00-04:00' and + '2015-05-18T11:38:00-08:00'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetime") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_rfc1123_request(**kwargs: Any) -> HttpRequest: + """Get complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetimerfc1123") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with datetimeRfc1123 properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 + May 2015 11:38:00 GMT'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'Mon, 01 Jan 0001 12:00:00 GMT' and 'Mon, 18 May + 2015 11:38:00 GMT'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "datetime (optional)", + "now": "datetime (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/datetimerfc1123") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_request(**kwargs: Any) -> HttpRequest: + """Get complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "timedelta (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/duration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with duration properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put 'P123DT22H14M12.011S'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put 'P123DT22H14M12.011S'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "timedelta (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/duration") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_request(**kwargs: Any) -> HttpRequest: + """Get complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "field": "bytearray (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/byte") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types with byte properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 + F8 F7 F6). + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Please put non-ascii byte string hex(FF FE FD FC 00 FA F9 F8 + F7 F6). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "field": "bytearray (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/primitive/byte") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/__init__.py new file mode 100644 index 00000000000..83d94e4e60b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/__init__.py @@ -0,0 +1,19 @@ +# 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_get_valid_request + from ._request_builders_py3 import build_put_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_valid_request # type: ignore + from ._request_builders import build_put_valid_request # type: ignore + +__all__ = [ + "build_get_valid_request", + "build_put_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/_request_builders.py new file mode 100644 index 00000000000..abcd6e7be36 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/_request_builders.py @@ -0,0 +1,108 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "id": "str (optional)", + "size": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/readonlyproperty/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "str (optional)", + "size": "int (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/complex/readonlyproperty/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/_request_builders_py3.py new file mode 100644 index 00000000000..27da9eaeedb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/bodycomplexlowlevel/rest/readonlyproperty/_request_builders_py3.py @@ -0,0 +1,87 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_valid_request(**kwargs: Any) -> HttpRequest: + """Get complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "id": "str (optional)", + "size": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/readonlyproperty/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put complex types that have readonly properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "str (optional)", + "size": "int (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/complex/readonlyproperty/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/setup.py new file mode 100644 index 00000000000..f043dc258ff --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyComplexLowLevel/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 = "autorestcomplextestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestComplexTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestComplexTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/__init__.py new file mode 100644 index 00000000000..1888f98f168 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/__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 ._auto_rest_date_test_service import AutoRestDateTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestDateTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_auto_rest_date_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_auto_rest_date_test_service.py new file mode 100644 index 00000000000..2baaea27393 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_auto_rest_date_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestDateTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDateTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydatelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatelowlevel.rest import date + >>> request = date.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDateTestService + 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/BodyDateLowLevel/bodydatelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_configuration.py new file mode 100644 index 00000000000..53d2becacbf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_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 AutoRestDateTestServiceConfiguration(Configuration): + """Configuration for AutoRestDateTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestDateTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdatetestservice/{}".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/BodyDateLowLevel/bodydatelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/_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/BodyDateLowLevel/bodydatelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/aio/__init__.py new file mode 100644 index 00000000000..e236881dc5a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/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 ._auto_rest_date_test_service import AutoRestDateTestService + +__all__ = ["AutoRestDateTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/aio/_auto_rest_date_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/aio/_auto_rest_date_test_service.py new file mode 100644 index 00000000000..15701b893c2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/aio/_auto_rest_date_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestDateTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestDateTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydatelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatelowlevel.rest import date + >>> request = date.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDateTestService": + 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/BodyDateLowLevel/bodydatelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..4f71dfb033d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/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 AutoRestDateTestServiceConfiguration(Configuration): + """Configuration for AutoRestDateTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestDateTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdatetestservice/{}".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/BodyDateLowLevel/bodydatelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/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/BodyDateLowLevel/bodydatelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/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/BodyDateLowLevel/bodydatelowlevel/rest/date/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/__init__.py new file mode 100644 index 00000000000..30de141574a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_invalid_date_request + from ._request_builders_py3 import build_get_overflow_date_request + from ._request_builders_py3 import build_get_underflow_date_request + from ._request_builders_py3 import build_put_max_date_request + from ._request_builders_py3 import build_get_max_date_request + from ._request_builders_py3 import build_put_min_date_request + from ._request_builders_py3 import build_get_min_date_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_date_request # type: ignore + from ._request_builders import build_get_overflow_date_request # type: ignore + from ._request_builders import build_get_underflow_date_request # type: ignore + from ._request_builders import build_put_max_date_request # type: ignore + from ._request_builders import build_get_max_date_request # type: ignore + from ._request_builders import build_put_min_date_request # type: ignore + from ._request_builders import build_get_min_date_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_date_request", + "build_get_overflow_date_request", + "build_get_underflow_date_request", + "build_put_max_date_request", + "build_get_max_date_request", + "build_put_min_date_request", + "build_get_min_date_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/_request_builders.py new file mode 100644 index 00000000000..ca38724e8ae --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/_request_builders.py @@ -0,0 +1,299 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/invaliddate') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/overflowdate') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/underflowdate') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_max_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "date (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/max') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_max_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/max') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_min_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "date (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/min') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_min_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/date/min') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/_request_builders_py3.py new file mode 100644 index 00000000000..894a33bd26e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/bodydatelowlevel/rest/date/_request_builders_py3.py @@ -0,0 +1,230 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_date_request(**kwargs: Any) -> HttpRequest: + """Get invalid date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/invaliddate") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_date_request(**kwargs: Any) -> HttpRequest: + """Get overflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/overflowdate") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_date_request(**kwargs: Any) -> HttpRequest: + """Get underflow date value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/underflowdate") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_max_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "date (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/max") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_max_date_request(**kwargs: Any) -> HttpRequest: + """Get max date value 9999-12-31. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/max") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_min_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. date body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). date body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "date (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/min") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_min_date_request(**kwargs: Any) -> HttpRequest: + """Get min date value 0000-01-01. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/date/min") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/setup.py new file mode 100644 index 00000000000..90b3542e082 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateLowLevel/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 = "autorestdatetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDateTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDateTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/__init__.py new file mode 100644 index 00000000000..0995814e86f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/__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 ._auto_rest_date_time_test_service import AutoRestDateTimeTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestDateTimeTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_auto_rest_date_time_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_auto_rest_date_time_test_service.py new file mode 100644 index 00000000000..78e5faa7a35 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_auto_rest_date_time_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestDateTimeTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDateTimeTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTimeTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydatetimelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetimelowlevel.rest import datetime + >>> request = datetime.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDateTimeTestService + 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/BodyDateTimeLowLevel/bodydatetimelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_configuration.py new file mode 100644 index 00000000000..41ec3af9b67 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_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 AutoRestDateTimeTestServiceConfiguration(Configuration): + """Configuration for AutoRestDateTimeTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestDateTimeTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdatetimetestservice/{}".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/BodyDateTimeLowLevel/bodydatetimelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/_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/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/__init__.py new file mode 100644 index 00000000000..f521d501b8e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/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 ._auto_rest_date_time_test_service import AutoRestDateTimeTestService + +__all__ = ["AutoRestDateTimeTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/_auto_rest_date_time_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/_auto_rest_date_time_test_service.py new file mode 100644 index 00000000000..5cb8bdc8d3d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/_auto_rest_date_time_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestDateTimeTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestDateTimeTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDateTimeTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydatetimelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetimelowlevel.rest import datetime + >>> request = datetime.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDateTimeTestService": + 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/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..fece892264c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/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 AutoRestDateTimeTestServiceConfiguration(Configuration): + """Configuration for AutoRestDateTimeTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestDateTimeTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdatetimetestservice/{}".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/BodyDateTimeLowLevel/bodydatetimelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/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/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/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/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/__init__.py new file mode 100644 index 00000000000..3a935a20ab7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/__init__.py @@ -0,0 +1,79 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_overflow_request + from ._request_builders_py3 import build_get_underflow_request + from ._request_builders_py3 import build_put_utc_max_date_time_request + from ._request_builders_py3 import build_put_utc_max_date_time7_digits_request + from ._request_builders_py3 import build_get_utc_lowercase_max_date_time_request + from ._request_builders_py3 import build_get_utc_uppercase_max_date_time_request + from ._request_builders_py3 import build_get_utc_uppercase_max_date_time7_digits_request + from ._request_builders_py3 import build_put_local_positive_offset_max_date_time_request + from ._request_builders_py3 import build_get_local_positive_offset_lowercase_max_date_time_request + from ._request_builders_py3 import build_get_local_positive_offset_uppercase_max_date_time_request + from ._request_builders_py3 import build_put_local_negative_offset_max_date_time_request + from ._request_builders_py3 import build_get_local_negative_offset_uppercase_max_date_time_request + from ._request_builders_py3 import build_get_local_negative_offset_lowercase_max_date_time_request + from ._request_builders_py3 import build_put_utc_min_date_time_request + from ._request_builders_py3 import build_get_utc_min_date_time_request + from ._request_builders_py3 import build_put_local_positive_offset_min_date_time_request + from ._request_builders_py3 import build_get_local_positive_offset_min_date_time_request + from ._request_builders_py3 import build_put_local_negative_offset_min_date_time_request + from ._request_builders_py3 import build_get_local_negative_offset_min_date_time_request + from ._request_builders_py3 import build_get_local_no_offset_min_date_time_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_overflow_request # type: ignore + from ._request_builders import build_get_underflow_request # type: ignore + from ._request_builders import build_put_utc_max_date_time_request # type: ignore + from ._request_builders import build_put_utc_max_date_time7_digits_request # type: ignore + from ._request_builders import build_get_utc_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_uppercase_max_date_time7_digits_request # type: ignore + from ._request_builders import build_put_local_positive_offset_max_date_time_request # type: ignore + from ._request_builders import build_get_local_positive_offset_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_get_local_positive_offset_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_put_local_negative_offset_max_date_time_request # type: ignore + from ._request_builders import build_get_local_negative_offset_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_get_local_negative_offset_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_put_utc_min_date_time_request # type: ignore + from ._request_builders import build_get_utc_min_date_time_request # type: ignore + from ._request_builders import build_put_local_positive_offset_min_date_time_request # type: ignore + from ._request_builders import build_get_local_positive_offset_min_date_time_request # type: ignore + from ._request_builders import build_put_local_negative_offset_min_date_time_request # type: ignore + from ._request_builders import build_get_local_negative_offset_min_date_time_request # type: ignore + from ._request_builders import build_get_local_no_offset_min_date_time_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_overflow_request", + "build_get_underflow_request", + "build_put_utc_max_date_time_request", + "build_put_utc_max_date_time7_digits_request", + "build_get_utc_lowercase_max_date_time_request", + "build_get_utc_uppercase_max_date_time_request", + "build_get_utc_uppercase_max_date_time7_digits_request", + "build_put_local_positive_offset_max_date_time_request", + "build_get_local_positive_offset_lowercase_max_date_time_request", + "build_get_local_positive_offset_uppercase_max_date_time_request", + "build_put_local_negative_offset_max_date_time_request", + "build_get_local_negative_offset_uppercase_max_date_time_request", + "build_get_local_negative_offset_lowercase_max_date_time_request", + "build_put_utc_min_date_time_request", + "build_get_utc_min_date_time_request", + "build_put_local_positive_offset_min_date_time_request", + "build_get_local_positive_offset_min_date_time_request", + "build_put_local_negative_offset_min_date_time_request", + "build_get_local_negative_offset_min_date_time_request", + "build_get_local_no_offset_min_date_time_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/_request_builders.py new file mode 100644 index 00000000000..b6f72e2170e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/_request_builders.py @@ -0,0 +1,819 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/overflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/underflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_max_date_time7_digits_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc7ms') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value 9999-12-31t23:59:59.999z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_uppercase_max_date_time7_digits_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/utc7ms/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_positive_offset_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localpositiveoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_positive_offset_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localpositiveoffset/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_positive_offset_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localpositiveoffset/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_negative_offset_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localnegativeoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_negative_offset_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localnegativeoffset/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_negative_offset_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/max/localnegativeoffset/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/utc') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/utc') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_positive_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localpositiveoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_positive_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localpositiveoffset') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_local_negative_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localnegativeoffset') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_negative_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localnegativeoffset') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_no_offset_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value 0001-01-01T00:00:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetime/min/localnooffset') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/_request_builders_py3.py new file mode 100644 index 00000000000..2e2534af8ef --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/bodydatetimelowlevel/rest/datetime/_request_builders_py3.py @@ -0,0 +1,646 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_request(**kwargs: Any) -> HttpRequest: + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/overflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_request(**kwargs: Any) -> HttpRequest: + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/underflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_max_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_utc_max_date_time7_digits_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc7ms") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value 9999-12-31t23:59:59.999z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_utc_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value 9999-12-31T23:59:59.999Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_utc_uppercase_max_date_time7_digits_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value 9999-12-31T23:59:59.9999999Z. + + This is against the recommendation that asks for 3 digits, but allow to test what happens in + that scenario. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/utc7ms/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_positive_offset_max_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localpositiveoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_positive_offset_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localpositiveoffset/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_local_positive_offset_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localpositiveoffset/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_negative_offset_max_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localnegativeoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_negative_offset_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31T23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localnegativeoffset/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_local_negative_offset_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value with positive num offset 9999-12-31t23:59:59.999-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/max/localnegativeoffset/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_min_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/utc") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00Z. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/utc") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_positive_offset_min_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localpositiveoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_positive_offset_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00+14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localpositiveoffset") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_local_negative_offset_min_date_time_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localnegativeoffset") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_local_negative_offset_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00-14:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localnegativeoffset") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_local_no_offset_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value 0001-01-01T00:00:00. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetime/min/localnooffset") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/setup.py new file mode 100644 index 00000000000..b0967348287 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeLowLevel/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 = "autorestdatetimetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDateTimeTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDateTimeTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/__init__.py new file mode 100644 index 00000000000..b965b28ad76 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/__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 ._auto_rest_rfc1123_date_time_test_service import AutoRestRFC1123DateTimeTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestRFC1123DateTimeTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_auto_rest_rfc1123_date_time_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_auto_rest_rfc1123_date_time_test_service.py new file mode 100644 index 00000000000..4fbf5416b51 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_auto_rest_rfc1123_date_time_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestRFC1123DateTimeTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestRFC1123DateTimeTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRFC1123DateTimeTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydatetimerfc1123lowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetimerfc1123lowlevel.rest import datetimerfc1123 + >>> request = datetimerfc1123.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestRFC1123DateTimeTestService + 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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_configuration.py new file mode 100644 index 00000000000..4048a5a7f59 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_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 AutoRestRFC1123DateTimeTestServiceConfiguration(Configuration): + """Configuration for AutoRestRFC1123DateTimeTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestRFC1123DateTimeTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestrfc1123datetimetestservice/{}".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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/_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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/__init__.py new file mode 100644 index 00000000000..43c4bda4f99 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/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 ._auto_rest_rfc1123_date_time_test_service import AutoRestRFC1123DateTimeTestService + +__all__ = ["AutoRestRFC1123DateTimeTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/_auto_rest_rfc1123_date_time_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/_auto_rest_rfc1123_date_time_test_service.py new file mode 100644 index 00000000000..e80c6e0c57d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/_auto_rest_rfc1123_date_time_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestRFC1123DateTimeTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestRFC1123DateTimeTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRFC1123DateTimeTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydatetimerfc1123lowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydatetimerfc1123lowlevel.rest import datetimerfc1123 + >>> request = datetimerfc1123.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestRFC1123DateTimeTestService": + 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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/aio/_configuration.py new file mode 100644 index 00000000000..a5f8aa98c35 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/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 AutoRestRFC1123DateTimeTestServiceConfiguration(Configuration): + """Configuration for AutoRestRFC1123DateTimeTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestRFC1123DateTimeTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestrfc1123datetimetestservice/{}".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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/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/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/__init__.py new file mode 100644 index 00000000000..63f5895326f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/__init__.py @@ -0,0 +1,40 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_overflow_request + from ._request_builders_py3 import build_get_underflow_request + from ._request_builders_py3 import build_put_utc_max_date_time_request + from ._request_builders_py3 import build_get_utc_lowercase_max_date_time_request + from ._request_builders_py3 import build_get_utc_uppercase_max_date_time_request + from ._request_builders_py3 import build_put_utc_min_date_time_request + from ._request_builders_py3 import build_get_utc_min_date_time_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_overflow_request # type: ignore + from ._request_builders import build_get_underflow_request # type: ignore + from ._request_builders import build_put_utc_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_lowercase_max_date_time_request # type: ignore + from ._request_builders import build_get_utc_uppercase_max_date_time_request # type: ignore + from ._request_builders import build_put_utc_min_date_time_request # type: ignore + from ._request_builders import build_get_utc_min_date_time_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_overflow_request", + "build_get_underflow_request", + "build_put_utc_max_date_time_request", + "build_get_utc_lowercase_max_date_time_request", + "build_get_utc_uppercase_max_date_time_request", + "build_put_utc_min_date_time_request", + "build_get_utc_min_date_time_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/_request_builders.py new file mode 100644 index 00000000000..345ba548b7c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/_request_builders.py @@ -0,0 +1,330 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/overflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/underflow') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/max') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_lowercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/max/lowercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_uppercase_max_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/max/uppercase') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/min') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_utc_min_date_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datetimerfc1123/min') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/_request_builders_py3.py new file mode 100644 index 00000000000..5fe045887bf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/bodydatetimerfc1123lowlevel/rest/datetimerfc1123/_request_builders_py3.py @@ -0,0 +1,253 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_request(**kwargs: Any) -> HttpRequest: + """Get overflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/overflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_request(**kwargs: Any) -> HttpRequest: + """Get underflow datetime value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/underflow") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_max_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/max") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_lowercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value fri, 31 dec 9999 23:59:59 gmt. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/max/lowercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_utc_uppercase_max_date_time_request(**kwargs: Any) -> HttpRequest: + """Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/max/uppercase") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_utc_min_date_time_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. datetime body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). datetime body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/min") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_utc_min_date_time_request(**kwargs: Any) -> HttpRequest: + """Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/datetimerfc1123/min") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/setup.py new file mode 100644 index 00000000000..b8061d302f5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel/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 = "autorestrfc1123datetimetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestRFC1123DateTimeTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestRFC1123DateTimeTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/__init__.py new file mode 100644 index 00000000000..f914a999b3b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/__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 ._auto_rest_swagger_ba_tdictionary_service import AutoRestSwaggerBATDictionaryService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATDictionaryService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_auto_rest_swagger_ba_tdictionary_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_auto_rest_swagger_ba_tdictionary_service.py new file mode 100644 index 00000000000..8d16127e570 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_auto_rest_swagger_ba_tdictionary_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATDictionaryServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATDictionaryService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATDictionaryServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydictionarylowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydictionarylowlevel.rest import dictionary + >>> request = dictionary.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATDictionaryService + 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/BodyDictionaryLowLevel/bodydictionarylowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_configuration.py new file mode 100644 index 00000000000..c8d4d966970 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_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 AutoRestSwaggerBATDictionaryServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATDictionaryService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATDictionaryServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatdictionaryservice/{}".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/BodyDictionaryLowLevel/bodydictionarylowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/_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/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/__init__.py new file mode 100644 index 00000000000..db34c8dfb85 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/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 ._auto_rest_swagger_ba_tdictionary_service import AutoRestSwaggerBATDictionaryService + +__all__ = ["AutoRestSwaggerBATDictionaryService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/_auto_rest_swagger_ba_tdictionary_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/_auto_rest_swagger_ba_tdictionary_service.py new file mode 100644 index 00000000000..44daab1523a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/_auto_rest_swagger_ba_tdictionary_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATDictionaryServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATDictionaryService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATDictionaryServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydictionarylowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydictionarylowlevel.rest import dictionary + >>> request = dictionary.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATDictionaryService": + 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/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/aio/_configuration.py new file mode 100644 index 00000000000..01218333453 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/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 AutoRestSwaggerBATDictionaryServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATDictionaryService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATDictionaryServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatdictionaryservice/{}".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/BodyDictionaryLowLevel/bodydictionarylowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/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/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/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/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/__init__.py new file mode 100644 index 00000000000..dbf5f8a21dd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/__init__.py @@ -0,0 +1,208 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_null_value_request + from ._request_builders_py3 import build_get_null_key_request + from ._request_builders_py3 import build_get_empty_string_key_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_boolean_tfft_request + from ._request_builders_py3 import build_put_boolean_tfft_request + from ._request_builders_py3 import build_get_boolean_invalid_null_request + from ._request_builders_py3 import build_get_boolean_invalid_string_request + from ._request_builders_py3 import build_get_integer_valid_request + from ._request_builders_py3 import build_put_integer_valid_request + from ._request_builders_py3 import build_get_int_invalid_null_request + from ._request_builders_py3 import build_get_int_invalid_string_request + from ._request_builders_py3 import build_get_long_valid_request + from ._request_builders_py3 import build_put_long_valid_request + from ._request_builders_py3 import build_get_long_invalid_null_request + from ._request_builders_py3 import build_get_long_invalid_string_request + from ._request_builders_py3 import build_get_float_valid_request + from ._request_builders_py3 import build_put_float_valid_request + from ._request_builders_py3 import build_get_float_invalid_null_request + from ._request_builders_py3 import build_get_float_invalid_string_request + from ._request_builders_py3 import build_get_double_valid_request + from ._request_builders_py3 import build_put_double_valid_request + from ._request_builders_py3 import build_get_double_invalid_null_request + from ._request_builders_py3 import build_get_double_invalid_string_request + from ._request_builders_py3 import build_get_string_valid_request + from ._request_builders_py3 import build_put_string_valid_request + from ._request_builders_py3 import build_get_string_with_null_request + from ._request_builders_py3 import build_get_string_with_invalid_request + from ._request_builders_py3 import build_get_date_valid_request + from ._request_builders_py3 import build_put_date_valid_request + from ._request_builders_py3 import build_get_date_invalid_null_request + from ._request_builders_py3 import build_get_date_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_valid_request + from ._request_builders_py3 import build_put_date_time_valid_request + from ._request_builders_py3 import build_get_date_time_invalid_null_request + from ._request_builders_py3 import build_get_date_time_invalid_chars_request + from ._request_builders_py3 import build_get_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_put_date_time_rfc1123_valid_request + from ._request_builders_py3 import build_get_duration_valid_request + from ._request_builders_py3 import build_put_duration_valid_request + from ._request_builders_py3 import build_get_byte_valid_request + from ._request_builders_py3 import build_put_byte_valid_request + from ._request_builders_py3 import build_get_byte_invalid_null_request + from ._request_builders_py3 import build_get_base64_url_request + from ._request_builders_py3 import build_get_complex_null_request + from ._request_builders_py3 import build_get_complex_empty_request + from ._request_builders_py3 import build_get_complex_item_null_request + from ._request_builders_py3 import build_get_complex_item_empty_request + from ._request_builders_py3 import build_get_complex_valid_request + from ._request_builders_py3 import build_put_complex_valid_request + from ._request_builders_py3 import build_get_array_null_request + from ._request_builders_py3 import build_get_array_empty_request + from ._request_builders_py3 import build_get_array_item_null_request + from ._request_builders_py3 import build_get_array_item_empty_request + from ._request_builders_py3 import build_get_array_valid_request + from ._request_builders_py3 import build_put_array_valid_request + from ._request_builders_py3 import build_get_dictionary_null_request + from ._request_builders_py3 import build_get_dictionary_empty_request + from ._request_builders_py3 import build_get_dictionary_item_null_request + from ._request_builders_py3 import build_get_dictionary_item_empty_request + from ._request_builders_py3 import build_get_dictionary_valid_request + from ._request_builders_py3 import build_put_dictionary_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_null_value_request # type: ignore + from ._request_builders import build_get_null_key_request # type: ignore + from ._request_builders import build_get_empty_string_key_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_boolean_tfft_request # type: ignore + from ._request_builders import build_put_boolean_tfft_request # type: ignore + from ._request_builders import build_get_boolean_invalid_null_request # type: ignore + from ._request_builders import build_get_boolean_invalid_string_request # type: ignore + from ._request_builders import build_get_integer_valid_request # type: ignore + from ._request_builders import build_put_integer_valid_request # type: ignore + from ._request_builders import build_get_int_invalid_null_request # type: ignore + from ._request_builders import build_get_int_invalid_string_request # type: ignore + from ._request_builders import build_get_long_valid_request # type: ignore + from ._request_builders import build_put_long_valid_request # type: ignore + from ._request_builders import build_get_long_invalid_null_request # type: ignore + from ._request_builders import build_get_long_invalid_string_request # type: ignore + from ._request_builders import build_get_float_valid_request # type: ignore + from ._request_builders import build_put_float_valid_request # type: ignore + from ._request_builders import build_get_float_invalid_null_request # type: ignore + from ._request_builders import build_get_float_invalid_string_request # type: ignore + from ._request_builders import build_get_double_valid_request # type: ignore + from ._request_builders import build_put_double_valid_request # type: ignore + from ._request_builders import build_get_double_invalid_null_request # type: ignore + from ._request_builders import build_get_double_invalid_string_request # type: ignore + from ._request_builders import build_get_string_valid_request # type: ignore + from ._request_builders import build_put_string_valid_request # type: ignore + from ._request_builders import build_get_string_with_null_request # type: ignore + from ._request_builders import build_get_string_with_invalid_request # type: ignore + from ._request_builders import build_get_date_valid_request # type: ignore + from ._request_builders import build_put_date_valid_request # type: ignore + from ._request_builders import build_get_date_invalid_null_request # type: ignore + from ._request_builders import build_get_date_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_valid_request # type: ignore + from ._request_builders import build_put_date_time_valid_request # type: ignore + from ._request_builders import build_get_date_time_invalid_null_request # type: ignore + from ._request_builders import build_get_date_time_invalid_chars_request # type: ignore + from ._request_builders import build_get_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_put_date_time_rfc1123_valid_request # type: ignore + from ._request_builders import build_get_duration_valid_request # type: ignore + from ._request_builders import build_put_duration_valid_request # type: ignore + from ._request_builders import build_get_byte_valid_request # type: ignore + from ._request_builders import build_put_byte_valid_request # type: ignore + from ._request_builders import build_get_byte_invalid_null_request # type: ignore + from ._request_builders import build_get_base64_url_request # type: ignore + from ._request_builders import build_get_complex_null_request # type: ignore + from ._request_builders import build_get_complex_empty_request # type: ignore + from ._request_builders import build_get_complex_item_null_request # type: ignore + from ._request_builders import build_get_complex_item_empty_request # type: ignore + from ._request_builders import build_get_complex_valid_request # type: ignore + from ._request_builders import build_put_complex_valid_request # type: ignore + from ._request_builders import build_get_array_null_request # type: ignore + from ._request_builders import build_get_array_empty_request # type: ignore + from ._request_builders import build_get_array_item_null_request # type: ignore + from ._request_builders import build_get_array_item_empty_request # type: ignore + from ._request_builders import build_get_array_valid_request # type: ignore + from ._request_builders import build_put_array_valid_request # type: ignore + from ._request_builders import build_get_dictionary_null_request # type: ignore + from ._request_builders import build_get_dictionary_empty_request # type: ignore + from ._request_builders import build_get_dictionary_item_null_request # type: ignore + from ._request_builders import build_get_dictionary_item_empty_request # type: ignore + from ._request_builders import build_get_dictionary_valid_request # type: ignore + from ._request_builders import build_put_dictionary_valid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_null_value_request", + "build_get_null_key_request", + "build_get_empty_string_key_request", + "build_get_invalid_request", + "build_get_boolean_tfft_request", + "build_put_boolean_tfft_request", + "build_get_boolean_invalid_null_request", + "build_get_boolean_invalid_string_request", + "build_get_integer_valid_request", + "build_put_integer_valid_request", + "build_get_int_invalid_null_request", + "build_get_int_invalid_string_request", + "build_get_long_valid_request", + "build_put_long_valid_request", + "build_get_long_invalid_null_request", + "build_get_long_invalid_string_request", + "build_get_float_valid_request", + "build_put_float_valid_request", + "build_get_float_invalid_null_request", + "build_get_float_invalid_string_request", + "build_get_double_valid_request", + "build_put_double_valid_request", + "build_get_double_invalid_null_request", + "build_get_double_invalid_string_request", + "build_get_string_valid_request", + "build_put_string_valid_request", + "build_get_string_with_null_request", + "build_get_string_with_invalid_request", + "build_get_date_valid_request", + "build_put_date_valid_request", + "build_get_date_invalid_null_request", + "build_get_date_invalid_chars_request", + "build_get_date_time_valid_request", + "build_put_date_time_valid_request", + "build_get_date_time_invalid_null_request", + "build_get_date_time_invalid_chars_request", + "build_get_date_time_rfc1123_valid_request", + "build_put_date_time_rfc1123_valid_request", + "build_get_duration_valid_request", + "build_put_duration_valid_request", + "build_get_byte_valid_request", + "build_put_byte_valid_request", + "build_get_byte_invalid_null_request", + "build_get_base64_url_request", + "build_get_complex_null_request", + "build_get_complex_empty_request", + "build_get_complex_item_null_request", + "build_get_complex_item_empty_request", + "build_get_complex_valid_request", + "build_put_complex_valid_request", + "build_get_array_null_request", + "build_get_array_empty_request", + "build_get_array_item_null_request", + "build_get_array_item_empty_request", + "build_get_array_valid_request", + "build_put_array_valid_request", + "build_get_dictionary_null_request", + "build_get_dictionary_empty_request", + "build_get_dictionary_item_null_request", + "build_get_dictionary_item_empty_request", + "build_get_dictionary_valid_request", + "build_put_dictionary_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/_request_builders.py new file mode 100644 index 00000000000..454054a29a6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/_request_builders.py @@ -0,0 +1,2766 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty dictionary value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_value_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get Dictionary with null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/nullvalue') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get Dictionary with null key. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/nullkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_string_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get Dictionary with key as empty string. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/keyemptystring') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/tfft') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_boolean_tfft_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/tfft') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": true, "1": null, "2": false }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/true.null.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/boolean/true.boolean.false') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_integer_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "int (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/integer/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.-1.3.300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_long_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "long (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.-1.3.300') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.null.zero') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/long/1.integer.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_float_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "float (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_float_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/float/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/0--0.01-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_double_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "float (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/0--0.01-1.2e20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/0.0-null-1.2e20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_double_invalid_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/double/1.number.0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo1.foo2.foo3') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_string_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo1.foo2.foo3') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo.null.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_string_with_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/string/foo.123.foo2') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "date (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2011-03-22", "1": "date"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", + "2": "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": + "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "datetime (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_invalid_chars_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time/invalidchars') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan + 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time-rfc1123/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_date_time_rfc1123_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 + 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "datetime (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/date-time-rfc1123/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "timedelta (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/duration/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_duration_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "timedelta (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/duration/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each item encoded in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bytearray (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/byte/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_byte_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "bytearray (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/byte/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_byte_invalid_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 + encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bytearray (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/byte/invalidnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test + string", "2": "Lorem ipsum"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bytes (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/prim/base64url/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty dictionary of complex type {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, + "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": + {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/complex/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty dictionary {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_array_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/array/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/itemnull') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_item_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/itemempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": { + "str": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/dictionary/dictionary/valid') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/_request_builders_py3.py new file mode 100644 index 00000000000..f62862d36a3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/bodydictionarylowlevel/rest/dictionary/_request_builders_py3.py @@ -0,0 +1,2241 @@ +# 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 datetime +from typing import Any, Dict, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty dictionary value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_value_request(**kwargs: Any) -> HttpRequest: + """Get Dictionary with null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/nullvalue") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_key_request(**kwargs: Any) -> HttpRequest: + """Get Dictionary with null key. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/nullkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_string_key_request(**kwargs: Any) -> HttpRequest: + """Get Dictionary with key as empty string. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/keyemptystring") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid Dictionary value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_tfft_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/tfft") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_boolean_tfft_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": true, "1": false, "2": false, "3": true }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/tfft") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_boolean_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": true, "1": null, "2": false }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/true.null.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/boolean/true.boolean.false") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_integer_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_integer_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "int (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_int_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/integer/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.-1.3.300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_long_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "long (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.-1.3.300") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_long_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get long dictionary value {"0": 1, "1": null, "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.null.zero") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_long_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get long dictionary value {"0": 1, "1": "integer", "2": 0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "long (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/long/1.integer.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_valid_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_float_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "float (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_float_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_float_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/float/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_valid_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/0--0.01-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_double_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "float (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/0--0.01-1.2e20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_double_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/0.0-null-1.2e20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_double_invalid_string_request(**kwargs: Any) -> HttpRequest: + """Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "float (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/double/1.number.0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_valid_request(**kwargs: Any) -> HttpRequest: + """Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo1.foo2.foo3") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_string_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo1.foo2.foo3") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_string_with_null_request(**kwargs: Any) -> HttpRequest: + """Get string dictionary value {"0": "foo", "1": null, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo.null.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_string_with_invalid_request(**kwargs: Any) -> HttpRequest: + """Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/string/foo.123.foo2") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "date (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2011-03-22", "1": "date"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "date (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", + "2": "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": + "1492-10-12T10:15:01-08:00"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "datetime (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_date_time_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_invalid_chars_request(**kwargs: Any) -> HttpRequest: + """Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time/invalidchars") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_date_time_rfc1123_valid_request(**kwargs: Any) -> HttpRequest: + """Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan + 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "datetime (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time-rfc1123/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_date_time_rfc1123_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 + 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "datetime (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/date-time-rfc1123/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_duration_valid_request(**kwargs: Any) -> HttpRequest: + """Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "timedelta (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/duration/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_duration_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "timedelta (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/duration/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_valid_request(**kwargs: Any) -> HttpRequest: + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each item encoded in base64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bytearray (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/byte/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_byte_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} + with each elementencoded in base 64. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": "bytearray (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/byte/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_byte_invalid_null_request(**kwargs: Any) -> HttpRequest: + """Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 + encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bytearray (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/byte/invalidnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_request(**kwargs: Any) -> HttpRequest: + """Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test + string", "2": "Lorem ipsum"}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "bytes (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/prim/base64url/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_null_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type null value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty dictionary of complex type {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_null_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, + "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_complex_valid_request(**kwargs: Any) -> HttpRequest: + """Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, + "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": + {"integer": 3, "string": "4"}, "2": {"integer": 5, "string": "6"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": { + "integer": "int (optional)", + "string": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/complex/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_null_request(**kwargs: Any) -> HttpRequest: + """Get a null array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_empty_request(**kwargs: Any) -> HttpRequest: + """Get an empty dictionary {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_array_valid_request(**kwargs: Any) -> HttpRequest: + """Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": [ + "str (optional)" + ] + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_array_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", + "9"]}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/array/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_null_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries with value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_empty_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_null_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/itemnull") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_item_empty_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/itemempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_dictionary_valid_request(**kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "str": "str (optional)" + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_valid_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": + "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": + "eight", "9": "nine"}}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": { + "str": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/dictionary/dictionary/valid") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/setup.py new file mode 100644 index 00000000000..2656cf02743 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDictionaryLowLevel/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 = "autorestswaggerbatdictionaryservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATDictionaryService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATDictionaryService"], + 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/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/__init__.py new file mode 100644 index 00000000000..0cac81cdcb4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/__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 ._auto_rest_duration_test_service import AutoRestDurationTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestDurationTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_auto_rest_duration_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..79ec50941a0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_auto_rest_duration_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestDurationTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestDurationTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydurationlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydurationlowlevel.rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestDurationTestService + 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/BodyDurationLowLevel/bodydurationlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_configuration.py new file mode 100644 index 00000000000..8b18f16d3f2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_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 AutoRestDurationTestServiceConfiguration(Configuration): + """Configuration for AutoRestDurationTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestDurationTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdurationtestservice/{}".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/BodyDurationLowLevel/bodydurationlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/_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/BodyDurationLowLevel/bodydurationlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/aio/__init__.py new file mode 100644 index 00000000000..7286d17b514 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/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 ._auto_rest_duration_test_service import AutoRestDurationTestService + +__all__ = ["AutoRestDurationTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/aio/_auto_rest_duration_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/aio/_auto_rest_duration_test_service.py new file mode 100644 index 00000000000..e76b2388a01 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/aio/_auto_rest_duration_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestDurationTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestDurationTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestDurationTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodydurationlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodydurationlowlevel.rest import duration + >>> request = duration.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestDurationTestService": + 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/BodyDurationLowLevel/bodydurationlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..f7cece514e6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/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 AutoRestDurationTestServiceConfiguration(Configuration): + """Configuration for AutoRestDurationTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestDurationTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestdurationtestservice/{}".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/BodyDurationLowLevel/bodydurationlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/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/BodyDurationLowLevel/bodydurationlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/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/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/__init__.py new file mode 100644 index 00000000000..2551fd5500f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/__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 ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_put_positive_duration_request + from ._request_builders_py3 import build_get_positive_duration_request + from ._request_builders_py3 import build_get_invalid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_put_positive_duration_request # type: ignore + from ._request_builders import build_get_positive_duration_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_put_positive_duration_request", + "build_get_positive_duration_request", + "build_get_invalid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders.py new file mode 100644 index 00000000000..21d0f269206 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders.py @@ -0,0 +1,159 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "timedelta (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_positive_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/positiveduration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/duration/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders_py3.py new file mode 100644 index 00000000000..4f334d1a221 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/bodydurationlowlevel/rest/duration/_request_builders_py3.py @@ -0,0 +1,122 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_positive_duration_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. duration body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). duration body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "timedelta (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_positive_duration_request(**kwargs: Any) -> HttpRequest: + """Get a positive duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/positiveduration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get an invalid duration value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/duration/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/setup.py new file mode 100644 index 00000000000..5d6c5294492 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyDurationLowLevel/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 = "autorestdurationtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestDurationTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestDurationTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/__init__.py new file mode 100644 index 00000000000..92c087697fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/__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 ._auto_rest_swagger_bat_file_service import AutoRestSwaggerBATFileService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATFileService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_auto_rest_swagger_bat_file_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_auto_rest_swagger_bat_file_service.py new file mode 100644 index 00000000000..20093653f02 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_auto_rest_swagger_bat_file_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATFileServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATFileService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFileServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyfilelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyfilelowlevel.rest import files + >>> request = files.build_get_file_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATFileService + 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/BodyFileLowLevel/bodyfilelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_configuration.py new file mode 100644 index 00000000000..06ec4ffc805 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_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 AutoRestSwaggerBATFileServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATFileService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATFileServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatfileservice/{}".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/BodyFileLowLevel/bodyfilelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/_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/BodyFileLowLevel/bodyfilelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/aio/__init__.py new file mode 100644 index 00000000000..f63334ed002 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/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 ._auto_rest_swagger_bat_file_service import AutoRestSwaggerBATFileService + +__all__ = ["AutoRestSwaggerBATFileService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/aio/_auto_rest_swagger_bat_file_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/aio/_auto_rest_swagger_bat_file_service.py new file mode 100644 index 00000000000..f62b7b1bcb9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/aio/_auto_rest_swagger_bat_file_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATFileServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATFileService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFileServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyfilelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyfilelowlevel.rest import files + >>> request = files.build_get_file_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATFileService": + 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/BodyFileLowLevel/bodyfilelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..668abb62f8e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/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 AutoRestSwaggerBATFileServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATFileService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATFileServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatfileservice/{}".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/BodyFileLowLevel/bodyfilelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/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/BodyFileLowLevel/bodyfilelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/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/BodyFileLowLevel/bodyfilelowlevel/rest/files/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/__init__.py new file mode 100644 index 00000000000..7ac5971aa0b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/__init__.py @@ -0,0 +1,22 @@ +# 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_get_file_request + from ._request_builders_py3 import build_get_file_large_request + from ._request_builders_py3 import build_get_empty_file_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_file_request # type: ignore + from ._request_builders import build_get_file_large_request # type: ignore + from ._request_builders import build_get_empty_file_request # type: ignore + +__all__ = [ + "build_get_file_request", + "build_get_file_large_request", + "build_get_empty_file_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/_request_builders.py new file mode 100644 index 00000000000..16c12b0af5b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/_request_builders.py @@ -0,0 +1,111 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_file_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", '/files/stream/nonempty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_file_large_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a large file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", '/files/stream/verylarge') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_file_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", '/files/stream/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/_request_builders_py3.py new file mode 100644 index 00000000000..dc41b15b5da --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/bodyfilelowlevel/rest/files/_request_builders_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 Any + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_file_request(**kwargs: Any) -> HttpRequest: + """Get file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", "/files/stream/nonempty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_file_large_request(**kwargs: Any) -> HttpRequest: + """Get a large file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", "/files/stream/verylarge") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_empty_file_request(**kwargs: Any) -> HttpRequest: + """Get empty file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "image/png, application/json" + # Construct URL + url = kwargs.pop("template_url", "/files/stream/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/setup.py new file mode 100644 index 00000000000..3a578b11e3f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFileLowLevel/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 = "autorestswaggerbatfileservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATFileService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATFileService"], + 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/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/__init__.py new file mode 100644 index 00000000000..41907abfc39 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/__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 ._auto_rest_swagger_bat_form_data_service import AutoRestSwaggerBATFormDataService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATFormDataService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass 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 new file mode 100644 index 00000000000..1a98e07551e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_auto_rest_swagger_bat_form_data_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATFormDataServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATFormDataService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFormDataServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyformdatalowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyformdatalowlevel.rest import formdata + >>> request = formdata.build_upload_file_request(files=files, 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 + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATFormDataService + 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/BodyFormDataLowLevel/bodyformdatalowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_configuration.py new file mode 100644 index 00000000000..7e429aea40b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_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 AutoRestSwaggerBATFormDataServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATFormDataService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATFormDataServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatformdataservice/{}".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/BodyFormDataLowLevel/bodyformdatalowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_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/BodyFormDataLowLevel/bodyformdatalowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/__init__.py new file mode 100644 index 00000000000..ded3830bb90 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/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 ._auto_rest_swagger_bat_form_data_service import AutoRestSwaggerBATFormDataService + +__all__ = ["AutoRestSwaggerBATFormDataService"] 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 new file mode 100644 index 00000000000..e97a4616e2c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_auto_rest_swagger_bat_form_data_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATFormDataServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATFormDataService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATFormDataServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyformdatalowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyformdatalowlevel.rest import formdata + >>> request = formdata.build_upload_file_request(files=files, 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 + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATFormDataService": + 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/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_configuration.py new file mode 100644 index 00000000000..6728a757294 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/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 AutoRestSwaggerBATFormDataServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATFormDataService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATFormDataServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatformdataservice/{}".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/BodyFormDataLowLevel/bodyformdatalowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/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/BodyFormDataLowLevel/bodyformdatalowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/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/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/__init__.py new file mode 100644 index 00000000000..f7d990f66f0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/__init__.py @@ -0,0 +1,22 @@ +# 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_upload_file_request + from ._request_builders_py3 import build_upload_file_via_body_request + from ._request_builders_py3 import build_upload_files_request +except (SyntaxError, ImportError): + from ._request_builders import build_upload_file_request # type: ignore + from ._request_builders import build_upload_file_via_body_request # type: ignore + from ._request_builders import build_upload_files_request # type: ignore + +__all__ = [ + "build_upload_file_request", + "build_upload_file_via_body_request", + "build_upload_files_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 new file mode 100644 index 00000000000..6f2fbb51c89 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders.py @@ -0,0 +1,150 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, IO, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_upload_file_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", '/formdata/stream/uploadfile') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_upload_file_via_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", '/formdata/stream/uploadfile') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_upload_files_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Upload multiple files. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", '/formdata/stream/uploadfiles') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) 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 new file mode 100644 index 00000000000..50d13889363 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders_py3.py @@ -0,0 +1,129 @@ +# 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, IO, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_upload_file_request( + *, files: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", "/formdata/stream/uploadfile") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, headers=header_parameters, files=files, data=data, content=content, **kwargs + ) + + +def build_upload_file_via_body_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Upload file. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", "/formdata/stream/uploadfile") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_upload_files_request( + *, files: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Upload multiple files. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/octet-stream, application/json" + # Construct URL + url = kwargs.pop("template_url", "/formdata/stream/uploadfiles") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="POST", url=url, headers=header_parameters, files=files, data=data, content=content, **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/setup.py new file mode 100644 index 00000000000..9174ce8304d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/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 = "autorestswaggerbatformdataservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATFormDataService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATFormDataService"], + 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/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/__init__.py new file mode 100644 index 00000000000..4fdc7bdbe25 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/__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 ._auto_rest_integer_test_service import AutoRestIntegerTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestIntegerTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_auto_rest_integer_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_auto_rest_integer_test_service.py new file mode 100644 index 00000000000..8f949454aaf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_auto_rest_integer_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestIntegerTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestIntegerTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestIntegerTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyintegerlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyintegerlowlevel.rest import int + >>> request = int.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestIntegerTestService + 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/BodyIntegerLowLevel/bodyintegerlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_configuration.py new file mode 100644 index 00000000000..fc5968bb1a7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_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 AutoRestIntegerTestServiceConfiguration(Configuration): + """Configuration for AutoRestIntegerTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestIntegerTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestintegertestservice/{}".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/BodyIntegerLowLevel/bodyintegerlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/_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/BodyIntegerLowLevel/bodyintegerlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/aio/__init__.py new file mode 100644 index 00000000000..25de233a342 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/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 ._auto_rest_integer_test_service import AutoRestIntegerTestService + +__all__ = ["AutoRestIntegerTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/aio/_auto_rest_integer_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/aio/_auto_rest_integer_test_service.py new file mode 100644 index 00000000000..bd0356c251e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/aio/_auto_rest_integer_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestIntegerTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestIntegerTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestIntegerTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodyintegerlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodyintegerlowlevel.rest import int + >>> request = int.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestIntegerTestService": + 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/BodyIntegerLowLevel/bodyintegerlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..68ab8b27e32 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/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 AutoRestIntegerTestServiceConfiguration(Configuration): + """Configuration for AutoRestIntegerTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestIntegerTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestintegertestservice/{}".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/BodyIntegerLowLevel/bodyintegerlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/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/BodyIntegerLowLevel/bodyintegerlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/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/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/__init__.py new file mode 100644 index 00000000000..9ef9986b288 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/__init__.py @@ -0,0 +1,55 @@ +# 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_get_null_request + from ._request_builders_py3 import build_get_invalid_request + from ._request_builders_py3 import build_get_overflow_int32_request + from ._request_builders_py3 import build_get_underflow_int32_request + from ._request_builders_py3 import build_get_overflow_int64_request + from ._request_builders_py3 import build_get_underflow_int64_request + from ._request_builders_py3 import build_put_max32_request + from ._request_builders_py3 import build_put_max64_request + from ._request_builders_py3 import build_put_min32_request + from ._request_builders_py3 import build_put_min64_request + from ._request_builders_py3 import build_get_unix_time_request + from ._request_builders_py3 import build_put_unix_time_date_request + from ._request_builders_py3 import build_get_invalid_unix_time_request + from ._request_builders_py3 import build_get_null_unix_time_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_request # type: ignore + from ._request_builders import build_get_overflow_int32_request # type: ignore + from ._request_builders import build_get_underflow_int32_request # type: ignore + from ._request_builders import build_get_overflow_int64_request # type: ignore + from ._request_builders import build_get_underflow_int64_request # type: ignore + from ._request_builders import build_put_max32_request # type: ignore + from ._request_builders import build_put_max64_request # type: ignore + from ._request_builders import build_put_min32_request # type: ignore + from ._request_builders import build_put_min64_request # type: ignore + from ._request_builders import build_get_unix_time_request # type: ignore + from ._request_builders import build_put_unix_time_date_request # type: ignore + from ._request_builders import build_get_invalid_unix_time_request # type: ignore + from ._request_builders import build_get_null_unix_time_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_request", + "build_get_overflow_int32_request", + "build_get_underflow_int32_request", + "build_get_overflow_int64_request", + "build_get_underflow_int64_request", + "build_put_max32_request", + "build_put_max64_request", + "build_put_min32_request", + "build_put_min64_request", + "build_get_unix_time_request", + "build_put_unix_time_date_request", + "build_get_invalid_unix_time_request", + "build_get_null_unix_time_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/_request_builders.py new file mode 100644 index 00000000000..b02ce390e93 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/_request_builders.py @@ -0,0 +1,533 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_int32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/overflowint32') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_int32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/underflowint32') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_overflow_int64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get overflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/overflowint64') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_underflow_int64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get underflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/underflowint64') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_max32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/max/32') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_max64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put max int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "long (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/max/64') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_min32_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/min/32') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_min64_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put min int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "long (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/min/64') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_unix_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get datetime encoded as Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/unixtime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_unix_time_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put datetime encoded as Unix time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/unixtime') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_unix_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/invalidunixtime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_unix_time_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/int/nullunixtime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/_request_builders_py3.py new file mode 100644 index 00000000000..c2122649481 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/bodyintegerlowlevel/rest/int/_request_builders_py3.py @@ -0,0 +1,416 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_request(**kwargs: Any) -> HttpRequest: + """Get invalid Int value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_int32_request(**kwargs: Any) -> HttpRequest: + """Get overflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/overflowint32") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_int32_request(**kwargs: Any) -> HttpRequest: + """Get underflow Int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/underflowint32") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_overflow_int64_request(**kwargs: Any) -> HttpRequest: + """Get overflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/overflowint64") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_underflow_int64_request(**kwargs: Any) -> HttpRequest: + """Get underflow Int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/underflowint64") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_max32_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/max/32") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_max64_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put max int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "long (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/max/64") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_min32_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min int32 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/min/32") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_min64_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put min int64 value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "long (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/min/64") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_unix_time_request(**kwargs: Any) -> HttpRequest: + """Get datetime encoded as Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/unixtime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_unix_time_date_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put datetime encoded as Unix time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. int body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). int body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "datetime (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/unixtime") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_invalid_unix_time_request(**kwargs: Any) -> HttpRequest: + """Get invalid Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/invalidunixtime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_null_unix_time_request(**kwargs: Any) -> HttpRequest: + """Get null Unix time value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/int/nullunixtime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/setup.py new file mode 100644 index 00000000000..770bf745d71 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyIntegerLowLevel/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 = "autorestintegertestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestIntegerTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestIntegerTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/__init__.py new file mode 100644 index 00000000000..0a0bae3e998 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/__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 ._auto_rest_number_test_service import AutoRestNumberTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestNumberTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_auto_rest_number_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_auto_rest_number_test_service.py new file mode 100644 index 00000000000..ef30af11ba3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_auto_rest_number_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestNumberTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestNumberTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestNumberTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodynumberlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodynumberlowlevel.rest import number + >>> request = number.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestNumberTestService + 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/BodyNumberLowLevel/bodynumberlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_configuration.py new file mode 100644 index 00000000000..da1fbd323a5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_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 AutoRestNumberTestServiceConfiguration(Configuration): + """Configuration for AutoRestNumberTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestNumberTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestnumbertestservice/{}".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/BodyNumberLowLevel/bodynumberlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/_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/BodyNumberLowLevel/bodynumberlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/aio/__init__.py new file mode 100644 index 00000000000..6c0a67a8f1f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/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 ._auto_rest_number_test_service import AutoRestNumberTestService + +__all__ = ["AutoRestNumberTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/aio/_auto_rest_number_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/aio/_auto_rest_number_test_service.py new file mode 100644 index 00000000000..a85563db01e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/aio/_auto_rest_number_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestNumberTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestNumberTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestNumberTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodynumberlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodynumberlowlevel.rest import number + >>> request = number.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestNumberTestService": + 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/BodyNumberLowLevel/bodynumberlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..aa79cc51c32 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/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 AutoRestNumberTestServiceConfiguration(Configuration): + """Configuration for AutoRestNumberTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestNumberTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestnumbertestservice/{}".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/BodyNumberLowLevel/bodynumberlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/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/BodyNumberLowLevel/bodynumberlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/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/BodyNumberLowLevel/bodynumberlowlevel/rest/number/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/__init__.py new file mode 100644 index 00000000000..cce808da949 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_get_null_request + from ._request_builders_py3 import build_get_invalid_float_request + from ._request_builders_py3 import build_get_invalid_double_request + from ._request_builders_py3 import build_get_invalid_decimal_request + from ._request_builders_py3 import build_put_big_float_request + from ._request_builders_py3 import build_get_big_float_request + from ._request_builders_py3 import build_put_big_double_request + from ._request_builders_py3 import build_get_big_double_request + from ._request_builders_py3 import build_put_big_double_positive_decimal_request + from ._request_builders_py3 import build_get_big_double_positive_decimal_request + from ._request_builders_py3 import build_put_big_double_negative_decimal_request + from ._request_builders_py3 import build_get_big_double_negative_decimal_request + from ._request_builders_py3 import build_put_big_decimal_request + from ._request_builders_py3 import build_get_big_decimal_request + from ._request_builders_py3 import build_put_big_decimal_positive_decimal_request + from ._request_builders_py3 import build_get_big_decimal_positive_decimal_request + from ._request_builders_py3 import build_put_big_decimal_negative_decimal_request + from ._request_builders_py3 import build_get_big_decimal_negative_decimal_request + from ._request_builders_py3 import build_put_small_float_request + from ._request_builders_py3 import build_get_small_float_request + from ._request_builders_py3 import build_put_small_double_request + from ._request_builders_py3 import build_get_small_double_request + from ._request_builders_py3 import build_put_small_decimal_request + from ._request_builders_py3 import build_get_small_decimal_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_get_invalid_float_request # type: ignore + from ._request_builders import build_get_invalid_double_request # type: ignore + from ._request_builders import build_get_invalid_decimal_request # type: ignore + from ._request_builders import build_put_big_float_request # type: ignore + from ._request_builders import build_get_big_float_request # type: ignore + from ._request_builders import build_put_big_double_request # type: ignore + from ._request_builders import build_get_big_double_request # type: ignore + from ._request_builders import build_put_big_double_positive_decimal_request # type: ignore + from ._request_builders import build_get_big_double_positive_decimal_request # type: ignore + from ._request_builders import build_put_big_double_negative_decimal_request # type: ignore + from ._request_builders import build_get_big_double_negative_decimal_request # type: ignore + from ._request_builders import build_put_big_decimal_request # type: ignore + from ._request_builders import build_get_big_decimal_request # type: ignore + from ._request_builders import build_put_big_decimal_positive_decimal_request # type: ignore + from ._request_builders import build_get_big_decimal_positive_decimal_request # type: ignore + from ._request_builders import build_put_big_decimal_negative_decimal_request # type: ignore + from ._request_builders import build_get_big_decimal_negative_decimal_request # type: ignore + from ._request_builders import build_put_small_float_request # type: ignore + from ._request_builders import build_get_small_float_request # type: ignore + from ._request_builders import build_put_small_double_request # type: ignore + from ._request_builders import build_get_small_double_request # type: ignore + from ._request_builders import build_put_small_decimal_request # type: ignore + from ._request_builders import build_get_small_decimal_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_get_invalid_float_request", + "build_get_invalid_double_request", + "build_get_invalid_decimal_request", + "build_put_big_float_request", + "build_get_big_float_request", + "build_put_big_double_request", + "build_get_big_double_request", + "build_put_big_double_positive_decimal_request", + "build_get_big_double_positive_decimal_request", + "build_put_big_double_negative_decimal_request", + "build_get_big_double_negative_decimal_request", + "build_put_big_decimal_request", + "build_get_big_decimal_request", + "build_put_big_decimal_positive_decimal_request", + "build_get_big_decimal_positive_decimal_request", + "build_put_big_decimal_negative_decimal_request", + "build_get_big_decimal_negative_decimal_request", + "build_put_small_float_request", + "build_get_small_float_request", + "build_put_small_double_request", + "build_get_small_double_request", + "build_put_small_decimal_request", + "build_get_small_decimal_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/_request_builders.py new file mode 100644 index 00000000000..7c655ab728c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/_request_builders.py @@ -0,0 +1,922 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid float Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/invalidfloat') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid double Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/invaliddouble') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_invalid_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get invalid decimal Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/invaliddecimal') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/float/3.402823e+20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/float/3.402823e+20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/2.5976931e+101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/2.5976931e+101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_double_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_double_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_double_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/-99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_double_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/double/-99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/2.5976931e+101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/2.5976931e+101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_decimal_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_decimal_positive_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_big_decimal_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/-99999999.99') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_big_decimal_negative_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/big/decimal/-99999999.99') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_small_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put small float value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/float/3.402823e-20') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_small_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/float/3.402823e-20') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_small_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put small double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/double/2.5976931e-101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_small_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get big double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/double/2.5976931e-101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_small_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/decimal/2.5976931e-101') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_small_decimal_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/number/small/decimal/2.5976931e-101') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/_request_builders_py3.py new file mode 100644 index 00000000000..9c448484118 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/bodynumberlowlevel/rest/number/_request_builders_py3.py @@ -0,0 +1,733 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_float_request(**kwargs: Any) -> HttpRequest: + """Get invalid float Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/invalidfloat") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_double_request(**kwargs: Any) -> HttpRequest: + """Get invalid double Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/invaliddouble") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_invalid_decimal_request(**kwargs: Any) -> HttpRequest: + """Get invalid decimal Number value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/invaliddecimal") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_float_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/float/3.402823e+20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_float_request(**kwargs: Any) -> HttpRequest: + """Get big float value 3.402823e+20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/float/3.402823e+20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_double_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/2.5976931e+101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_double_request(**kwargs: Any) -> HttpRequest: + """Get big double value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/2.5976931e+101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_double_positive_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_double_positive_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big double value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_double_negative_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/-99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_double_negative_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big double value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/double/-99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_decimal_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/2.5976931e+101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big decimal value 2.5976931e+101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/2.5976931e+101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_decimal_positive_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_decimal_positive_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big decimal value 99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_big_decimal_negative_decimal_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/-99999999.99") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_big_decimal_negative_decimal_request(**kwargs: Any) -> HttpRequest: + """Get big decimal value -99999999.99. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/big/decimal/-99999999.99") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_small_float_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put small float value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/float/3.402823e-20") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_small_float_request(**kwargs: Any) -> HttpRequest: + """Get big double value 3.402823e-20. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/float/3.402823e-20") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_small_double_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put small double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/double/2.5976931e-101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_small_double_request(**kwargs: Any) -> HttpRequest: + """Get big double value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/double/2.5976931e-101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_small_decimal_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. number body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). number body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/decimal/2.5976931e-101") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_small_decimal_request(**kwargs: Any) -> HttpRequest: + """Get small decimal value 2.5976931e-101. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/number/small/decimal/2.5976931e-101") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/setup.py new file mode 100644 index 00000000000..c3cbe8a4696 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyNumberLowLevel/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 = "autorestnumbertestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestNumberTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestNumberTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/__init__.py new file mode 100644 index 00000000000..e64af9a6a74 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/__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 ._auto_rest_swagger_bat_service import AutoRestSwaggerBATService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_auto_rest_swagger_bat_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_auto_rest_swagger_bat_service.py new file mode 100644 index 00000000000..de47b61161e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_auto_rest_swagger_bat_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodystringlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodystringlowlevel.rest import string + >>> request = string.build_get_null_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATService + 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/BodyStringLowLevel/bodystringlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_configuration.py new file mode 100644 index 00000000000..79befee47c6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_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 AutoRestSwaggerBATServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatservice/{}".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/BodyStringLowLevel/bodystringlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/_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/BodyStringLowLevel/bodystringlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/aio/__init__.py new file mode 100644 index 00000000000..c2a9d122989 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/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 ._auto_rest_swagger_bat_service import AutoRestSwaggerBATService + +__all__ = ["AutoRestSwaggerBATService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/aio/_auto_rest_swagger_bat_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/aio/_auto_rest_swagger_bat_service.py new file mode 100644 index 00000000000..1672bc3e2ec --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/aio/_auto_rest_swagger_bat_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodystringlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodystringlowlevel.rest import string + >>> request = string.build_get_null_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATService": + 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/BodyStringLowLevel/bodystringlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..b78427e6b41 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/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 AutoRestSwaggerBATServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatservice/{}".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/BodyStringLowLevel/bodystringlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/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/BodyStringLowLevel/bodystringlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/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/BodyStringLowLevel/bodystringlowlevel/rest/enum/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/__init__.py new file mode 100644 index 00000000000..b47975af01f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/__init__.py @@ -0,0 +1,31 @@ +# 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_get_not_expandable_request + from ._request_builders_py3 import build_put_not_expandable_request + from ._request_builders_py3 import build_get_referenced_request + from ._request_builders_py3 import build_put_referenced_request + from ._request_builders_py3 import build_get_referenced_constant_request + from ._request_builders_py3 import build_put_referenced_constant_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_not_expandable_request # type: ignore + from ._request_builders import build_put_not_expandable_request # type: ignore + from ._request_builders import build_get_referenced_request # type: ignore + from ._request_builders import build_put_referenced_request # type: ignore + from ._request_builders import build_get_referenced_constant_request # type: ignore + from ._request_builders import build_put_referenced_constant_request # type: ignore + +__all__ = [ + "build_get_not_expandable_request", + "build_put_not_expandable_request", + "build_get_referenced_request", + "build_put_referenced_request", + "build_get_referenced_constant_request", + "build_put_referenced_constant_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/_request_builders.py new file mode 100644 index 00000000000..39d47e31af8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/_request_builders.py @@ -0,0 +1,264 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_not_expandable_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/notExpandable') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_not_expandable_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/notExpandable') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_referenced_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/Referenced') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_referenced_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/Referenced') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_referenced_constant_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get value 'green-color' from the constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "ColorConstant": "str", + "field1": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/ReferencedConstant') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_referenced_constant_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Sends value 'green-color' from a constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "ColorConstant": "str", + "field1": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/enum/ReferencedConstant') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/_request_builders_py3.py new file mode 100644 index 00000000000..db0e4aa0a99 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/enum/_request_builders_py3.py @@ -0,0 +1,211 @@ +# 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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_not_expandable_request(**kwargs: Any) -> HttpRequest: + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/notExpandable") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_not_expandable_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/notExpandable") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_referenced_request(**kwargs: Any) -> HttpRequest: + """Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/Referenced") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_referenced_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/Referenced") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_referenced_constant_request(**kwargs: Any) -> HttpRequest: + """Get value 'green-color' from the constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "ColorConstant": "str", + "field1": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/ReferencedConstant") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_referenced_constant_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Sends value 'green-color' from a constant. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. enum string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). enum string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "ColorConstant": "str", + "field1": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/enum/ReferencedConstant") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/__init__.py new file mode 100644 index 00000000000..9ace38ded20 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/__init__.py @@ -0,0 +1,52 @@ +# 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_get_null_request + from ._request_builders_py3 import build_put_null_request + from ._request_builders_py3 import build_get_empty_request + from ._request_builders_py3 import build_put_empty_request + from ._request_builders_py3 import build_get_mbcs_request + from ._request_builders_py3 import build_put_mbcs_request + from ._request_builders_py3 import build_get_whitespace_request + from ._request_builders_py3 import build_put_whitespace_request + from ._request_builders_py3 import build_get_not_provided_request + from ._request_builders_py3 import build_get_base64_encoded_request + from ._request_builders_py3 import build_get_base64_url_encoded_request + from ._request_builders_py3 import build_put_base64_url_encoded_request + from ._request_builders_py3 import build_get_null_base64_url_encoded_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_null_request # type: ignore + from ._request_builders import build_put_null_request # type: ignore + from ._request_builders import build_get_empty_request # type: ignore + from ._request_builders import build_put_empty_request # type: ignore + from ._request_builders import build_get_mbcs_request # type: ignore + from ._request_builders import build_put_mbcs_request # type: ignore + from ._request_builders import build_get_whitespace_request # type: ignore + from ._request_builders import build_put_whitespace_request # type: ignore + from ._request_builders import build_get_not_provided_request # type: ignore + from ._request_builders import build_get_base64_encoded_request # type: ignore + from ._request_builders import build_get_base64_url_encoded_request # type: ignore + from ._request_builders import build_put_base64_url_encoded_request # type: ignore + from ._request_builders import build_get_null_base64_url_encoded_request # type: ignore + +__all__ = [ + "build_get_null_request", + "build_put_null_request", + "build_get_empty_request", + "build_put_empty_request", + "build_get_mbcs_request", + "build_put_mbcs_request", + "build_get_whitespace_request", + "build_put_whitespace_request", + "build_get_not_provided_request", + "build_get_base64_encoded_request", + "build_get_base64_url_encoded_request", + "build_put_base64_url_encoded_request", + "build_get_null_base64_url_encoded_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/_request_builders.py new file mode 100644 index 00000000000..43100c61c74 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/_request_builders.py @@ -0,0 +1,505 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null string value value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/null') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set string value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/null') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty string value value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set string value empty ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/empty') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_mbcs_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/mbcs') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_mbcs_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/mbcs') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_whitespace_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get string value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/whitespace') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_whitespace_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Set String value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/whitespace') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_not_provided_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get String value when no string value is sent in response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/notProvided') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get value that is base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/base64Encoding') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_base64_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/base64UrlEncoding') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_base64_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bytes (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/base64UrlEncoding') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_null_base64_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null value that is expected to be base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/string/nullBase64UrlEncoding') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/_request_builders_py3.py new file mode 100644 index 00000000000..4c3788daa5e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/bodystringlowlevel/rest/string/_request_builders_py3.py @@ -0,0 +1,396 @@ +# 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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_null_request(**kwargs: Any) -> HttpRequest: + """Get null string value value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/null") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_null_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set string value null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/null") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty string value value ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set string value empty ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/empty") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_mbcs_request(**kwargs: Any) -> HttpRequest: + """Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/mbcs") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_mbcs_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/mbcs") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_whitespace_request(**kwargs: Any) -> HttpRequest: + """Get string value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/whitespace") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_whitespace_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Set String value with leading and trailing whitespace + ':code:``:code:``:code:``Now is the time for all good men to come to the aid + of their country:code:``:code:``:code:``'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/whitespace") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_not_provided_request(**kwargs: Any) -> HttpRequest: + """Get String value when no string value is sent in response payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/notProvided") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_encoded_request(**kwargs: Any) -> HttpRequest: + """Get value that is base64 encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/base64Encoding") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_base64_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/base64UrlEncoding") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_base64_url_encoded_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put value that is base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. string body. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). string body. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bytes (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/base64UrlEncoding") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_null_base64_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get null value that is expected to be base64url encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/string/nullBase64UrlEncoding") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/setup.py new file mode 100644 index 00000000000..b64368f0a3d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyStringLowLevel/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 = "autorestswaggerbatservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATService"], + 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/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/__init__.py new file mode 100644 index 00000000000..fcefd932c10 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/__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 ._auto_rest_time_test_service import AutoRestTimeTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestTimeTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_auto_rest_time_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_auto_rest_time_test_service.py new file mode 100644 index 00000000000..21a9f005838 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_auto_rest_time_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestTimeTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestTimeTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestTimeTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodytimelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodytimelowlevel.rest import time + >>> request = time.build_get_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestTimeTestService + 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/BodyTimeLowLevel/bodytimelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_configuration.py new file mode 100644 index 00000000000..afe602fc9d6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_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 AutoRestTimeTestServiceConfiguration(Configuration): + """Configuration for AutoRestTimeTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestTimeTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autoresttimetestservice/{}".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/BodyTimeLowLevel/bodytimelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/_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/BodyTimeLowLevel/bodytimelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/aio/__init__.py new file mode 100644 index 00000000000..9a1a1a62fc6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/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 ._auto_rest_time_test_service import AutoRestTimeTestService + +__all__ = ["AutoRestTimeTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/aio/_auto_rest_time_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/aio/_auto_rest_time_test_service.py new file mode 100644 index 00000000000..3e1ad9c5dec --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/aio/_auto_rest_time_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestTimeTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestTimeTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestTimeTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `bodytimelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from bodytimelowlevel.rest import time + >>> request = time.build_get_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestTimeTestService": + 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/BodyTimeLowLevel/bodytimelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..b77c2f46895 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/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 AutoRestTimeTestServiceConfiguration(Configuration): + """Configuration for AutoRestTimeTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestTimeTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autoresttimetestservice/{}".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/BodyTimeLowLevel/bodytimelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/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/BodyTimeLowLevel/bodytimelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/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/BodyTimeLowLevel/bodytimelowlevel/rest/time/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/__init__.py new file mode 100644 index 00000000000..355267c5498 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/__init__.py @@ -0,0 +1,19 @@ +# 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_get_request + from ._request_builders_py3 import build_put_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_request # type: ignore + from ._request_builders import build_put_request # type: ignore + +__all__ = [ + "build_get_request", + "build_put_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/_request_builders.py new file mode 100644 index 00000000000..1b6c72df14f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/_request_builders.py @@ -0,0 +1,97 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get time value "11:34:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/time/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put time value "08:07:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put time value "08:07:56" in parameter to pass testserver. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put time value "08:07:56" in parameter to pass testserver. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "time (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/time/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/_request_builders_py3.py new file mode 100644 index 00000000000..b6cb2423d19 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/bodytimelowlevel/rest/time/_request_builders_py3.py @@ -0,0 +1,76 @@ +# 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 datetime +from typing import Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get time value "11:34:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/time/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put time value "08:07:56". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put time value "08:07:56" in parameter to pass testserver. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put time value "08:07:56" in parameter to pass testserver. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "time (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/time/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/setup.py new file mode 100644 index 00000000000..92d1b4c9146 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyTimeLowLevel/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 = "autoresttimetestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestTimeTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestTimeTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/__init__.py new file mode 100644 index 00000000000..2e6bfbead69 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/__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 ._auto_rest_swagger_constant_service import AutoRestSwaggerConstantService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerConstantService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_auto_rest_swagger_constant_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_auto_rest_swagger_constant_service.py new file mode 100644 index 00000000000..634c87d641b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_auto_rest_swagger_constant_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerConstantServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerConstantService(object): + """Test Infrastructure for AutoRest Swagger Constant. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerConstantServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `constantslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from constantslowlevel.rest import contants + >>> request = contants.build_put_no_model_as_string_no_required_two_value_no_default_request(input=input, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerConstantService + 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/ConstantsLowLevel/constantslowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_configuration.py new file mode 100644 index 00000000000..ab1d288660f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_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 AutoRestSwaggerConstantServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerConstantService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerConstantServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerconstantservice/{}".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/ConstantsLowLevel/constantslowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/_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/ConstantsLowLevel/constantslowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/aio/__init__.py new file mode 100644 index 00000000000..3ae96a692bf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/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 ._auto_rest_swagger_constant_service import AutoRestSwaggerConstantService + +__all__ = ["AutoRestSwaggerConstantService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/aio/_auto_rest_swagger_constant_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/aio/_auto_rest_swagger_constant_service.py new file mode 100644 index 00000000000..9e5dd242bd2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/aio/_auto_rest_swagger_constant_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerConstantServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerConstantService: + """Test Infrastructure for AutoRest Swagger Constant. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerConstantServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `constantslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from constantslowlevel.rest import contants + >>> request = contants.build_put_no_model_as_string_no_required_two_value_no_default_request(input=input, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerConstantService": + 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/ConstantsLowLevel/constantslowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..272d0a67324 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/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 AutoRestSwaggerConstantServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerConstantService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerConstantServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerconstantservice/{}".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/ConstantsLowLevel/constantslowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/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/ConstantsLowLevel/constantslowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/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/ConstantsLowLevel/constantslowlevel/rest/contants/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/__init__.py new file mode 100644 index 00000000000..81d5ec39170 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/__init__.py @@ -0,0 +1,61 @@ +# 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_put_no_model_as_string_no_required_two_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_no_required_two_value_default_request + from ._request_builders_py3 import build_put_no_model_as_string_no_required_one_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_no_required_one_value_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_two_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_two_value_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_one_value_no_default_request + from ._request_builders_py3 import build_put_no_model_as_string_required_one_value_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_two_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_two_value_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_one_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_no_required_one_value_default_request + from ._request_builders_py3 import build_put_model_as_string_required_two_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_required_two_value_default_request + from ._request_builders_py3 import build_put_model_as_string_required_one_value_no_default_request + from ._request_builders_py3 import build_put_model_as_string_required_one_value_default_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_no_model_as_string_no_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_no_required_two_value_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_no_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_no_required_one_value_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_two_value_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_no_model_as_string_required_one_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_two_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_no_required_one_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_two_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_two_value_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_one_value_no_default_request # type: ignore + from ._request_builders import build_put_model_as_string_required_one_value_default_request # type: ignore + +__all__ = [ + "build_put_no_model_as_string_no_required_two_value_no_default_request", + "build_put_no_model_as_string_no_required_two_value_default_request", + "build_put_no_model_as_string_no_required_one_value_no_default_request", + "build_put_no_model_as_string_no_required_one_value_default_request", + "build_put_no_model_as_string_required_two_value_no_default_request", + "build_put_no_model_as_string_required_two_value_default_request", + "build_put_no_model_as_string_required_one_value_no_default_request", + "build_put_no_model_as_string_required_one_value_default_request", + "build_put_model_as_string_no_required_two_value_no_default_request", + "build_put_model_as_string_no_required_two_value_default_request", + "build_put_model_as_string_no_required_one_value_no_default_request", + "build_put_model_as_string_no_required_one_value_default_request", + "build_put_model_as_string_required_two_value_no_default_request", + "build_put_model_as_string_required_two_value_default_request", + "build_put_model_as_string_required_one_value_no_default_request", + "build_put_model_as_string_required_one_value_default_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/_request_builders.py new file mode 100644 index 00000000000..44c688c12ed --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/_request_builders.py @@ -0,0 +1,601 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_no_model_as_string_no_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', None) # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_no_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_no_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_no_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringNoRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input') # type: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.NoModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_no_model_as_string_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", '/constants/putNoModelAsStringRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', None) # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', None) # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_no_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringNoRequiredOneValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringNoRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_two_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input') # type: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredTwoValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_two_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredTwoValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_one_value_no_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredOneValueNoDefaultOpEnum + :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 + """ + + input = kwargs.pop('input') # type: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredOneValueNoDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_put_model_as_string_required_one_value_default_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredOneValueDefaultOpEnum + :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 + """ + + input = kwargs.pop('input', "value1") # type: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] + + # Construct URL + url = kwargs.pop("template_url", '/constants/putModelAsStringRequiredOneValueDefault') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['input'] = _SERIALIZER.query("input", input, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/_request_builders_py3.py new file mode 100644 index 00000000000..d8b16c9f500 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/constantslowlevel/rest/contants/_request_builders_py3.py @@ -0,0 +1,468 @@ +# 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, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_no_model_as_string_no_required_two_value_no_default_request( + *, input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.NoModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_no_required_two_value_default_request( + *, input: Optional[Union[str, "_models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.NoModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_no_required_one_value_no_default_request( + *, input: Optional[str] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_no_required_one_value_default_request( + *, input: Optional[str] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringNoRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_two_value_no_default_request( + *, input: Union[str, "_models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.NoModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_two_value_default_request( + *, input: Union[str, "_models.NoModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.NoModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_one_value_no_default_request(**kwargs: Any) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_no_model_as_string_required_one_value_default_request(**kwargs: Any) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + input = "value1" + # Construct URL + url = kwargs.pop("template_url", "/constants/putNoModelAsStringRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_two_value_no_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum"]] = None, **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.ModelAsStringNoRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_two_value_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredTwoValueDefaultOpEnum"]] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringNoRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_one_value_no_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum"]] = None, **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or + ~constantslowlevel.models.ModelAsStringNoRequiredOneValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_no_required_one_value_default_request( + *, input: Optional[Union[str, "_models.ModelAsStringNoRequiredOneValueDefaultOpEnum"]] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringNoRequiredOneValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringNoRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if input is not None: + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_two_value_no_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredTwoValueNoDefaultOpEnum"], **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredTwoValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredTwoValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_two_value_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredTwoValueDefaultOpEnum"] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredTwoValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredTwoValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_one_value_no_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredOneValueNoDefaultOpEnum"], **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredOneValueNoDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredOneValueNoDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) + + +def build_put_model_as_string_required_one_value_default_request( + *, input: Union[str, "_models.ModelAsStringRequiredOneValueDefaultOpEnum"] = "value1", **kwargs: Any +) -> HttpRequest: + """Puts constants to the testserver. + + Puts constants to the testserver. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword input: + :paramtype input: str or ~constantslowlevel.models.ModelAsStringRequiredOneValueDefaultOpEnum + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/constants/putModelAsStringRequiredOneValueDefault") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["input"] = _SERIALIZER.query("input", input, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/setup.py new file mode 100644 index 00000000000..122b3e88598 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ConstantsLowLevel/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 = "autorestswaggerconstantservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerConstantService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerConstantService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger Constant. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/__init__.py new file mode 100644 index 00000000000..b8067887b35 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/__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 ._auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestParameterizedHostTestClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_auto_rest_parameterized_host_test_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..d00e1ca9266 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,93 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedHostTestClient(object): + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurllowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurllowlevel.rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedHostTestClient + 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/CustomBaseUriLowLevel/custombaseurllowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_configuration.py new file mode 100644 index 00000000000..ad7661010a8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_configuration.py @@ -0,0 +1,57 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedHostTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__( + self, + host="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AutoRestParameterizedHostTestClientConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "autorestparameterizedhosttestclient/{}".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/CustomBaseUriLowLevel/custombaseurllowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/_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/CustomBaseUriLowLevel/custombaseurllowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/__init__.py new file mode 100644 index 00000000000..76852835031 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/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 ._auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient + +__all__ = ["AutoRestParameterizedHostTestClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_auto_rest_parameterized_host_test_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_auto_rest_parameterized_host_test_client.py new file mode 100644 index 00000000000..20af13c1141 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_auto_rest_parameterized_host_test_client.py @@ -0,0 +1,79 @@ +# 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, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestParameterizedHostTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestParameterizedHostTestClient: + """Test Infrastructure for AutoRest. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + base_url = "http://{accountName}{host}" + self._config = AutoRestParameterizedHostTestClientConfiguration(host, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurllowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurllowlevel.rest import paths + >>> request = paths.build_get_empty_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedHostTestClient": + 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/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_configuration.py new file mode 100644 index 00000000000..d8ad54e11fa --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/aio/_configuration.py @@ -0,0 +1,45 @@ +# 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 AutoRestParameterizedHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedHostTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param host: A string value that is used as a global part of the parameterized host. + :type host: str + """ + + def __init__(self, host: str = "host", **kwargs: Any) -> None: + if host is None: + raise ValueError("Parameter 'host' must not be None.") + super(AutoRestParameterizedHostTestClientConfiguration, self).__init__(**kwargs) + + self.host = host + kwargs.setdefault("sdk_moniker", "autorestparameterizedhosttestclient/{}".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/CustomBaseUriLowLevel/custombaseurllowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/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/CustomBaseUriLowLevel/custombaseurllowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/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/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/__init__.py new file mode 100644 index 00000000000..5daa0aa077d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/__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_get_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_request # type: ignore + +__all__ = [ + "build_get_empty_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders.py new file mode 100644 index 00000000000..0931964c6cb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders.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.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/customuri') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..5a2da7d8789 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/custombaseurllowlevel/rest/paths/_request_builders_py3.py @@ -0,0 +1,36 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_request(**kwargs: Any) -> HttpRequest: + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/customuri") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/setup.py new file mode 100644 index 00000000000..37d0593ce8f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriLowLevel/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 = "autorestparameterizedhosttestclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/__init__.py new file mode 100644 index 00000000000..d9f4fc39375 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/__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 ._auto_rest_parameterized_custom_host_test_client import AutoRestParameterizedCustomHostTestClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestParameterizedCustomHostTestClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_auto_rest_parameterized_custom_host_test_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_auto_rest_parameterized_custom_host_test_client.py new file mode 100644 index 00000000000..1ef77cf5ed9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_auto_rest_parameterized_custom_host_test_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestParameterizedCustomHostTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterizedCustomHostTestClient(object): + """Test Infrastructure for AutoRest. + + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the parameterized host. + Default value 'host'. + :type dns_suffix: str + """ + + def __init__( + self, + subscription_id, # type: str + dns_suffix="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = "{vault}{secret}{dnsSuffix}" + self._config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurlmoreoptionslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlmoreoptionslowlevel.rest import paths + >>> request = paths.build_get_empty_request(key_name, subscription_id, key_version=key_version, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "dnsSuffix": self._serialize.url( + "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True + ), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AutoRestParameterizedCustomHostTestClient + 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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_configuration.py new file mode 100644 index 00000000000..3f525fc4f1e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_configuration.py @@ -0,0 +1,63 @@ +# 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 AutoRestParameterizedCustomHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedCustomHostTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the parameterized host. Default value 'host'. + :type dns_suffix: str + """ + + def __init__( + self, + subscription_id, # type: str + dns_suffix="host", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if dns_suffix is None: + raise ValueError("Parameter 'dns_suffix' must not be None.") + super(AutoRestParameterizedCustomHostTestClientConfiguration, self).__init__(**kwargs) + + self.subscription_id = subscription_id + self.dns_suffix = dns_suffix + kwargs.setdefault("sdk_moniker", "autorestparameterizedcustomhosttestclient/{}".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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/_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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/__init__.py new file mode 100644 index 00000000000..12a8bb14752 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/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 ._auto_rest_parameterized_custom_host_test_client import AutoRestParameterizedCustomHostTestClient + +__all__ = ["AutoRestParameterizedCustomHostTestClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/_auto_rest_parameterized_custom_host_test_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/_auto_rest_parameterized_custom_host_test_client.py new file mode 100644 index 00000000000..c4b61ef58e4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/_auto_rest_parameterized_custom_host_test_client.py @@ -0,0 +1,84 @@ +# 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, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import AutoRestParameterizedCustomHostTestClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestParameterizedCustomHostTestClient: + """Test Infrastructure for AutoRest. + + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the parameterized host. + Default value 'host'. + :type dns_suffix: str + """ + + def __init__(self, subscription_id: str, dns_suffix: str = "host", **kwargs: Any) -> None: + base_url = "{vault}{secret}{dnsSuffix}" + self._config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `custombaseurlmoreoptionslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from custombaseurlmoreoptionslowlevel.rest import paths + >>> request = paths.build_get_empty_request(key_name, subscription_id, key_version=key_version, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) + path_format_arguments = { + "dnsSuffix": self._serialize.url( + "self._config.dns_suffix", self._config.dns_suffix, "str", skip_quote=True + ), + } + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AutoRestParameterizedCustomHostTestClient": + 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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..32e0abf2b2a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/aio/_configuration.py @@ -0,0 +1,50 @@ +# 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 AutoRestParameterizedCustomHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedCustomHostTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the parameterized host. Default value 'host'. + :type dns_suffix: str + """ + + def __init__(self, subscription_id: str, dns_suffix: str = "host", **kwargs: Any) -> None: + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if dns_suffix is None: + raise ValueError("Parameter 'dns_suffix' must not be None.") + super(AutoRestParameterizedCustomHostTestClientConfiguration, self).__init__(**kwargs) + + self.subscription_id = subscription_id + self.dns_suffix = dns_suffix + kwargs.setdefault("sdk_moniker", "autorestparameterizedcustomhosttestclient/{}".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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/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/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/__init__.py new file mode 100644 index 00000000000..5daa0aa077d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/__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_get_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_request # type: ignore + +__all__ = [ + "build_get_empty_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/_request_builders.py new file mode 100644 index 00000000000..34a5abdd325 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/_request_builders.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 typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_request( + key_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param key_name: The key name with value 'key1'. + :type key_name: str + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :keyword key_version: The key version. Default value 'v1'. + :paramtype key_version: str + :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 + """ + + key_version = kwargs.pop('key_version', "v1") # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/customuri/{subscriptionId}/{keyName}') + path_format_arguments = { + 'keyName': _SERIALIZER.url("key_name", key_name, 'str'), + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if key_version is not None: + query_parameters['keyVersion'] = _SERIALIZER.query("key_version", key_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..fbcd97e612b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/custombaseurlmoreoptionslowlevel/rest/paths/_request_builders_py3.py @@ -0,0 +1,55 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_request( + key_name: str, subscription_id: str, *, key_version: Optional[str] = "v1", **kwargs: Any +) -> HttpRequest: + """Get a 200 to test a valid base uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param key_name: The key name with value 'key1'. + :type key_name: str + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :keyword key_version: The key version. Default value 'v1'. + :paramtype key_version: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/customuri/{subscriptionId}/{keyName}") + path_format_arguments = { + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if key_version is not None: + query_parameters["keyVersion"] = _SERIALIZER.query("key_version", key_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/setup.py new file mode 100644 index 00000000000..be943bbad97 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel/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 = "autorestparameterizedcustomhosttestclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedCustomHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedCustomHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/__init__.py new file mode 100644 index 00000000000..6ca7f004efb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/__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 ._pet_store_inc import PetStoreInc +from ._version import VERSION + +__version__ = VERSION +__all__ = ["PetStoreInc"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_configuration.py new file mode 100644 index 00000000000..32885416ee0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_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 PetStoreIncConfiguration(Configuration): + """Configuration for PetStoreInc. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(PetStoreIncConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "petstoreinc/{}".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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_pet_store_inc.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_pet_store_inc.py new file mode 100644 index 00000000000..6c4d7f9e4a4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_pet_store_inc.py @@ -0,0 +1,91 @@ +# 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 PetStoreIncConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class PetStoreInc(object): + """PetStore. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = PetStoreIncConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `extensibleenumsswaggerlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from extensibleenumsswaggerlowlevel.rest import pet + >>> request = pet.build_get_by_pet_id_request(pet_id, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> PetStoreInc + 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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/_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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/__init__.py new file mode 100644 index 00000000000..9db477edf61 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/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 ._pet_store_inc import PetStoreInc + +__all__ = ["PetStoreInc"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..f20dc3de00b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/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 PetStoreIncConfiguration(Configuration): + """Configuration for PetStoreInc. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(PetStoreIncConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "petstoreinc/{}".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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/_pet_store_inc.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/_pet_store_inc.py new file mode 100644 index 00000000000..81c03191a01 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/aio/_pet_store_inc.py @@ -0,0 +1,77 @@ +# 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 PetStoreIncConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class PetStoreInc: + """PetStore. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = PetStoreIncConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `extensibleenumsswaggerlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from extensibleenumsswaggerlowlevel.rest import pet + >>> request = pet.build_get_by_pet_id_request(pet_id, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "PetStoreInc": + 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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/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/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/__init__.py new file mode 100644 index 00000000000..c2d46d43efe --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/__init__.py @@ -0,0 +1,19 @@ +# 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_get_by_pet_id_request + from ._request_builders_py3 import build_add_pet_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_by_pet_id_request # type: ignore + from ._request_builders import build_add_pet_request # type: ignore + +__all__ = [ + "build_get_by_pet_id_request", + "build_add_pet_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/_request_builders.py new file mode 100644 index 00000000000..3e9e94a94c2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/_request_builders.py @@ -0,0 +1,125 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_by_pet_id_request( + pet_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """get pet by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: Pet id. + :type pet_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "DaysOfWeek": "str (optional). Default value is \"Friday\"", + "IntEnum": "str", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/extensibleenums/pet/{petId}') + path_format_arguments = { + 'petId': _SERIALIZER.url("pet_id", pet_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_add_pet_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """add pet. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. pet param. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). pet param. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "DaysOfWeek": "str (optional). Default value is \"Friday\"", + "IntEnum": "str", + "name": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "DaysOfWeek": "str (optional). Default value is \"Friday\"", + "IntEnum": "str", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/extensibleenums/pet/addPet') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/_request_builders_py3.py new file mode 100644 index 00000000000..021499613bf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/extensibleenumsswaggerlowlevel/rest/pet/_request_builders_py3.py @@ -0,0 +1,103 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_by_pet_id_request(pet_id: str, **kwargs: Any) -> HttpRequest: + """get pet by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: Pet id. + :type pet_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "DaysOfWeek": "str (optional). Default value is \"Friday\"", + "IntEnum": "str", + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/extensibleenums/pet/{petId}") + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_add_pet_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """add pet. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. pet param. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). pet param. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "DaysOfWeek": "str (optional). Default value is \"Friday\"", + "IntEnum": "str", + "name": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "DaysOfWeek": "str (optional). Default value is \"Friday\"", + "IntEnum": "str", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/extensibleenums/pet/addPet") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/setup.py new file mode 100644 index 00000000000..dddcaae773f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ExtensibleEnumsLowLevel/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 = "petstoreinc" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="PetStoreInc", + author_email="", + url="", + keywords=["Swagger", "PetStoreInc"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + PetStore. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/__init__.py new file mode 100644 index 00000000000..4a074abe9db --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/__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 ._auto_rest_swagger_bat_header_service import AutoRestSwaggerBATHeaderService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATHeaderService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_auto_rest_swagger_bat_header_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_auto_rest_swagger_bat_header_service.py new file mode 100644 index 00000000000..79915d1f894 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_auto_rest_swagger_bat_header_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATHeaderServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATHeaderService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATHeaderServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `headerlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headerlowlevel.rest import header + >>> request = header.build_param_existing_key_request(user_agent_parameter=user_agent_parameter, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATHeaderService + 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/HeaderLowLevel/headerlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_configuration.py new file mode 100644 index 00000000000..25a01661b0c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_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 AutoRestSwaggerBATHeaderServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATHeaderService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATHeaderServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatheaderservice/{}".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/HeaderLowLevel/headerlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/_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/HeaderLowLevel/headerlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/aio/__init__.py new file mode 100644 index 00000000000..0890ed44164 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/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 ._auto_rest_swagger_bat_header_service import AutoRestSwaggerBATHeaderService + +__all__ = ["AutoRestSwaggerBATHeaderService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/aio/_auto_rest_swagger_bat_header_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/aio/_auto_rest_swagger_bat_header_service.py new file mode 100644 index 00000000000..fb1a39a1be5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/aio/_auto_rest_swagger_bat_header_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATHeaderServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATHeaderService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATHeaderServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `headerlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from headerlowlevel.rest import header + >>> request = header.build_param_existing_key_request(user_agent_parameter=user_agent_parameter, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATHeaderService": + 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/HeaderLowLevel/headerlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..d7e96d2334c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/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 AutoRestSwaggerBATHeaderServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATHeaderService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATHeaderServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatheaderservice/{}".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/HeaderLowLevel/headerlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/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/HeaderLowLevel/headerlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/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/HeaderLowLevel/headerlowlevel/rest/header/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/__init__.py new file mode 100644 index 00000000000..62ca0400102 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/__init__.py @@ -0,0 +1,100 @@ +# 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_param_existing_key_request + from ._request_builders_py3 import build_response_existing_key_request + from ._request_builders_py3 import build_param_protected_key_request + from ._request_builders_py3 import build_response_protected_key_request + from ._request_builders_py3 import build_param_integer_request + from ._request_builders_py3 import build_response_integer_request + from ._request_builders_py3 import build_param_long_request + from ._request_builders_py3 import build_response_long_request + from ._request_builders_py3 import build_param_float_request + from ._request_builders_py3 import build_response_float_request + from ._request_builders_py3 import build_param_double_request + from ._request_builders_py3 import build_response_double_request + from ._request_builders_py3 import build_param_bool_request + from ._request_builders_py3 import build_response_bool_request + from ._request_builders_py3 import build_param_string_request + from ._request_builders_py3 import build_response_string_request + from ._request_builders_py3 import build_param_date_request + from ._request_builders_py3 import build_response_date_request + from ._request_builders_py3 import build_param_datetime_request + from ._request_builders_py3 import build_response_datetime_request + from ._request_builders_py3 import build_param_datetime_rfc1123_request + from ._request_builders_py3 import build_response_datetime_rfc1123_request + from ._request_builders_py3 import build_param_duration_request + from ._request_builders_py3 import build_response_duration_request + from ._request_builders_py3 import build_param_byte_request + from ._request_builders_py3 import build_response_byte_request + from ._request_builders_py3 import build_param_enum_request + from ._request_builders_py3 import build_response_enum_request + from ._request_builders_py3 import build_custom_request_id_request +except (SyntaxError, ImportError): + from ._request_builders import build_param_existing_key_request # type: ignore + from ._request_builders import build_response_existing_key_request # type: ignore + from ._request_builders import build_param_protected_key_request # type: ignore + from ._request_builders import build_response_protected_key_request # type: ignore + from ._request_builders import build_param_integer_request # type: ignore + from ._request_builders import build_response_integer_request # type: ignore + from ._request_builders import build_param_long_request # type: ignore + from ._request_builders import build_response_long_request # type: ignore + from ._request_builders import build_param_float_request # type: ignore + from ._request_builders import build_response_float_request # type: ignore + from ._request_builders import build_param_double_request # type: ignore + from ._request_builders import build_response_double_request # type: ignore + from ._request_builders import build_param_bool_request # type: ignore + from ._request_builders import build_response_bool_request # type: ignore + from ._request_builders import build_param_string_request # type: ignore + from ._request_builders import build_response_string_request # type: ignore + from ._request_builders import build_param_date_request # type: ignore + from ._request_builders import build_response_date_request # type: ignore + from ._request_builders import build_param_datetime_request # type: ignore + from ._request_builders import build_response_datetime_request # type: ignore + from ._request_builders import build_param_datetime_rfc1123_request # type: ignore + from ._request_builders import build_response_datetime_rfc1123_request # type: ignore + from ._request_builders import build_param_duration_request # type: ignore + from ._request_builders import build_response_duration_request # type: ignore + from ._request_builders import build_param_byte_request # type: ignore + from ._request_builders import build_response_byte_request # type: ignore + from ._request_builders import build_param_enum_request # type: ignore + from ._request_builders import build_response_enum_request # type: ignore + from ._request_builders import build_custom_request_id_request # type: ignore + +__all__ = [ + "build_param_existing_key_request", + "build_response_existing_key_request", + "build_param_protected_key_request", + "build_response_protected_key_request", + "build_param_integer_request", + "build_response_integer_request", + "build_param_long_request", + "build_response_long_request", + "build_param_float_request", + "build_response_float_request", + "build_param_double_request", + "build_response_double_request", + "build_param_bool_request", + "build_response_bool_request", + "build_param_string_request", + "build_response_string_request", + "build_param_date_request", + "build_response_date_request", + "build_param_datetime_request", + "build_response_datetime_request", + "build_param_datetime_rfc1123_request", + "build_response_datetime_rfc1123_request", + "build_param_duration_request", + "build_response_duration_request", + "build_param_byte_request", + "build_response_byte_request", + "build_param_enum_request", + "build_response_enum_request", + "build_custom_request_id_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/_request_builders.py new file mode 100644 index 00000000000..afdd80920cd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/_request_builders.py @@ -0,0 +1,1116 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_param_existing_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". + :paramtype user_agent_parameter: str + :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 + """ + + user_agent_parameter = kwargs.pop('user_agent_parameter') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/existingkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['User-Agent'] = _SERIALIZER.header("user_agent_parameter", user_agent_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_existing_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/existingkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_protected_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + content_type = kwargs.pop('content_type') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/protectedkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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, + **kwargs + ) + + +def build_response_protected_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/protectedkey') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_integer_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 1 or -2. + :paramtype value: int + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: int + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/integer') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_integer_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 1 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/integer') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 105 or -2. + :paramtype value: long + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: int + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'long') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_long_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 105 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 0.07 or -3.0. + :paramtype value: float + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: float + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'float') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_float_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 0.07 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 7e120 or -3.0. + :paramtype value: float + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: float + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/double') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'float') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_double_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": 7e120 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/double') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "true", "value": true or "scenario": + "false", "value": false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :keyword value: Send a post request with header values true or false. + :paramtype value: bool + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: bool + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'bool') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_bool_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header value "value": true or false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps + over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values "The quick brown fox jumps over the lazy + dog" or null or "". + :paramtype value: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + if value is not None: + header_parameters['value'] = _SERIALIZER.header("value", value, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_string_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/string') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or + "scenario": "min", "value": "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01" or "0001-01-01". + :paramtype value: ~datetime.date + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: datetime.date + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'date') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_date_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "2010-01-01" or "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_datetime_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or + "scenario": "min", "value": "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01T12:34:56Z" or + "0001-01-01T00:00:00Z". + :paramtype value: ~datetime.datetime + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: datetime.datetime + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/datetime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'iso-8601') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_datetime_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/datetime') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_datetime_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 + GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, + 01 Jan 0001 00:00:00 GMT". + :paramtype value: ~datetime.datetime + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value', None) # type: Optional[datetime.datetime] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/datetimerfc1123') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + if value is not None: + header_parameters['value'] = _SERIALIZER.header("value", value, 'rfc-1123') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_datetime_rfc1123_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 + GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/datetimerfc1123') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "P123DT22H14M12.011S". + :paramtype value: ~datetime.timedelta + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: datetime.timedelta + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/duration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'duration') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_duration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/duration') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". + :paramtype value: bytearray + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value') # type: bytearray + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/byte') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['value'] = _SERIALIZER.header("value", value, 'bytearray') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/byte') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_param_enum_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": + "null", "value": null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values 'GREY'. + :paramtype value: str or ~headerlowlevel.models.GreyscaleColors + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + value = kwargs.pop('value', None) # type: Optional[Union[str, "_models.GreyscaleColors"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/param/prim/enum') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + if value is not None: + header_parameters['value'] = _SERIALIZER.header("value", value, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_response_enum_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a response with header values "GREY" or null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + scenario = kwargs.pop('scenario') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/response/prim/enum') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['scenario'] = _SERIALIZER.header("scenario", scenario, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_custom_request_id_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the + request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/_request_builders_py3.py new file mode 100644 index 00000000000..f4bfd5061cc --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/headerlowlevel/rest/header/_request_builders_py3.py @@ -0,0 +1,821 @@ +# 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 datetime +from typing import Any, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_param_existing_key_request(*, user_agent_parameter: str, **kwargs: Any) -> HttpRequest: + """Send a post request with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword user_agent_parameter: Send a post request with header value "User-Agent": "overwrite". + :paramtype user_agent_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/existingkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["User-Agent"] = _SERIALIZER.header("user_agent_parameter", user_agent_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_existing_key_request(**kwargs: Any) -> HttpRequest: + """Get a response with header value "User-Agent": "overwrite". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/existingkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_protected_key_request(**kwargs: Any) -> HttpRequest: + """Send a post request with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + content_type = kwargs.pop("content_type") # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/protectedkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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, **kwargs) + + +def build_response_protected_key_request(**kwargs: Any) -> HttpRequest: + """Get a response with header value "Content-Type": "text/html". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/protectedkey") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_integer_request(*, scenario: str, value: int, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 1 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 1 or -2. + :paramtype value: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/integer") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_integer_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 1 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/integer") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_long_request(*, scenario: str, value: int, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 105 or "scenario": + "negative", "value": -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 105 or -2. + :paramtype value: long + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "long") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_long_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 105 or -2. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_float_request(*, scenario: str, value: float, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 0.07 or -3.0. + :paramtype value: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "float") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_float_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 0.07 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_double_request(*, scenario: str, value: float, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": + "negative", "value": -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :keyword value: Send a post request with header values 7e120 or -3.0. + :paramtype value: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/double") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "float") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_double_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": 7e120 or -3.0. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "positive" or "negative". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/double") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_bool_request(*, scenario: str, value: bool, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "true", "value": true or "scenario": + "false", "value": false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :keyword value: Send a post request with header values true or false. + :paramtype value: bool + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "bool") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_bool_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header value "value": true or false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "true" or "false". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_string_request(*, scenario: str, value: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps + over the lazy dog" or "scenario": "null", "value": null or "scenario": "empty", "value": "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values "The quick brown fox jumps over the lazy + dog" or null or "". + :paramtype value: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + if value is not None: + header_parameters["value"] = _SERIALIZER.header("value", value, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_string_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/string") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_date_request(*, scenario: str, value: datetime.date, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "2010-01-01" or + "scenario": "min", "value": "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01" or "0001-01-01". + :paramtype value: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "date") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_date_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "2010-01-01" or "0001-01-01". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_datetime_request(*, scenario: str, value: datetime.datetime, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or + "scenario": "min", "value": "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "2010-01-01T12:34:56Z" or + "0001-01-01T00:00:00Z". + :paramtype value: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/datetime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "iso-8601") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_datetime_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/datetime") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_datetime_rfc1123_request( + *, scenario: str, value: Optional[datetime.datetime] = None, **kwargs: Any +) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 + GMT" or "scenario": "min", "value": "Mon, 01 Jan 0001 00:00:00 GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :keyword value: Send a post request with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, + 01 Jan 0001 00:00:00 GMT". + :paramtype value: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/datetimerfc1123") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + if value is not None: + header_parameters["value"] = _SERIALIZER.header("value", value, "rfc-1123") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_datetime_rfc1123_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 + GMT". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "min". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/datetimerfc1123") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_duration_request(*, scenario: str, value: datetime.timedelta, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "P123DT22H14M12.011S". + :paramtype value: ~datetime.timedelta + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/duration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "duration") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_duration_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "P123DT22H14M12.011S". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/duration") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_byte_request(*, scenario: str, value: bytearray, **kwargs: Any) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :keyword value: Send a post request with header values "啊齄丂狛狜隣郎隣兀﨩". + :paramtype value: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/byte") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["value"] = _SERIALIZER.header("value", value, "bytearray") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_byte_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "啊齄丂狛狜隣郎隣兀﨩". + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/byte") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_param_enum_request( + *, scenario: str, value: Optional[Union[str, "_models.GreyscaleColors"]] = None, **kwargs: Any +) -> HttpRequest: + """Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": + "null", "value": null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :keyword value: Send a post request with header values 'GREY'. + :paramtype value: str or ~headerlowlevel.models.GreyscaleColors + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/param/prim/enum") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + if value is not None: + header_parameters["value"] = _SERIALIZER.header("value", value, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_response_enum_request(*, scenario: str, **kwargs: Any) -> HttpRequest: + """Get a response with header values "GREY" or null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword scenario: Send a post request with header values "scenario": "valid" or "null" or + "empty". + :paramtype scenario: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/response/prim/enum") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["scenario"] = _SERIALIZER.header("scenario", scenario, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_custom_request_id_request(**kwargs: Any) -> HttpRequest: + """Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the + request. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/setup.py new file mode 100644 index 00000000000..6e39f645217 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HeaderLowLevel/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 = "autorestswaggerbatheaderservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATHeaderService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATHeaderService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/__init__.py new file mode 100644 index 00000000000..95a3254c497 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/__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 ._auto_rest_http_infrastructure_test_service import AutoRestHttpInfrastructureTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestHttpInfrastructureTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_auto_rest_http_infrastructure_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_auto_rest_http_infrastructure_test_service.py new file mode 100644 index 00000000000..dc6d6b7653e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_auto_rest_http_infrastructure_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestHttpInfrastructureTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestHttpInfrastructureTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHttpInfrastructureTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `httpinfrastructurelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from httpinfrastructurelowlevel.rest import http_failure + >>> request = http_failure.build_get_empty_error_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestHttpInfrastructureTestService + 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/HttpLowLevel/httpinfrastructurelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_configuration.py new file mode 100644 index 00000000000..4ec368ae08d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_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 AutoRestHttpInfrastructureTestServiceConfiguration(Configuration): + """Configuration for AutoRestHttpInfrastructureTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestHttpInfrastructureTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autoresthttpinfrastructuretestservice/{}".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/HttpLowLevel/httpinfrastructurelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/_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/HttpLowLevel/httpinfrastructurelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/aio/__init__.py new file mode 100644 index 00000000000..77bad56f56a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/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 ._auto_rest_http_infrastructure_test_service import AutoRestHttpInfrastructureTestService + +__all__ = ["AutoRestHttpInfrastructureTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/aio/_auto_rest_http_infrastructure_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/aio/_auto_rest_http_infrastructure_test_service.py new file mode 100644 index 00000000000..afc404f0ad4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/aio/_auto_rest_http_infrastructure_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestHttpInfrastructureTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestHttpInfrastructureTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestHttpInfrastructureTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `httpinfrastructurelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from httpinfrastructurelowlevel.rest import http_failure + >>> request = http_failure.build_get_empty_error_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestHttpInfrastructureTestService": + 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/HttpLowLevel/httpinfrastructurelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..3e8df985edb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/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 AutoRestHttpInfrastructureTestServiceConfiguration(Configuration): + """Configuration for AutoRestHttpInfrastructureTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestHttpInfrastructureTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autoresthttpinfrastructuretestservice/{}".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/HttpLowLevel/httpinfrastructurelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/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/HttpLowLevel/httpinfrastructurelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/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/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/__init__.py new file mode 100644 index 00000000000..014c45ac99e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/__init__.py @@ -0,0 +1,91 @@ +# 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_head400_request + from ._request_builders_py3 import build_get400_request + from ._request_builders_py3 import build_options400_request + from ._request_builders_py3 import build_put400_request + from ._request_builders_py3 import build_patch400_request + from ._request_builders_py3 import build_post400_request + from ._request_builders_py3 import build_delete400_request + from ._request_builders_py3 import build_head401_request + from ._request_builders_py3 import build_get402_request + from ._request_builders_py3 import build_options403_request + from ._request_builders_py3 import build_get403_request + from ._request_builders_py3 import build_put404_request + from ._request_builders_py3 import build_patch405_request + from ._request_builders_py3 import build_post406_request + from ._request_builders_py3 import build_delete407_request + from ._request_builders_py3 import build_put409_request + from ._request_builders_py3 import build_head410_request + from ._request_builders_py3 import build_get411_request + from ._request_builders_py3 import build_options412_request + from ._request_builders_py3 import build_get412_request + from ._request_builders_py3 import build_put413_request + from ._request_builders_py3 import build_patch414_request + from ._request_builders_py3 import build_post415_request + from ._request_builders_py3 import build_get416_request + from ._request_builders_py3 import build_delete417_request + from ._request_builders_py3 import build_head429_request +except (SyntaxError, ImportError): + from ._request_builders import build_head400_request # type: ignore + from ._request_builders import build_get400_request # type: ignore + from ._request_builders import build_options400_request # type: ignore + from ._request_builders import build_put400_request # type: ignore + from ._request_builders import build_patch400_request # type: ignore + from ._request_builders import build_post400_request # type: ignore + from ._request_builders import build_delete400_request # type: ignore + from ._request_builders import build_head401_request # type: ignore + from ._request_builders import build_get402_request # type: ignore + from ._request_builders import build_options403_request # type: ignore + from ._request_builders import build_get403_request # type: ignore + from ._request_builders import build_put404_request # type: ignore + from ._request_builders import build_patch405_request # type: ignore + from ._request_builders import build_post406_request # type: ignore + from ._request_builders import build_delete407_request # type: ignore + from ._request_builders import build_put409_request # type: ignore + from ._request_builders import build_head410_request # type: ignore + from ._request_builders import build_get411_request # type: ignore + from ._request_builders import build_options412_request # type: ignore + from ._request_builders import build_get412_request # type: ignore + from ._request_builders import build_put413_request # type: ignore + from ._request_builders import build_patch414_request # type: ignore + from ._request_builders import build_post415_request # type: ignore + from ._request_builders import build_get416_request # type: ignore + from ._request_builders import build_delete417_request # type: ignore + from ._request_builders import build_head429_request # type: ignore + +__all__ = [ + "build_head400_request", + "build_get400_request", + "build_options400_request", + "build_put400_request", + "build_patch400_request", + "build_post400_request", + "build_delete400_request", + "build_head401_request", + "build_get402_request", + "build_options403_request", + "build_get403_request", + "build_put404_request", + "build_patch405_request", + "build_post406_request", + "build_delete407_request", + "build_put409_request", + "build_head410_request", + "build_get411_request", + "build_options412_request", + "build_get412_request", + "build_put413_request", + "build_patch414_request", + "build_post415_request", + "build_get416_request", + "build_delete417_request", + "build_head429_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/_request_builders.py new file mode 100644 index 00000000000..0724ca2d413 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/_request_builders.py @@ -0,0 +1,1032 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete400_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/400') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head401_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 401 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/401') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get402_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 402 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/402') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options403_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/403') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get403_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/403') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/404') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch405_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 405 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/405') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post406_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 406 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/406') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete407_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 407 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/407') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put409_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 409 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/409') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head410_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 410 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/410') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get411_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 411 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/411') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options412_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/412') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get412_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/412') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put413_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 413 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/413') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch414_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 414 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/414') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post415_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 415 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/415') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get416_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 416 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/416') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete417_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 417 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/417') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head429_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 429 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/client/429') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/_request_builders_py3.py new file mode 100644 index 00000000000..06f2c6871c3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_client_failure/_request_builders_py3.py @@ -0,0 +1,819 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head400_request(**kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get400_request(**kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options400_request(**kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_put400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete400_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 400 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/400") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head401_request(**kwargs: Any) -> HttpRequest: + """Return 401 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/401") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get402_request(**kwargs: Any) -> HttpRequest: + """Return 402 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/402") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options403_request(**kwargs: Any) -> HttpRequest: + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/403") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_get403_request(**kwargs: Any) -> HttpRequest: + """Return 403 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/403") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put404_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 404 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/404") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch405_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 405 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/405") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post406_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 406 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/406") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete407_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 407 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/407") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put409_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 409 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/409") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head410_request(**kwargs: Any) -> HttpRequest: + """Return 410 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/410") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get411_request(**kwargs: Any) -> HttpRequest: + """Return 411 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/411") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options412_request(**kwargs: Any) -> HttpRequest: + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/412") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_get412_request(**kwargs: Any) -> HttpRequest: + """Return 412 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/412") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put413_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 413 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/413") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch414_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 414 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/414") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post415_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 415 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/415") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get416_request(**kwargs: Any) -> HttpRequest: + """Return 416 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/416") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_delete417_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 417 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/417") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head429_request(**kwargs: Any) -> HttpRequest: + """Return 429 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/client/429") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/__init__.py new file mode 100644 index 00000000000..9aa026c9102 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/__init__.py @@ -0,0 +1,22 @@ +# 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_get_empty_error_request + from ._request_builders_py3 import build_get_no_model_error_request + from ._request_builders_py3 import build_get_no_model_empty_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_empty_error_request # type: ignore + from ._request_builders import build_get_no_model_error_request # type: ignore + from ._request_builders import build_get_no_model_empty_request # type: ignore + +__all__ = [ + "build_get_empty_error_request", + "build_get_no_model_error_request", + "build_get_no_model_empty_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/_request_builders.py new file mode 100644 index 00000000000..37537fc261e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/_request_builders.py @@ -0,0 +1,111 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_empty_error_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/emptybody/error') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_no_model_error_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/nomodel/error') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_no_model_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get empty response from server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/nomodel/empty') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/_request_builders_py3.py new file mode 100644 index 00000000000..d08e3bc8822 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_failure/_request_builders_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 Any, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_empty_error_request(**kwargs: Any) -> HttpRequest: + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/emptybody/error") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_no_model_error_request(**kwargs: Any) -> HttpRequest: + """Get empty error form server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/nomodel/error") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_no_model_empty_request(**kwargs: Any) -> HttpRequest: + """Get empty response from server. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/nomodel/empty") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/__init__.py new file mode 100644 index 00000000000..32da62631a7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/__init__.py @@ -0,0 +1,61 @@ +# 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_head300_request + from ._request_builders_py3 import build_get300_request + from ._request_builders_py3 import build_head301_request + from ._request_builders_py3 import build_get301_request + from ._request_builders_py3 import build_put301_request + from ._request_builders_py3 import build_head302_request + from ._request_builders_py3 import build_get302_request + from ._request_builders_py3 import build_patch302_request + from ._request_builders_py3 import build_post303_request + from ._request_builders_py3 import build_head307_request + from ._request_builders_py3 import build_get307_request + from ._request_builders_py3 import build_options307_request + from ._request_builders_py3 import build_put307_request + from ._request_builders_py3 import build_patch307_request + from ._request_builders_py3 import build_post307_request + from ._request_builders_py3 import build_delete307_request +except (SyntaxError, ImportError): + from ._request_builders import build_head300_request # type: ignore + from ._request_builders import build_get300_request # type: ignore + from ._request_builders import build_head301_request # type: ignore + from ._request_builders import build_get301_request # type: ignore + from ._request_builders import build_put301_request # type: ignore + from ._request_builders import build_head302_request # type: ignore + from ._request_builders import build_get302_request # type: ignore + from ._request_builders import build_patch302_request # type: ignore + from ._request_builders import build_post303_request # type: ignore + from ._request_builders import build_head307_request # type: ignore + from ._request_builders import build_get307_request # type: ignore + from ._request_builders import build_options307_request # type: ignore + from ._request_builders import build_put307_request # type: ignore + from ._request_builders import build_patch307_request # type: ignore + from ._request_builders import build_post307_request # type: ignore + from ._request_builders import build_delete307_request # type: ignore + +__all__ = [ + "build_head300_request", + "build_get300_request", + "build_head301_request", + "build_get301_request", + "build_put301_request", + "build_head302_request", + "build_get302_request", + "build_patch302_request", + "build_post303_request", + "build_head307_request", + "build_get307_request", + "build_options307_request", + "build_put307_request", + "build_patch307_request", + "build_post307_request", + "build_delete307_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/_request_builders.py new file mode 100644 index 00000000000..c6aaf54b458 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/_request_builders.py @@ -0,0 +1,637 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head300_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get300_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 300 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/300') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head301_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/301') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get301_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/301') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put301_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 301. This request should not be automatically + redirected, but should return the received 301 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/301') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head302_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/302') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get302_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/302') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch302_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returns 302. This request should not be automatically + redirected, but should return the received 302 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/302') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post303_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 303. This request should be automatically + redirected usign a get, ultimately returning a 200 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/303') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Redirect with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Redirect get with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """options redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete307_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/redirect/307') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/_request_builders_py3.py new file mode 100644 index 00000000000..fe37921cf33 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_redirects/_request_builders_py3.py @@ -0,0 +1,504 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head300_request(**kwargs: Any) -> HttpRequest: + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get300_request(**kwargs: Any) -> HttpRequest: + """Return 300 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 300 + response.json() == [ + "str (optional)" + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/300") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_head301_request(**kwargs: Any) -> HttpRequest: + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/301") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get301_request(**kwargs: Any) -> HttpRequest: + """Return 301 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/301") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put301_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 301. This request should not be automatically + redirected, but should return the received 301 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/301") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head302_request(**kwargs: Any) -> HttpRequest: + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/302") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get302_request(**kwargs: Any) -> HttpRequest: + """Return 302 status code and redirect to /http/success/200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/302") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_patch302_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returns 302. This request should not be automatically + redirected, but should return the received 302 to the caller for evaluation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/302") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post303_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 303. This request should be automatically + redirected usign a get, ultimately returning a 200 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/303") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head307_request(**kwargs: Any) -> HttpRequest: + """Redirect with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get307_request(**kwargs: Any) -> HttpRequest: + """Redirect get with 307, resulting in a 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options307_request(**kwargs: Any) -> HttpRequest: + """options redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_put307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete307_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete redirected with 307, resulting in a 200 after redirect. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/redirect/307") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/__init__.py new file mode 100644 index 00000000000..c645a81dabd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/__init__.py @@ -0,0 +1,40 @@ +# 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_head408_request + from ._request_builders_py3 import build_put500_request + from ._request_builders_py3 import build_patch500_request + from ._request_builders_py3 import build_get502_request + from ._request_builders_py3 import build_options502_request + from ._request_builders_py3 import build_post503_request + from ._request_builders_py3 import build_delete503_request + from ._request_builders_py3 import build_put504_request + from ._request_builders_py3 import build_patch504_request +except (SyntaxError, ImportError): + from ._request_builders import build_head408_request # type: ignore + from ._request_builders import build_put500_request # type: ignore + from ._request_builders import build_patch500_request # type: ignore + from ._request_builders import build_get502_request # type: ignore + from ._request_builders import build_options502_request # type: ignore + from ._request_builders import build_post503_request # type: ignore + from ._request_builders import build_delete503_request # type: ignore + from ._request_builders import build_put504_request # type: ignore + from ._request_builders import build_patch504_request # type: ignore + +__all__ = [ + "build_head408_request", + "build_put500_request", + "build_patch500_request", + "build_get502_request", + "build_options502_request", + "build_post503_request", + "build_delete503_request", + "build_put504_request", + "build_patch504_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/_request_builders.py new file mode 100644 index 00000000000..56106f4dddb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/_request_builders.py @@ -0,0 +1,393 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head408_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 408 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/408') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put500_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/500') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch500_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/500') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get502_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/502') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options502_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/502') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post503_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/503') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete503_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/503') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put504_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/504') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch504_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/retry/504') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/_request_builders_py3.py new file mode 100644 index 00000000000..d09d7f6d71f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_retry/_request_builders_py3.py @@ -0,0 +1,316 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head408_request(**kwargs: Any) -> HttpRequest: + """Return 408 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/408") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_put500_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/500") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch500_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 500 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/500") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get502_request(**kwargs: Any) -> HttpRequest: + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/502") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options502_request(**kwargs: Any) -> HttpRequest: + """Return 502 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/502") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_post503_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/503") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete503_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 503 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/503") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put504_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/504") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch504_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 504 status code, then 200 after retry. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/retry/504") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/__init__.py new file mode 100644 index 00000000000..6c9509398a2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/__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 ._request_builders_py3 import build_head501_request + from ._request_builders_py3 import build_get501_request + from ._request_builders_py3 import build_post505_request + from ._request_builders_py3 import build_delete505_request +except (SyntaxError, ImportError): + from ._request_builders import build_head501_request # type: ignore + from ._request_builders import build_get501_request # type: ignore + from ._request_builders import build_post505_request # type: ignore + from ._request_builders import build_delete505_request # type: ignore + +__all__ = [ + "build_head501_request", + "build_get501_request", + "build_post505_request", + "build_delete505_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/_request_builders.py new file mode 100644 index 00000000000..d5c1df351b3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/_request_builders.py @@ -0,0 +1,174 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head501_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/501') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get501_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/501') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post505_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/505') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete505_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/failure/server/505') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/_request_builders_py3.py new file mode 100644 index 00000000000..97ba9cc3c63 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_server_failure/_request_builders_py3.py @@ -0,0 +1,137 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head501_request(**kwargs: Any) -> HttpRequest: + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/501") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get501_request(**kwargs: Any) -> HttpRequest: + """Return 501 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/501") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_post505_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/505") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete505_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Return 505 status code - should be represented in the client as an error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/failure/server/505") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/__init__.py new file mode 100644 index 00000000000..6d355239b28 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/__init__.py @@ -0,0 +1,70 @@ +# 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_head200_request + from ._request_builders_py3 import build_get200_request + from ._request_builders_py3 import build_options200_request + from ._request_builders_py3 import build_put200_request + from ._request_builders_py3 import build_patch200_request + from ._request_builders_py3 import build_post200_request + from ._request_builders_py3 import build_delete200_request + from ._request_builders_py3 import build_put201_request + from ._request_builders_py3 import build_post201_request + from ._request_builders_py3 import build_put202_request + from ._request_builders_py3 import build_patch202_request + from ._request_builders_py3 import build_post202_request + from ._request_builders_py3 import build_delete202_request + from ._request_builders_py3 import build_head204_request + from ._request_builders_py3 import build_put204_request + from ._request_builders_py3 import build_patch204_request + from ._request_builders_py3 import build_post204_request + from ._request_builders_py3 import build_delete204_request + from ._request_builders_py3 import build_head404_request +except (SyntaxError, ImportError): + from ._request_builders import build_head200_request # type: ignore + from ._request_builders import build_get200_request # type: ignore + from ._request_builders import build_options200_request # type: ignore + from ._request_builders import build_put200_request # type: ignore + from ._request_builders import build_patch200_request # type: ignore + from ._request_builders import build_post200_request # type: ignore + from ._request_builders import build_delete200_request # type: ignore + from ._request_builders import build_put201_request # type: ignore + from ._request_builders import build_post201_request # type: ignore + from ._request_builders import build_put202_request # type: ignore + from ._request_builders import build_patch202_request # type: ignore + from ._request_builders import build_post202_request # type: ignore + from ._request_builders import build_delete202_request # type: ignore + from ._request_builders import build_head204_request # type: ignore + from ._request_builders import build_put204_request # type: ignore + from ._request_builders import build_patch204_request # type: ignore + from ._request_builders import build_post204_request # type: ignore + from ._request_builders import build_delete204_request # type: ignore + from ._request_builders import build_head404_request # type: ignore + +__all__ = [ + "build_head200_request", + "build_get200_request", + "build_options200_request", + "build_put200_request", + "build_patch200_request", + "build_post200_request", + "build_delete200_request", + "build_put201_request", + "build_post201_request", + "build_put202_request", + "build_patch202_request", + "build_post202_request", + "build_delete202_request", + "build_head204_request", + "build_put204_request", + "build_patch204_request", + "build_post204_request", + "build_delete204_request", + "build_head404_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/_request_builders.py new file mode 100644 index 00000000000..41691f91724 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/_request_builders.py @@ -0,0 +1,831 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_head200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_options200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Options 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="OPTIONS", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put boolean value true returning 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returning 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post bollean value true in request that returns a 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete200_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete simple boolean value true returns 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/200') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put201_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 201. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/201') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post201_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 201 (Created). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/201') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returns 202. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete202_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete true Boolean value in request returns 202 (accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/202') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_patch204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Patch true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Post true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_delete204_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Delete true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/204') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_head404_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Return 404 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/success/404') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/_request_builders_py3.py new file mode 100644 index 00000000000..6cf427a2dde --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/http_success/_request_builders_py3.py @@ -0,0 +1,674 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_head200_request(**kwargs: Any) -> HttpRequest: + """Return 200 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_get200_request(**kwargs: Any) -> HttpRequest: + """Get 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_options200_request(**kwargs: Any) -> HttpRequest: + """Options 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="OPTIONS", url=url, headers=header_parameters, **kwargs) + + +def build_put200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put boolean value true returning 200 success. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returning 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post bollean value true in request that returns a 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete200_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete simple boolean value true returns 200. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/200") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put201_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 201. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/201") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post201_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 201 (Created). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/201") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returns 202. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 202 (Accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete202_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete true Boolean value in request returns 202 (accepted). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/202") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head204_request(**kwargs: Any) -> HttpRequest: + """Return 204 status code if successful. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) + + +def build_put204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_patch204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Patch true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Post true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_delete204_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Delete true Boolean value in request returns 204 (no content). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple boolean value true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple boolean value true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "bool (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/204") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_head404_request(**kwargs: Any) -> HttpRequest: + """Return 404 status code. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/success/404") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/__init__.py new file mode 100644 index 00000000000..6a4f9bc9a49 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/__init__.py @@ -0,0 +1,115 @@ +# 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_get200_model204_no_model_default_error200_valid_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error204_valid_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error201_invalid_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error202_none_request + from ._request_builders_py3 import build_get200_model204_no_model_default_error400_valid_request + from ._request_builders_py3 import build_get200_model201_model_default_error200_valid_request + from ._request_builders_py3 import build_get200_model201_model_default_error201_valid_request + from ._request_builders_py3 import build_get200_model201_model_default_error400_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error200_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error201_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error404_valid_request + from ._request_builders_py3 import build_get200_model_a201_model_c404_model_d_default_error400_valid_request + from ._request_builders_py3 import build_get202_none204_none_default_error202_none_request + from ._request_builders_py3 import build_get202_none204_none_default_error204_none_request + from ._request_builders_py3 import build_get202_none204_none_default_error400_valid_request + from ._request_builders_py3 import build_get202_none204_none_default_none202_invalid_request + from ._request_builders_py3 import build_get202_none204_none_default_none204_none_request + from ._request_builders_py3 import build_get202_none204_none_default_none400_none_request + from ._request_builders_py3 import build_get202_none204_none_default_none400_invalid_request + from ._request_builders_py3 import build_get_default_model_a200_valid_request + from ._request_builders_py3 import build_get_default_model_a200_none_request + from ._request_builders_py3 import build_get_default_model_a400_valid_request + from ._request_builders_py3 import build_get_default_model_a400_none_request + from ._request_builders_py3 import build_get_default_none200_invalid_request + from ._request_builders_py3 import build_get_default_none200_none_request + from ._request_builders_py3 import build_get_default_none400_invalid_request + from ._request_builders_py3 import build_get_default_none400_none_request + from ._request_builders_py3 import build_get200_model_a200_none_request + from ._request_builders_py3 import build_get200_model_a200_valid_request + from ._request_builders_py3 import build_get200_model_a200_invalid_request + from ._request_builders_py3 import build_get200_model_a400_none_request + from ._request_builders_py3 import build_get200_model_a400_valid_request + from ._request_builders_py3 import build_get200_model_a400_invalid_request + from ._request_builders_py3 import build_get200_model_a202_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get200_model204_no_model_default_error200_valid_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error204_valid_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error201_invalid_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error202_none_request # type: ignore + from ._request_builders import build_get200_model204_no_model_default_error400_valid_request # type: ignore + from ._request_builders import build_get200_model201_model_default_error200_valid_request # type: ignore + from ._request_builders import build_get200_model201_model_default_error201_valid_request # type: ignore + from ._request_builders import build_get200_model201_model_default_error400_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error200_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error201_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error404_valid_request # type: ignore + from ._request_builders import build_get200_model_a201_model_c404_model_d_default_error400_valid_request # type: ignore + from ._request_builders import build_get202_none204_none_default_error202_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_error204_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_error400_valid_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none202_invalid_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none204_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none400_none_request # type: ignore + from ._request_builders import build_get202_none204_none_default_none400_invalid_request # type: ignore + from ._request_builders import build_get_default_model_a200_valid_request # type: ignore + from ._request_builders import build_get_default_model_a200_none_request # type: ignore + from ._request_builders import build_get_default_model_a400_valid_request # type: ignore + from ._request_builders import build_get_default_model_a400_none_request # type: ignore + from ._request_builders import build_get_default_none200_invalid_request # type: ignore + from ._request_builders import build_get_default_none200_none_request # type: ignore + from ._request_builders import build_get_default_none400_invalid_request # type: ignore + from ._request_builders import build_get_default_none400_none_request # type: ignore + from ._request_builders import build_get200_model_a200_none_request # type: ignore + from ._request_builders import build_get200_model_a200_valid_request # type: ignore + from ._request_builders import build_get200_model_a200_invalid_request # type: ignore + from ._request_builders import build_get200_model_a400_none_request # type: ignore + from ._request_builders import build_get200_model_a400_valid_request # type: ignore + from ._request_builders import build_get200_model_a400_invalid_request # type: ignore + from ._request_builders import build_get200_model_a202_valid_request # type: ignore + +__all__ = [ + "build_get200_model204_no_model_default_error200_valid_request", + "build_get200_model204_no_model_default_error204_valid_request", + "build_get200_model204_no_model_default_error201_invalid_request", + "build_get200_model204_no_model_default_error202_none_request", + "build_get200_model204_no_model_default_error400_valid_request", + "build_get200_model201_model_default_error200_valid_request", + "build_get200_model201_model_default_error201_valid_request", + "build_get200_model201_model_default_error400_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error200_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error201_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error404_valid_request", + "build_get200_model_a201_model_c404_model_d_default_error400_valid_request", + "build_get202_none204_none_default_error202_none_request", + "build_get202_none204_none_default_error204_none_request", + "build_get202_none204_none_default_error400_valid_request", + "build_get202_none204_none_default_none202_invalid_request", + "build_get202_none204_none_default_none204_none_request", + "build_get202_none204_none_default_none400_none_request", + "build_get202_none204_none_default_none400_invalid_request", + "build_get_default_model_a200_valid_request", + "build_get_default_model_a200_none_request", + "build_get_default_model_a400_valid_request", + "build_get_default_model_a400_none_request", + "build_get_default_none200_invalid_request", + "build_get_default_none200_none_request", + "build_get_default_none400_invalid_request", + "build_get_default_none400_none_request", + "build_get200_model_a200_none_request", + "build_get200_model_a200_valid_request", + "build_get200_model_a200_invalid_request", + "build_get200_model_a400_none_request", + "build_get200_model_a400_valid_request", + "build_get200_model_a400_invalid_request", + "build_get200_model_a202_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/_request_builders.py new file mode 100644 index 00000000000..2789d397bf2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/_request_builders.py @@ -0,0 +1,1237 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get200_model204_no_model_default_error200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error204_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/204/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error201_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 201 response with valid payload: {'statusCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/201/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error202_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with no payload:. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/202/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model204_no_model_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/204/none/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model201_model_default_error200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "textStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/B/default/Error/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model201_model_default_error201_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "textStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/B/default/Error/response/201/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model201_model_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "textStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/B/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error201_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'httpCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error404_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'httpStatusCode': '404'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a201_model_c404_model_d_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_error202_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/Error/response/202/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_error204_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/Error/response/204/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_error400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/Error/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get202_none204_none_default_none202_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/202/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get202_none204_none_default_none204_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/204/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get202_none204_none_default_none400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/400/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get202_none204_none_default_none400_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/202/none/204/none/default/none/response/400/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_model_a200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_model_a200_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/200/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_model_a400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_model_a400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/A/response/400/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_default_none200_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with invalid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/200/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_none200_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/200/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_none400_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/400/invalid') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_default_none400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/default/none/response/400/none') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get200_model_a200_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with no payload, when a payload is expected - client should return a null + object of thde type for model A. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/200/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a200_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with payload {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/200/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a200_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/200/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a400_none_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 400 response with no payload client should treat as an http error with no error model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/400/none') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a400_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with payload {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/400/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a400_invalid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/400/invalid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get200_model_a202_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Send a 202 response with payload {'statusCode': '202'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/http/payloads/200/A/response/202/valid') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/_request_builders_py3.py new file mode 100644 index 00000000000..6dad3cb9abb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/httpinfrastructurelowlevel/rest/multiple_responses/_request_builders_py3.py @@ -0,0 +1,968 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get200_model204_no_model_default_error200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error204_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/204/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error201_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 201 response with valid payload: {'statusCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/201/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error202_none_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with no payload:. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/202/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model204_no_model_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/204/none/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model201_model_default_error200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "textStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/B/default/Error/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model201_model_default_error201_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "textStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/B/default/Error/response/201/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model201_model_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "textStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/B/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error201_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'httpCode': '201'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/201/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error404_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'httpStatusCode': '404'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/404/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a201_model_c404_model_d_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + # response body for status code(s): 201 + response.json() == { + "httpCode": "str (optional)" + } + # response body for status code(s): 404 + response.json() == { + "httpStatusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/201/C/404/D/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_error202_none_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/Error/response/202/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_error204_none_request(**kwargs: Any) -> HttpRequest: + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/Error/response/204/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_error400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'code': '400', 'message': 'client error'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/Error/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get202_none204_none_default_none202_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/202/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get202_none204_none_default_none204_none_request(**kwargs: Any) -> HttpRequest: + """Send a 204 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/204/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get202_none204_none_default_none400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/400/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get202_none204_none_default_none400_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with an unexpected payload {'property': 'value'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/202/none/204/none/default/none/response/400/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_model_a200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with valid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_model_a200_none_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/200/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_model_a400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_model_a400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/A/response/400/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_default_none200_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with invalid payload: {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/200/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_none200_none_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/200/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_none400_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with valid payload: {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/400/invalid") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_default_none400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/default/none/response/400/none") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get200_model_a200_none_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with no payload, when a payload is expected - client should return a null + object of thde type for model A. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/200/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a200_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with payload {'statusCode': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/200/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a200_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with invalid payload {'statusCodeInvalid': '200'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/200/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a400_none_request(**kwargs: Any) -> HttpRequest: + """Send a 400 response with no payload client should treat as an http error with no error model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/400/none") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a400_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with payload {'statusCode': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/400/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a400_invalid_request(**kwargs: Any) -> HttpRequest: + """Send a 200 response with invalid payload {'statusCodeInvalid': '400'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/400/invalid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get200_model_a202_valid_request(**kwargs: Any) -> HttpRequest: + """Send a 202 response with payload {'statusCode': '202'}. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "statusCode": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/http/payloads/200/A/response/202/valid") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/setup.py new file mode 100644 index 00000000000..fcfd79cd81c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/HttpLowLevel/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 = "autoresthttpinfrastructuretestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestHttpInfrastructureTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestHttpInfrastructureTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/__init__.py new file mode 100644 index 00000000000..f0ba65e1fdd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/__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 ._incorrect_returned_error_model import IncorrectReturnedErrorModel +from ._version import VERSION + +__version__ = VERSION +__all__ = ["IncorrectReturnedErrorModel"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_configuration.py new file mode 100644 index 00000000000..a5f2e613aa7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_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 IncorrectReturnedErrorModelConfiguration(Configuration): + """Configuration for IncorrectReturnedErrorModel. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(IncorrectReturnedErrorModelConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "incorrectreturnederrormodel/{}".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/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_incorrect_returned_error_model.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_incorrect_returned_error_model.py new file mode 100644 index 00000000000..930279020c6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_incorrect_returned_error_model.py @@ -0,0 +1,91 @@ +# 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 IncorrectReturnedErrorModelConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class IncorrectReturnedErrorModel(object): + """Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = IncorrectReturnedErrorModelConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `incorrecterrorresponselowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from incorrecterrorresponselowlevel.rest import build_get_incorrect_error_from_server_request + >>> request = build_get_incorrect_error_from_server_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> IncorrectReturnedErrorModel + 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/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/_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/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/__init__.py new file mode 100644 index 00000000000..5c833bf683d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/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 ._incorrect_returned_error_model import IncorrectReturnedErrorModel + +__all__ = ["IncorrectReturnedErrorModel"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/_configuration.py new file mode 100644 index 00000000000..556842de3fd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/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 IncorrectReturnedErrorModelConfiguration(Configuration): + """Configuration for IncorrectReturnedErrorModel. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(IncorrectReturnedErrorModelConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "incorrectreturnederrormodel/{}".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/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/_incorrect_returned_error_model.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/_incorrect_returned_error_model.py new file mode 100644 index 00000000000..78cee41c4a2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/aio/_incorrect_returned_error_model.py @@ -0,0 +1,77 @@ +# 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 IncorrectReturnedErrorModelConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class IncorrectReturnedErrorModel: + """Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = IncorrectReturnedErrorModelConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `incorrecterrorresponselowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from incorrecterrorresponselowlevel.rest import build_get_incorrect_error_from_server_request + >>> request = build_get_incorrect_error_from_server_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "IncorrectReturnedErrorModel": + 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/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/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/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/__init__.py new file mode 100644 index 00000000000..dc1410e2374 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/__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_get_incorrect_error_from_server_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_incorrect_error_from_server_request # type: ignore + +__all__ = [ + "build_get_incorrect_error_from_server_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..5d04266b137 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/_request_builders.py @@ -0,0 +1,44 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_incorrect_error_from_server_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an error response from the server that is not as described in our Error object. Want to + swallow the deserialization error and still return an HttpResponseError to the users. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/incorrectError') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..52f28f5764a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/incorrecterrorresponselowlevel/rest/_request_builders_py3.py @@ -0,0 +1,32 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_incorrect_error_from_server_request(**kwargs: Any) -> HttpRequest: + """Get an error response from the server that is not as described in our Error object. Want to + swallow the deserialization error and still return an HttpResponseError to the users. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/incorrectError") + + return HttpRequest(method="GET", url=url, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/setup.py new file mode 100644 index 00000000000..efcb49f90cd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/IncorrectErrorResponseLowLevel/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 = "incorrectreturnederrormodel" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="IncorrectReturnedErrorModel", + author_email="", + url="", + keywords=["Swagger", "IncorrectReturnedErrorModel"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test to see when throwing an HttpResponseError whether we swallow error model deserialization errors. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/__init__.py new file mode 100644 index 00000000000..eab5740bac6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/__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 ._llc_client import LLCClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["LLCClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_configuration.py new file mode 100644 index 00000000000..4d1b640f4d1 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_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 LLCClientConfiguration(Configuration): + """Configuration for LLCClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(LLCClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "llcclient/{}".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/LLCInitialLowLevel/llcpackagelowlevel/_llc_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_llc_client.py new file mode 100644 index 00000000000..9cb459b0ff8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_llc_client.py @@ -0,0 +1,91 @@ +# 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 LLCClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class LLCClient(object): + """LLC Swagger, this is the initial swager a service could do. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = LLCClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `llcpackagelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from llcpackagelowlevel.rest import params + >>> request = params.build_get_required_request(parameter1=parameter1, parameter2=parameter2, parameter3=parameter3, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> LLCClient + 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/LLCInitialLowLevel/llcpackagelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/_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/LLCInitialLowLevel/llcpackagelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/aio/__init__.py new file mode 100644 index 00000000000..dc3fcb57603 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/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 ._llc_client import LLCClient + +__all__ = ["LLCClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..92561d376b8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/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 LLCClientConfiguration(Configuration): + """Configuration for LLCClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(LLCClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "llcclient/{}".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/LLCInitialLowLevel/llcpackagelowlevel/aio/_llc_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/aio/_llc_client.py new file mode 100644 index 00000000000..3ffdaebf6da --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/aio/_llc_client.py @@ -0,0 +1,77 @@ +# 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 LLCClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class LLCClient: + """LLC Swagger, this is the initial swager a service could do. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = LLCClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `llcpackagelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from llcpackagelowlevel.rest import params + >>> request = params.build_get_required_request(parameter1=parameter1, parameter2=parameter2, parameter3=parameter3, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "LLCClient": + 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/LLCInitialLowLevel/llcpackagelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/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/LLCInitialLowLevel/llcpackagelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/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/LLCInitialLowLevel/llcpackagelowlevel/rest/params/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/__init__.py new file mode 100644 index 00000000000..f842c47d569 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/__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_get_required_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_required_request # type: ignore + +__all__ = [ + "build_get_required_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/_request_builders.py new file mode 100644 index 00000000000..b9b883dca4b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/_request_builders.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_required_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter1: I am a required parameter. + :paramtype parameter1: str + :keyword parameter2: I am a required parameter. + :paramtype parameter2: str + :keyword parameter3: I am a required parameter and I'm last in Swagger. + :paramtype parameter3: str + :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 + """ + + parameter1 = kwargs.pop('parameter1') # type: str + parameter2 = kwargs.pop('parameter2') # type: str + parameter3 = kwargs.pop('parameter3') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/llc/parameters') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameter1'] = _SERIALIZER.query("parameter1", parameter1, 'str') + query_parameters['parameter2'] = _SERIALIZER.query("parameter2", parameter2, 'str') + query_parameters['parameter3'] = _SERIALIZER.query("parameter3", parameter3, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/_request_builders_py3.py new file mode 100644 index 00000000000..d961281dba4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/llcpackagelowlevel/rest/params/_request_builders_py3.py @@ -0,0 +1,48 @@ +# 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.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_required_request(*, parameter1: str, parameter2: str, parameter3: str, **kwargs: Any) -> HttpRequest: + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter1: I am a required parameter. + :paramtype parameter1: str + :keyword parameter2: I am a required parameter. + :paramtype parameter2: str + :keyword parameter3: I am a required parameter and I'm last in Swagger. + :paramtype parameter3: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/llc/parameters") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["parameter1"] = _SERIALIZER.query("parameter1", parameter1, "str") + query_parameters["parameter2"] = _SERIALIZER.query("parameter2", parameter2, "str") + query_parameters["parameter3"] = _SERIALIZER.query("parameter3", parameter3, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/setup.py new file mode 100644 index 00000000000..51b75ad264c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCInitialLowLevel/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 = "llcclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="LLCClient", + author_email="", + url="", + keywords=["Swagger", "LLCClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + LLC Swagger, this is the initial swager a service could do. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/__init__.py new file mode 100644 index 00000000000..eab5740bac6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/__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 ._llc_client import LLCClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["LLCClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_configuration.py new file mode 100644 index 00000000000..4d1b640f4d1 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_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 LLCClientConfiguration(Configuration): + """Configuration for LLCClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(LLCClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "llcclient/{}".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/LLCUpdateOneLowLevel/llcpackagelowlevel/_llc_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_llc_client.py new file mode 100644 index 00000000000..3eac60bb28d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_llc_client.py @@ -0,0 +1,91 @@ +# 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 LLCClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class LLCClient(object): + """LLC Swagger, this is the initial swager a service could do. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = LLCClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `llcpackagelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from llcpackagelowlevel.rest import params + >>> request = params.build_get_required_request(parameter3=parameter3, parameter1=parameter1, parameter2=parameter2, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> LLCClient + 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/LLCUpdateOneLowLevel/llcpackagelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/_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/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/__init__.py new file mode 100644 index 00000000000..dc3fcb57603 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/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 ._llc_client import LLCClient + +__all__ = ["LLCClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..92561d376b8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/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 LLCClientConfiguration(Configuration): + """Configuration for LLCClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(LLCClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "llcclient/{}".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/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/_llc_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/_llc_client.py new file mode 100644 index 00000000000..659478dbc95 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/aio/_llc_client.py @@ -0,0 +1,77 @@ +# 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 LLCClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class LLCClient: + """LLC Swagger, this is the initial swager a service could do. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = LLCClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `llcpackagelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from llcpackagelowlevel.rest import params + >>> request = params.build_get_required_request(parameter3=parameter3, parameter1=parameter1, parameter2=parameter2, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "LLCClient": + 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/LLCUpdateOneLowLevel/llcpackagelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/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/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/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/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/__init__.py new file mode 100644 index 00000000000..f842c47d569 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/__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_get_required_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_required_request # type: ignore + +__all__ = [ + "build_get_required_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/_request_builders.py new file mode 100644 index 00000000000..521702b6f29 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/_request_builders.py @@ -0,0 +1,67 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_required_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter3: I am a required parameter and I'm last in Swagger. + :paramtype parameter3: str + :keyword parameter1: I am a required parameter with a client default value. + :paramtype parameter1: str + :keyword parameter2: I was a required parameter, but now I'm optional. + :paramtype parameter2: str + :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 + """ + + parameter3 = kwargs.pop('parameter3') # type: str + parameter1 = kwargs.pop('parameter1', "DefaultValue") # type: str + parameter2 = kwargs.pop('parameter2', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/llc/parameters') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['parameter1'] = _SERIALIZER.query("parameter1", parameter1, 'str') + if parameter2 is not None: + query_parameters['parameter2'] = _SERIALIZER.query("parameter2", parameter2, 'str') + query_parameters['parameter3'] = _SERIALIZER.query("parameter3", parameter3, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/_request_builders_py3.py new file mode 100644 index 00000000000..68df6a85503 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/llcpackagelowlevel/rest/params/_request_builders_py3.py @@ -0,0 +1,51 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_required_request( + *, parameter3: str, parameter1: str = "DefaultValue", parameter2: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword parameter3: I am a required parameter and I'm last in Swagger. + :paramtype parameter3: str + :keyword parameter1: I am a required parameter with a client default value. + :paramtype parameter1: str + :keyword parameter2: I was a required parameter, but now I'm optional. + :paramtype parameter2: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/llc/parameters") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["parameter1"] = _SERIALIZER.query("parameter1", parameter1, "str") + if parameter2 is not None: + query_parameters["parameter2"] = _SERIALIZER.query("parameter2", parameter2, "str") + query_parameters["parameter3"] = _SERIALIZER.query("parameter3", parameter3, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/setup.py new file mode 100644 index 00000000000..51b75ad264c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/LLCUpdateOneLowLevel/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 = "llcclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="LLCClient", + author_email="", + url="", + keywords=["Swagger", "LLCClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + LLC Swagger, this is the initial swager a service could do. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/__init__.py new file mode 100644 index 00000000000..1d5b9d8d17b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/__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 ._media_types_client import MediaTypesClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["MediaTypesClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_configuration.py new file mode 100644 index 00000000000..4fb0dd8a354 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_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 MediaTypesClientConfiguration(Configuration): + """Configuration for MediaTypesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(MediaTypesClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "mediatypesclient/{}".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/MediaTypesLowLevel/mediatypeslowlevel/_media_types_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_media_types_client.py new file mode 100644 index 00000000000..0992de5bae8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_media_types_client.py @@ -0,0 +1,91 @@ +# 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 MediaTypesClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class MediaTypesClient(object): + """Play with produces/consumes and media-types in general. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = MediaTypesClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `mediatypeslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from mediatypeslowlevel.rest import build_analyze_body_request + >>> request = build_analyze_body_request(json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> MediaTypesClient + 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/MediaTypesLowLevel/mediatypeslowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/_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/MediaTypesLowLevel/mediatypeslowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/aio/__init__.py new file mode 100644 index 00000000000..413c4ed03a0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/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 ._media_types_client import MediaTypesClient + +__all__ = ["MediaTypesClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..4048232998c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/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 MediaTypesClientConfiguration(Configuration): + """Configuration for MediaTypesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(MediaTypesClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "mediatypesclient/{}".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/MediaTypesLowLevel/mediatypeslowlevel/aio/_media_types_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/aio/_media_types_client.py new file mode 100644 index 00000000000..5da13649e68 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/aio/_media_types_client.py @@ -0,0 +1,77 @@ +# 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 MediaTypesClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class MediaTypesClient: + """Play with produces/consumes and media-types in general. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = MediaTypesClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `mediatypeslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from mediatypeslowlevel.rest import build_analyze_body_request + >>> request = build_analyze_body_request(json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "MediaTypesClient": + 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/MediaTypesLowLevel/mediatypeslowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/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/MediaTypesLowLevel/mediatypeslowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/__init__.py new file mode 100644 index 00000000000..276b724f566 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/__init__.py @@ -0,0 +1,19 @@ +# 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_analyze_body_request + from ._request_builders_py3 import build_content_type_with_encoding_request +except (SyntaxError, ImportError): + from ._request_builders import build_analyze_body_request # type: ignore + from ._request_builders import build_content_type_with_encoding_request # type: ignore + +__all__ = [ + "build_analyze_body_request", + "build_content_type_with_encoding_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..32a6f5be9ef --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/_request_builders.py @@ -0,0 +1,108 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_analyze_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Analyze body, that could be different media types. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "source": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[Union[str, "_models.ContentType"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/mediatypes/analyze') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_content_type_with_encoding_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/mediatypes/contentTypeWithEncoding') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..c32a4176232 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/mediatypeslowlevel/rest/_request_builders_py3.py @@ -0,0 +1,87 @@ +# 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, IO, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_analyze_body_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Analyze body, that could be different media types. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input parameter. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :paramtype content: any + :keyword str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "application/pdf", "image/jpeg", "image/png", + "image/tiff", "application/json." + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "source": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[Union[str, "_models.ContentType"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/mediatypes/analyze") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_content_type_with_encoding_request(*, content: Any = None, **kwargs: Any) -> HttpRequest: + """Pass in contentType 'text/plain; encoding=UTF-8' to pass test. Value for input does not matter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input parameter. + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/mediatypes/contentTypeWithEncoding") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/setup.py new file mode 100644 index 00000000000..dc511b5a976 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MediaTypesLowLevel/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 = "mediatypesclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="MediaTypesClient", + author_email="", + url="", + keywords=["Swagger", "MediaTypesClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Play with produces/consumes and media-types in general. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/__init__.py new file mode 100644 index 00000000000..487d0a491a7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/__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 ._auto_rest_resource_flattening_test_service import AutoRestResourceFlatteningTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestResourceFlatteningTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_auto_rest_resource_flattening_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_auto_rest_resource_flattening_test_service.py new file mode 100644 index 00000000000..4f61b298376 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_auto_rest_resource_flattening_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestResourceFlatteningTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestResourceFlatteningTestService(object): + """Resource Flattening for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestResourceFlatteningTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `modelflatteninglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from modelflatteninglowlevel.rest import build_put_array_request + >>> request = build_put_array_request(json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestResourceFlatteningTestService + 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/ModelFlatteningLowLevel/modelflatteninglowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_configuration.py new file mode 100644 index 00000000000..70070e83c02 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_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 AutoRestResourceFlatteningTestServiceConfiguration(Configuration): + """Configuration for AutoRestResourceFlatteningTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestResourceFlatteningTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestresourceflatteningtestservice/{}".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/ModelFlatteningLowLevel/modelflatteninglowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/_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/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/__init__.py new file mode 100644 index 00000000000..29a7101ac7b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/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 ._auto_rest_resource_flattening_test_service import AutoRestResourceFlatteningTestService + +__all__ = ["AutoRestResourceFlatteningTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/_auto_rest_resource_flattening_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/_auto_rest_resource_flattening_test_service.py new file mode 100644 index 00000000000..5b0f274166e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/_auto_rest_resource_flattening_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestResourceFlatteningTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestResourceFlatteningTestService: + """Resource Flattening for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestResourceFlatteningTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `modelflatteninglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from modelflatteninglowlevel.rest import build_put_array_request + >>> request = build_put_array_request(json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestResourceFlatteningTestService": + 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/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/aio/_configuration.py new file mode 100644 index 00000000000..c4cc1600aaf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/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 AutoRestResourceFlatteningTestServiceConfiguration(Configuration): + """Configuration for AutoRestResourceFlatteningTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestResourceFlatteningTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestresourceflatteningtestservice/{}".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/ModelFlatteningLowLevel/modelflatteninglowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/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/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/__init__.py new file mode 100644 index 00000000000..f56a51a7756 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/__init__.py @@ -0,0 +1,46 @@ +# 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_put_array_request + from ._request_builders_py3 import build_get_array_request + from ._request_builders_py3 import build_put_wrapped_array_request + from ._request_builders_py3 import build_get_wrapped_array_request + from ._request_builders_py3 import build_put_dictionary_request + from ._request_builders_py3 import build_get_dictionary_request + from ._request_builders_py3 import build_put_resource_collection_request + from ._request_builders_py3 import build_get_resource_collection_request + from ._request_builders_py3 import build_put_simple_product_request + from ._request_builders_py3 import build_post_flattened_simple_product_request + from ._request_builders_py3 import build_put_simple_product_with_grouping_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_array_request # type: ignore + from ._request_builders import build_get_array_request # type: ignore + from ._request_builders import build_put_wrapped_array_request # type: ignore + from ._request_builders import build_get_wrapped_array_request # type: ignore + from ._request_builders import build_put_dictionary_request # type: ignore + from ._request_builders import build_get_dictionary_request # type: ignore + from ._request_builders import build_put_resource_collection_request # type: ignore + from ._request_builders import build_get_resource_collection_request # type: ignore + from ._request_builders import build_put_simple_product_request # type: ignore + from ._request_builders import build_post_flattened_simple_product_request # type: ignore + from ._request_builders import build_put_simple_product_with_grouping_request # type: ignore + +__all__ = [ + "build_put_array_request", + "build_get_array_request", + "build_put_wrapped_array_request", + "build_get_wrapped_array_request", + "build_put_dictionary_request", + "build_get_dictionary_request", + "build_put_resource_collection_request", + "build_get_resource_collection_request", + "build_put_simple_product_request", + "build_post_flattened_simple_product_request", + "build_put_simple_product_with_grouping_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..8f9f80be7da --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/_request_builders.py @@ -0,0 +1,667 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "id": "str (optional)", + "location": "str (optional)", + "name": "str (optional)", + "tags": { + "str": "str (optional)" + }, + "type": "str (optional)" + } + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/array') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/array') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_wrapped_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "value": "str (optional)" + } + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/wrappedarray') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_wrapped_array_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "property": { + "value": "str (optional)" + } + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/wrappedarray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_dictionary_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a Dictionary to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a Dictionary to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/dictionary') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_dictionary_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/dictionary') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_resource_collection_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a ResourceCollection to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a ResourceCollection to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "arrayofresources": [ + { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + ], + "dictionaryofresources": { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + }, + "productresource": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/resourcecollection') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_resource_collection_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "arrayofresources": [ + { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + ], + "dictionaryofresources": { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + }, + "productresource": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/resourcecollection') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_simple_product_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/customFlattening') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_flattened_simple_product_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put Flattened Simple Product with client flattening true on the parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to post. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to post. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/customFlattening') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_simple_product_with_grouping_request( + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param name: Product name with value 'groupproduct'. + :type name: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/model-flatten/customFlattening/parametergrouping/{name}/') + path_format_arguments = { + 'name': _SERIALIZER.url("name", name, 'str'), + } + 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..aec2590f3e7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/modelflatteninglowlevel/rest/_request_builders_py3.py @@ -0,0 +1,575 @@ +# 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, List, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_array_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "id": "str (optional)", + "location": "str (optional)", + "name": "str (optional)", + "tags": { + "str": "str (optional)" + }, + "type": "str (optional)" + } + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/array") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_array_request(**kwargs: Any) -> HttpRequest: + """Get External Resource as an Array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/array") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_wrapped_array_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as an Array to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as an Array to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + { + "value": "str (optional)" + } + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/wrappedarray") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_wrapped_array_request(**kwargs: Any) -> HttpRequest: + """No need to have a route in Express server for this operation. Used to verify the type flattened + is not removed if it's referenced in an array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "property": { + "value": "str (optional)" + } + } + ] + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/wrappedarray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_dictionary_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a Dictionary to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a Dictionary to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/dictionary") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_dictionary_request(**kwargs: Any) -> HttpRequest: + """Get External Resource as a Dictionary. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/dictionary") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_resource_collection_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. External Resource as a ResourceCollection to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). External Resource as a ResourceCollection to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "arrayofresources": [ + { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + ], + "dictionaryofresources": { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + }, + "productresource": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/resourcecollection") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_resource_collection_request(**kwargs: Any) -> HttpRequest: + """Get External Resource as a ResourceCollection. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "arrayofresources": [ + { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + ], + "dictionaryofresources": { + "str": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + }, + "productresource": { + "properties": { + "p.name": "str (optional)", + "provisioningState": "str (optional)", + "provisioningStateValues": "str (optional)", + "type": "str (optional)" + } + } + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/resourcecollection") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_simple_product_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/customFlattening") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_flattened_simple_product_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put Flattened Simple Product with client flattening true on the parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to post. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to post. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/customFlattening") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_simple_product_with_grouping_request( + name: str, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Put Simple Product with client flattening true on the model. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param name: Product name with value 'groupproduct'. + :type name: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Simple body product to put. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Simple body product to put. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + + # response body for status code(s): 200 + response.json() == { + "details": { + "max_product_capacity": "str", + "max_product_display_name": "str", + "max_product_image": { + "@odata.value": "str (optional)" + } + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/model-flatten/customFlattening/parametergrouping/{name}/") + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/setup.py new file mode 100644 index 00000000000..1fbc49db0c0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ModelFlatteningLowLevel/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 = "autorestresourceflatteningtestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestResourceFlatteningTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestResourceFlatteningTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Resource Flattening for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/__init__.py new file mode 100644 index 00000000000..243ec09260a --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/__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 ._multiple_inheritance_service_client import MultipleInheritanceServiceClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["MultipleInheritanceServiceClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_configuration.py new file mode 100644 index 00000000000..3bf3a3a50bc --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_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 MultipleInheritanceServiceClientConfiguration(Configuration): + """Configuration for MultipleInheritanceServiceClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(MultipleInheritanceServiceClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "multipleinheritanceserviceclient/{}".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/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_multiple_inheritance_service_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_multiple_inheritance_service_client.py new file mode 100644 index 00000000000..88eb355385c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_multiple_inheritance_service_client.py @@ -0,0 +1,91 @@ +# 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 MultipleInheritanceServiceClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class MultipleInheritanceServiceClient(object): + """Service client for multiinheritance client testing. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = MultipleInheritanceServiceClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `multipleinheritancelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multipleinheritancelowlevel.rest import build_get_horse_request + >>> request = build_get_horse_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> MultipleInheritanceServiceClient + 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/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/_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/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/__init__.py new file mode 100644 index 00000000000..0657aa743de --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/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 ._multiple_inheritance_service_client import MultipleInheritanceServiceClient + +__all__ = ["MultipleInheritanceServiceClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..795387844ed --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/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 MultipleInheritanceServiceClientConfiguration(Configuration): + """Configuration for MultipleInheritanceServiceClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(MultipleInheritanceServiceClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "multipleinheritanceserviceclient/{}".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/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/_multiple_inheritance_service_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/_multiple_inheritance_service_client.py new file mode 100644 index 00000000000..ea7ce94da0e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/aio/_multiple_inheritance_service_client.py @@ -0,0 +1,77 @@ +# 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 MultipleInheritanceServiceClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class MultipleInheritanceServiceClient: + """Service client for multiinheritance client testing. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = MultipleInheritanceServiceClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `multipleinheritancelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from multipleinheritancelowlevel.rest import build_get_horse_request + >>> request = build_get_horse_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "MultipleInheritanceServiceClient": + 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/MultipleInheritanceLowLevel/multipleinheritancelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/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/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/__init__.py new file mode 100644 index 00000000000..007cd269e83 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/__init__.py @@ -0,0 +1,43 @@ +# 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_get_horse_request + from ._request_builders_py3 import build_put_horse_request + from ._request_builders_py3 import build_get_pet_request + from ._request_builders_py3 import build_put_pet_request + from ._request_builders_py3 import build_get_feline_request + from ._request_builders_py3 import build_put_feline_request + from ._request_builders_py3 import build_get_cat_request + from ._request_builders_py3 import build_put_cat_request + from ._request_builders_py3 import build_get_kitten_request + from ._request_builders_py3 import build_put_kitten_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_horse_request # type: ignore + from ._request_builders import build_put_horse_request # type: ignore + from ._request_builders import build_get_pet_request # type: ignore + from ._request_builders import build_put_pet_request # type: ignore + from ._request_builders import build_get_feline_request # type: ignore + from ._request_builders import build_put_feline_request # type: ignore + from ._request_builders import build_get_cat_request # type: ignore + from ._request_builders import build_put_cat_request # type: ignore + from ._request_builders import build_get_kitten_request # type: ignore + from ._request_builders import build_put_kitten_request # type: ignore + +__all__ = [ + "build_get_horse_request", + "build_put_horse_request", + "build_get_pet_request", + "build_put_pet_request", + "build_get_feline_request", + "build_put_feline_request", + "build_get_cat_request", + "build_put_cat_request", + "build_get_kitten_request", + "build_put_kitten_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..30cc898f21b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/_request_builders.py @@ -0,0 +1,466 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_horse_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a horse with name 'Fred' and isAShowHorse true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "isAShowHorse": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/horse') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_horse_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a horse with name 'General' and isAShowHorse false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a horse with name 'General' and isAShowHorse false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a horse with name 'General' and isAShowHorse false. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "isAShowHorse": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/horse') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_pet_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a pet with name 'Peanut'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "name": "str" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/pet') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_pet_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a pet with name 'Butter'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a pet with name 'Butter'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a pet with name 'Butter'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "name": "str" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/pet') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_feline_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a feline where meows and hisses are true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "hisses": "bool (optional)", + "meows": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/feline') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_feline_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a feline who hisses and doesn't meow. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a feline who hisses and doesn't meow. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a feline who hisses and doesn't meow. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "hisses": "bool (optional)", + "meows": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/feline') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_cat_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "likesMilk": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/cat') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_cat_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "likesMilk": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/cat') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_kitten_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet + is false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "eatsMiceYet": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/kitten') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_kitten_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is + true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a kitten with name 'Kitty' where likesMilk and hisses + is false, meows and eatsMiceYet is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a kitten with name 'Kitty' where likesMilk and hisses is + false, meows and eatsMiceYet is true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "eatsMiceYet": "bool (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/multipleInheritance/kitten') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..a9809817fea --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/multipleinheritancelowlevel/rest/_request_builders_py3.py @@ -0,0 +1,381 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_horse_request(**kwargs: Any) -> HttpRequest: + """Get a horse with name 'Fred' and isAShowHorse true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "isAShowHorse": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/horse") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_horse_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a horse with name 'General' and isAShowHorse false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a horse with name 'General' and isAShowHorse false. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a horse with name 'General' and isAShowHorse false. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "isAShowHorse": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/horse") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_pet_request(**kwargs: Any) -> HttpRequest: + """Get a pet with name 'Peanut'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "name": "str" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/pet") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_pet_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a pet with name 'Butter'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a pet with name 'Butter'. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a pet with name 'Butter'. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "name": "str" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/pet") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_feline_request(**kwargs: Any) -> HttpRequest: + """Get a feline where meows and hisses are true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "hisses": "bool (optional)", + "meows": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/feline") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_feline_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a feline who hisses and doesn't meow. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a feline who hisses and doesn't meow. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a feline who hisses and doesn't meow. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "hisses": "bool (optional)", + "meows": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/feline") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_cat_request(**kwargs: Any) -> HttpRequest: + """Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "likesMilk": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/cat") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_cat_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a cat with name 'Boots' where likesMilk and hisses is + false, meows is true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "likesMilk": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/cat") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_kitten_request(**kwargs: Any) -> HttpRequest: + """Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet + is false. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "eatsMiceYet": "bool (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/kitten") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_kitten_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is + true. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Put a kitten with name 'Kitty' where likesMilk and hisses + is false, meows and eatsMiceYet is true. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Put a kitten with name 'Kitty' where likesMilk and hisses is + false, meows and eatsMiceYet is true. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "eatsMiceYet": "bool (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/multipleInheritance/kitten") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/setup.py new file mode 100644 index 00000000000..22685bc333d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/MultipleInheritanceLowLevel/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 = "multipleinheritanceserviceclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="MultipleInheritanceServiceClient", + author_email="", + url="", + keywords=["Swagger", "MultipleInheritanceServiceClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for multiinheritance client testing. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/_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/NoOperationsLowLevel/nooperationslowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/nooperationslowlevel/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/NoOperationsLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/setup.py new file mode 100644 index 00000000000..5371219ae09 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NoOperationsLowLevel/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 = "nooperationsserviceclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="NoOperationsServiceClient", + author_email="", + url="", + keywords=["Swagger", "NoOperationsServiceClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client with no operations. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/__init__.py new file mode 100644 index 00000000000..43619519384 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/__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 ._non_string_enums_client import NonStringEnumsClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["NonStringEnumsClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_configuration.py new file mode 100644 index 00000000000..a29dd58414b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_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 NonStringEnumsClientConfiguration(Configuration): + """Configuration for NonStringEnumsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(NonStringEnumsClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "nonstringenumsclient/{}".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/NonStringEnumsLowLevel/nonstringenumslowlevel/_non_string_enums_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_non_string_enums_client.py new file mode 100644 index 00000000000..518781d0c7b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_non_string_enums_client.py @@ -0,0 +1,91 @@ +# 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 NonStringEnumsClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class NonStringEnumsClient(object): + """Testing non-string enums. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = NonStringEnumsClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `nonstringenumslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from nonstringenumslowlevel.rest import int + >>> request = int.build_put_request(json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> NonStringEnumsClient + 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/NonStringEnumsLowLevel/nonstringenumslowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/_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/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/__init__.py new file mode 100644 index 00000000000..2a5dbcf228c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/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 ._non_string_enums_client import NonStringEnumsClient + +__all__ = ["NonStringEnumsClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/_configuration.py new file mode 100644 index 00000000000..7daa742b2c9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/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 NonStringEnumsClientConfiguration(Configuration): + """Configuration for NonStringEnumsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(NonStringEnumsClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "nonstringenumsclient/{}".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/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/_non_string_enums_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/_non_string_enums_client.py new file mode 100644 index 00000000000..d998c599741 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/aio/_non_string_enums_client.py @@ -0,0 +1,77 @@ +# 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 NonStringEnumsClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class NonStringEnumsClient: + """Testing non-string enums. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = NonStringEnumsClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `nonstringenumslowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from nonstringenumslowlevel.rest import int + >>> request = int.build_put_request(json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "NonStringEnumsClient": + 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/NonStringEnumsLowLevel/nonstringenumslowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/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/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/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/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/__init__.py new file mode 100644 index 00000000000..caeb33f5416 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/__init__.py @@ -0,0 +1,19 @@ +# 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_put_request + from ._request_builders_py3 import build_get_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_request # type: ignore + from ._request_builders import build_get_request # type: ignore + +__all__ = [ + "build_put_request", + "build_get_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/_request_builders.py new file mode 100644 index 00000000000..97e27981a82 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/_request_builders.py @@ -0,0 +1,96 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input float enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input float enum. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/float/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/float/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/_request_builders_py3.py new file mode 100644 index 00000000000..0156676e813 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/float/_request_builders_py3.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 typing import Any, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input float enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input float enum. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "float (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/float/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get a float enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/float/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/__init__.py new file mode 100644 index 00000000000..caeb33f5416 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/__init__.py @@ -0,0 +1,19 @@ +# 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_put_request + from ._request_builders_py3 import build_get_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_request # type: ignore + from ._request_builders import build_get_request # type: ignore + +__all__ = [ + "build_put_request", + "build_get_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/_request_builders.py new file mode 100644 index 00000000000..6afcde89218 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/_request_builders.py @@ -0,0 +1,96 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input int enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input int enum. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/int/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/nonStringEnums/int/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/_request_builders_py3.py new file mode 100644 index 00000000000..67e3e7d2b43 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/nonstringenumslowlevel/rest/int/_request_builders_py3.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 typing import Any, Optional, Union + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Put an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Input int enum. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Input int enum. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/int/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Get an int enum. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/nonStringEnums/int/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/setup.py new file mode 100644 index 00000000000..2be14d7505b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/NonStringEnumsLowLevel/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 = "nonstringenumsclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="NonStringEnumsClient", + author_email="", + url="", + keywords=["Swagger", "NonStringEnumsClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Testing non-string enums. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/__init__.py new file mode 100644 index 00000000000..5b8ea3d7a47 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/__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 ._object_type_client import ObjectTypeClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["ObjectTypeClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_configuration.py new file mode 100644 index 00000000000..b8c2eb028e2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_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 ObjectTypeClientConfiguration(Configuration): + """Configuration for ObjectTypeClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(ObjectTypeClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "objecttypeclient/{}".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/ObjectTypeLowLevel/objecttypelowlevel/_object_type_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_object_type_client.py new file mode 100644 index 00000000000..a33d645bb3c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_object_type_client.py @@ -0,0 +1,91 @@ +# 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 ObjectTypeClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class ObjectTypeClient(object): + """Service client for testing basic type: object swaggers. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = ObjectTypeClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `objecttypelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from objecttypelowlevel.rest import build_get_request + >>> request = build_get_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> ObjectTypeClient + 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/ObjectTypeLowLevel/objecttypelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/_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/ObjectTypeLowLevel/objecttypelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/aio/__init__.py new file mode 100644 index 00000000000..80691bf1906 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/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 ._object_type_client import ObjectTypeClient + +__all__ = ["ObjectTypeClient"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..5c8877fc3b9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/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 ObjectTypeClientConfiguration(Configuration): + """Configuration for ObjectTypeClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(ObjectTypeClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "objecttypeclient/{}".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/ObjectTypeLowLevel/objecttypelowlevel/aio/_object_type_client.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/aio/_object_type_client.py new file mode 100644 index 00000000000..5d9421e1eca --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/aio/_object_type_client.py @@ -0,0 +1,77 @@ +# 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 ObjectTypeClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class ObjectTypeClient: + """Service client for testing basic type: object swaggers. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = ObjectTypeClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `objecttypelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from objecttypelowlevel.rest import build_get_request + >>> request = build_get_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "ObjectTypeClient": + 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/ObjectTypeLowLevel/objecttypelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/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/ObjectTypeLowLevel/objecttypelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/__init__.py new file mode 100644 index 00000000000..355267c5498 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/__init__.py @@ -0,0 +1,19 @@ +# 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_get_request + from ._request_builders_py3 import build_put_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_request # type: ignore + from ._request_builders import build_put_request # type: ignore + +__all__ = [ + "build_get_request", + "build_put_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..f26e480e738 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/_request_builders.py @@ -0,0 +1,100 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic get that returns an object. Returns object { 'message': 'An object was successfully + returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/objectType/get') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an + object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/objectType/put') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..ef400218a05 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/objecttypelowlevel/rest/_request_builders_py3.py @@ -0,0 +1,79 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_request(**kwargs: Any) -> HttpRequest: + """Basic get that returns an object. Returns object { 'message': 'An object was successfully + returned' }. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/objectType/get") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an + object error. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Pass in {'foo': 'bar'} for a 200, anything else for an + object error. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "any (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/objectType/put") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/setup.py new file mode 100644 index 00000000000..af6035300ac --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ObjectTypeLowLevel/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 = "objecttypeclient" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="ObjectTypeClient", + author_email="", + url="", + keywords=["Swagger", "ObjectTypeClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for testing basic type: object swaggers. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/__init__.py new file mode 100644 index 00000000000..6b63dac8e02 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/__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 ._auto_rest_parameter_flattening import AutoRestParameterFlattening +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestParameterFlattening"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_auto_rest_parameter_flattening.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_auto_rest_parameter_flattening.py new file mode 100644 index 00000000000..1f74d044138 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_auto_rest_parameter_flattening.py @@ -0,0 +1,91 @@ +# 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 AutoRestParameterFlatteningConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestParameterFlattening(object): + """Resource Flattening for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterFlatteningConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `parameterflatteninglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from parameterflatteninglowlevel.rest import availability_sets + >>> request = availability_sets.build_update_request(resource_group_name, avset, json=json, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestParameterFlattening + 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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_configuration.py new file mode 100644 index 00000000000..ad161b32967 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_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 AutoRestParameterFlatteningConfiguration(Configuration): + """Configuration for AutoRestParameterFlattening. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestParameterFlatteningConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestparameterflattening/{}".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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/_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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/__init__.py new file mode 100644 index 00000000000..fb2a57c831e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/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 ._auto_rest_parameter_flattening import AutoRestParameterFlattening + +__all__ = ["AutoRestParameterFlattening"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/_auto_rest_parameter_flattening.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/_auto_rest_parameter_flattening.py new file mode 100644 index 00000000000..4d987efd890 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/_auto_rest_parameter_flattening.py @@ -0,0 +1,77 @@ +# 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 AutoRestParameterFlatteningConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestParameterFlattening: + """Resource Flattening for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestParameterFlatteningConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `parameterflatteninglowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from parameterflatteninglowlevel.rest import availability_sets + >>> request = availability_sets.build_update_request(resource_group_name, avset, json=json, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestParameterFlattening": + 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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/aio/_configuration.py new file mode 100644 index 00000000000..2def2fa1a10 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/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 AutoRestParameterFlatteningConfiguration(Configuration): + """Configuration for AutoRestParameterFlattening. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestParameterFlatteningConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestparameterflattening/{}".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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/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/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/__init__.py new file mode 100644 index 00000000000..0f9c14f9c76 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/__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_request +except (SyntaxError, ImportError): + from ._request_builders import build_update_request # type: ignore + +__all__ = [ + "build_update_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/_request_builders.py new file mode 100644 index 00000000000..8df1cbe8599 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/_request_builders.py @@ -0,0 +1,79 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_update_request( + resource_group_name, # type: str + avset, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Updates the tags for an availability set. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param avset: The name of the storage availability set. + :type avset: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The tags. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The tags. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "tags": { + "str": "str" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/parameterFlattening/{resourceGroupName}/{availabilitySetName}') + path_format_arguments = { + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + 'availabilitySetName': _SERIALIZER.url("avset", avset, 'str', max_length=80, min_length=0), + } + 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="PATCH", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/_request_builders_py3.py new file mode 100644 index 00000000000..9fa2f21e823 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/parameterflatteninglowlevel/rest/availability_sets/_request_builders_py3.py @@ -0,0 +1,66 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_update_request( + resource_group_name: str, avset: str, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Updates the tags for an availability set. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param avset: The name of the storage availability set. + :type avset: str + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. The tags. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). The tags. + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "tags": { + "str": "str" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/parameterFlattening/{resourceGroupName}/{availabilitySetName}") + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "availabilitySetName": _SERIALIZER.url("avset", avset, "str", max_length=80, min_length=0), + } + 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="PATCH", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/setup.py new file mode 100644 index 00000000000..cb58a52fd5c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ParameterFlatteningLowLevel/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 = "autorestparameterflattening" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterFlattening", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterFlattening"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Resource Flattening for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/__init__.py new file mode 100644 index 00000000000..4dfae9fa296 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/__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 ._auto_rest_report_service import AutoRestReportService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestReportService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_auto_rest_report_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_auto_rest_report_service.py new file mode 100644 index 00000000000..4a3df1b7912 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_auto_rest_report_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestReportServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestReportService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `reportlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from reportlowlevel.rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestReportService + 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/ReportLowLevel/reportlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_configuration.py new file mode 100644 index 00000000000..80e1163ce47 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_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 AutoRestReportServiceConfiguration(Configuration): + """Configuration for AutoRestReportService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestReportServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestreportservice/{}".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/ReportLowLevel/reportlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/_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/ReportLowLevel/reportlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/aio/__init__.py new file mode 100644 index 00000000000..7d397c69aa8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/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 ._auto_rest_report_service import AutoRestReportService + +__all__ = ["AutoRestReportService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/aio/_auto_rest_report_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/aio/_auto_rest_report_service.py new file mode 100644 index 00000000000..437470c49e5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/aio/_auto_rest_report_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestReportServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestReportService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestReportServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `reportlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from reportlowlevel.rest import build_get_report_request + >>> request = build_get_report_request(qualifier=qualifier, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestReportService": + 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/ReportLowLevel/reportlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..0b086b995d9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/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 AutoRestReportServiceConfiguration(Configuration): + """Configuration for AutoRestReportService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestReportServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestreportservice/{}".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/ReportLowLevel/reportlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/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/ReportLowLevel/reportlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/__init__.py new file mode 100644 index 00000000000..7d62f26b1bd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/__init__.py @@ -0,0 +1,19 @@ +# 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_get_report_request + from ._request_builders_py3 import build_get_optional_report_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_report_request # type: ignore + from ._request_builders import build_get_optional_report_request # type: ignore + +__all__ = [ + "build_get_report_request", + "build_get_optional_report_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..2b022846ee6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/_request_builders.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. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_report_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + qualifier = kwargs.pop('qualifier', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/report') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters['qualifier'] = _SERIALIZER.query("qualifier", qualifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_optional_report_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get optional test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + qualifier = kwargs.pop('qualifier', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/report/optional') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters['qualifier'] = _SERIALIZER.query("qualifier", qualifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..b86ec08a308 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/reportlowlevel/rest/_request_builders_py3.py @@ -0,0 +1,93 @@ +# 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, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_report_request(*, qualifier: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/report") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters["qualifier"] = _SERIALIZER.query("qualifier", qualifier, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_optional_report_request(*, qualifier: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get optional test coverage report. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword qualifier: If specified, qualifies the generated report further (e.g. '2.7' vs '3.5' + in for Python). The only effect is, that generators that run all tests several times, can + distinguish the generated reports. + :paramtype qualifier: str + :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 + + # response body for status code(s): 200 + response.json() == { + "str": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/report/optional") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if qualifier is not None: + query_parameters["qualifier"] = _SERIALIZER.query("qualifier", qualifier, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/setup.py new file mode 100644 index 00000000000..c8c36f71df3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ReportLowLevel/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 = "autorestreportservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestReportService", + author_email="", + url="", + keywords=["Swagger", "AutoRestReportService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/__init__.py new file mode 100644 index 00000000000..80e968ca2c3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/__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 ._auto_rest_required_optional_test_service import AutoRestRequiredOptionalTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestRequiredOptionalTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_auto_rest_required_optional_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_auto_rest_required_optional_test_service.py new file mode 100644 index 00000000000..d40ad55dfbf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_auto_rest_required_optional_test_service.py @@ -0,0 +1,102 @@ +# 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 AutoRestRequiredOptionalTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestRequiredOptionalTestService(object): + """Test Infrastructure for AutoRest. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :param required_global_query: number of items to skip. + :type required_global_query: str + :param optional_global_query: number of items to skip. + :type optional_global_query: int + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + required_global_path, # type: str + required_global_query, # type: str + optional_global_query=None, # type: Optional[int] + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRequiredOptionalTestServiceConfiguration( + required_global_path, required_global_query, optional_global_query, **kwargs + ) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `requiredoptionallowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from requiredoptionallowlevel.rest import implicit + >>> request = implicit.build_get_required_path_request(path_parameter, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestRequiredOptionalTestService + 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/RequiredOptionalLowLevel/requiredoptionallowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_configuration.py new file mode 100644 index 00000000000..04d77f09a9d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_configuration.py @@ -0,0 +1,67 @@ +# 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, Optional + + +class AutoRestRequiredOptionalTestServiceConfiguration(Configuration): + """Configuration for AutoRestRequiredOptionalTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :param required_global_query: number of items to skip. + :type required_global_query: str + :param optional_global_query: number of items to skip. + :type optional_global_query: int + """ + + def __init__( + self, + required_global_path, # type: str + required_global_query, # type: str + optional_global_query=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + if required_global_path is None: + raise ValueError("Parameter 'required_global_path' must not be None.") + if required_global_query is None: + raise ValueError("Parameter 'required_global_query' must not be None.") + super(AutoRestRequiredOptionalTestServiceConfiguration, self).__init__(**kwargs) + + self.required_global_path = required_global_path + self.required_global_query = required_global_query + self.optional_global_query = optional_global_query + kwargs.setdefault("sdk_moniker", "autorestrequiredoptionaltestservice/{}".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/RequiredOptionalLowLevel/requiredoptionallowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/_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/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/__init__.py new file mode 100644 index 00000000000..ca54bbbf19d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/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 ._auto_rest_required_optional_test_service import AutoRestRequiredOptionalTestService + +__all__ = ["AutoRestRequiredOptionalTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/_auto_rest_required_optional_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/_auto_rest_required_optional_test_service.py new file mode 100644 index 00000000000..32e70dddc89 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/_auto_rest_required_optional_test_service.py @@ -0,0 +1,92 @@ +# 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 AutoRestRequiredOptionalTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestRequiredOptionalTestService: + """Test Infrastructure for AutoRest. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :param required_global_query: number of items to skip. + :type required_global_query: str + :param optional_global_query: number of items to skip. + :type optional_global_query: int + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + required_global_path: str, + required_global_query: str, + optional_global_query: Optional[int] = None, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestRequiredOptionalTestServiceConfiguration( + required_global_path, required_global_query, optional_global_query, **kwargs + ) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `requiredoptionallowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from requiredoptionallowlevel.rest import implicit + >>> request = implicit.build_get_required_path_request(path_parameter, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestRequiredOptionalTestService": + 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/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/_configuration.py new file mode 100644 index 00000000000..017774c5a5d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/aio/_configuration.py @@ -0,0 +1,59 @@ +# 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, Optional + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + + +class AutoRestRequiredOptionalTestServiceConfiguration(Configuration): + """Configuration for AutoRestRequiredOptionalTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :param required_global_query: number of items to skip. + :type required_global_query: str + :param optional_global_query: number of items to skip. + :type optional_global_query: int + """ + + def __init__( + self, + required_global_path: str, + required_global_query: str, + optional_global_query: Optional[int] = None, + **kwargs: Any + ) -> None: + if required_global_path is None: + raise ValueError("Parameter 'required_global_path' must not be None.") + if required_global_query is None: + raise ValueError("Parameter 'required_global_query' must not be None.") + super(AutoRestRequiredOptionalTestServiceConfiguration, self).__init__(**kwargs) + + self.required_global_path = required_global_path + self.required_global_query = required_global_query + self.optional_global_query = optional_global_query + kwargs.setdefault("sdk_moniker", "autorestrequiredoptionaltestservice/{}".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/RequiredOptionalLowLevel/requiredoptionallowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/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/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/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/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/__init__.py new file mode 100644 index 00000000000..573a6e28340 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_put_optional_binary_body_request + from ._request_builders_py3 import build_put_required_binary_body_request + from ._request_builders_py3 import build_post_required_integer_parameter_request + from ._request_builders_py3 import build_post_optional_integer_parameter_request + from ._request_builders_py3 import build_post_required_integer_property_request + from ._request_builders_py3 import build_post_optional_integer_property_request + from ._request_builders_py3 import build_post_required_integer_header_request + from ._request_builders_py3 import build_post_optional_integer_header_request + from ._request_builders_py3 import build_post_required_string_parameter_request + from ._request_builders_py3 import build_post_optional_string_parameter_request + from ._request_builders_py3 import build_post_required_string_property_request + from ._request_builders_py3 import build_post_optional_string_property_request + from ._request_builders_py3 import build_post_required_string_header_request + from ._request_builders_py3 import build_post_optional_string_header_request + from ._request_builders_py3 import build_post_required_class_parameter_request + from ._request_builders_py3 import build_post_optional_class_parameter_request + from ._request_builders_py3 import build_post_required_class_property_request + from ._request_builders_py3 import build_post_optional_class_property_request + from ._request_builders_py3 import build_post_required_array_parameter_request + from ._request_builders_py3 import build_post_optional_array_parameter_request + from ._request_builders_py3 import build_post_required_array_property_request + from ._request_builders_py3 import build_post_optional_array_property_request + from ._request_builders_py3 import build_post_required_array_header_request + from ._request_builders_py3 import build_post_optional_array_header_request +except (SyntaxError, ImportError): + from ._request_builders import build_put_optional_binary_body_request # type: ignore + from ._request_builders import build_put_required_binary_body_request # type: ignore + from ._request_builders import build_post_required_integer_parameter_request # type: ignore + from ._request_builders import build_post_optional_integer_parameter_request # type: ignore + from ._request_builders import build_post_required_integer_property_request # type: ignore + from ._request_builders import build_post_optional_integer_property_request # type: ignore + from ._request_builders import build_post_required_integer_header_request # type: ignore + from ._request_builders import build_post_optional_integer_header_request # type: ignore + from ._request_builders import build_post_required_string_parameter_request # type: ignore + from ._request_builders import build_post_optional_string_parameter_request # type: ignore + from ._request_builders import build_post_required_string_property_request # type: ignore + from ._request_builders import build_post_optional_string_property_request # type: ignore + from ._request_builders import build_post_required_string_header_request # type: ignore + from ._request_builders import build_post_optional_string_header_request # type: ignore + from ._request_builders import build_post_required_class_parameter_request # type: ignore + from ._request_builders import build_post_optional_class_parameter_request # type: ignore + from ._request_builders import build_post_required_class_property_request # type: ignore + from ._request_builders import build_post_optional_class_property_request # type: ignore + from ._request_builders import build_post_required_array_parameter_request # type: ignore + from ._request_builders import build_post_optional_array_parameter_request # type: ignore + from ._request_builders import build_post_required_array_property_request # type: ignore + from ._request_builders import build_post_optional_array_property_request # type: ignore + from ._request_builders import build_post_required_array_header_request # type: ignore + from ._request_builders import build_post_optional_array_header_request # type: ignore + +__all__ = [ + "build_put_optional_binary_body_request", + "build_put_required_binary_body_request", + "build_post_required_integer_parameter_request", + "build_post_optional_integer_parameter_request", + "build_post_required_integer_property_request", + "build_post_optional_integer_property_request", + "build_post_required_integer_header_request", + "build_post_optional_integer_header_request", + "build_post_required_string_parameter_request", + "build_post_optional_string_parameter_request", + "build_post_required_string_property_request", + "build_post_optional_string_property_request", + "build_post_required_string_header_request", + "build_post_optional_string_header_request", + "build_post_required_class_parameter_request", + "build_post_optional_class_parameter_request", + "build_post_required_class_property_request", + "build_post_optional_class_property_request", + "build_post_required_array_parameter_request", + "build_post_optional_array_parameter_request", + "build_post_required_array_property_request", + "build_post_optional_array_property_request", + "build_post_required_array_header_request", + "build_post_optional_array_header_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/_request_builders.py new file mode 100644 index 00000000000..5f09f706b0e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/_request_builders.py @@ -0,0 +1,1113 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_put_optional_binary_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/explicit/optional/binary-body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_required_binary_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/explicit/required/binary-body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_integer_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required integer. Please put null and the client library should throw before + the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/integer/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_integer_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/integer/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_integer_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "int" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/integer/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_integer_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "int (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/integer/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_integer_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required integer. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + header_parameter = kwargs.pop('header_parameter') # type: int + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/integer/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_integer_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + header_parameter = kwargs.pop('header_parameter', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/integer/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, 'int') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_string_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required string. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/string/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_string_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional string. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/string/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_string_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "str" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/string/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_string_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/string/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_string_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required string. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: str + :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 + """ + + header_parameter = kwargs.pop('header_parameter') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/string/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_string_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional string. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword body_parameter: + :paramtype body_parameter: str + :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 + """ + + body_parameter = kwargs.pop('body_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/string/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if body_parameter is not None: + header_parameters['bodyParameter'] = _SERIALIZER.header("body_parameter", body_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_class_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required complex object. Please put null and the client library should throw + before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "int", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/class/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_class_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional complex object. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "int", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/class/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_class_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null + and the client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": { + "id": "int", + "name": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/class/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_class_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": { + "id": "int", + "name": "str (optional)" + } + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/class/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_array_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required array. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/array/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_array_parameter_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional array. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/array/parameter') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_array_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": [ + "str" + ] + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/array/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_array_property_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/array/property') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_required_array_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly required array. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + header_parameter = kwargs.pop('header_parameter') # type: List[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/requied/array/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, '[str]', div=',') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_post_optional_array_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + header_parameter = kwargs.pop('header_parameter', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/optional/array/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters['headerParameter'] = _SERIALIZER.header("header_parameter", header_parameter, '[str]', div=',') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/_request_builders_py3.py new file mode 100644 index 00000000000..9018a8ee4aa --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/explicit/_request_builders_py3.py @@ -0,0 +1,920 @@ +# 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, IO, List, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_put_optional_binary_body_request(*, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/explicit/optional/binary-body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_put_required_binary_body_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Test explicitly required body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/explicit/required/binary-body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_post_required_integer_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly required integer. Please put null and the client library should throw before + the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/integer/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_integer_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional integer. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "int (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/integer/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_integer_property_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "int" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/integer/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_integer_property_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "int (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/integer/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_integer_header_request(*, header_parameter: int, **kwargs: Any) -> HttpRequest: + """Test explicitly required integer. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/integer/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_optional_integer_header_request(*, header_parameter: Optional[int] = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/integer/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "int") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_required_string_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly required string. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/string/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_string_parameter_request( + *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional string. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/string/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_string_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "str" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/string/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_string_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/string/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_string_header_request(*, header_parameter: str, **kwargs: Any) -> HttpRequest: + """Test explicitly required string. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/string/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_optional_string_header_request(*, body_parameter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional string. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword body_parameter: + :paramtype body_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/string/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if body_parameter is not None: + header_parameters["bodyParameter"] = _SERIALIZER.header("body_parameter", body_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_required_class_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required complex object. Please put null and the client library should throw + before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "int", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/class/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_class_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional complex object. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "int", + "name": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/class/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_class_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null + and the client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": { + "id": "int", + "name": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/class/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_class_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": { + "id": "int", + "name": "str (optional)" + } + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/class/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_array_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required array. Please put null and the client library should throw before the + request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/array/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_array_parameter_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional array. Please put null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = [ + "str (optional)" + ] + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/array/parameter") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_array_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the + client library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": [ + "str" + ] + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/array/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_optional_array_property_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "value": [ + "str (optional)" + ] + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/array/property") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_post_required_array_header_request(*, header_parameter: List[str], **kwargs: Any) -> HttpRequest: + """Test explicitly required array. Please put a header 'headerParameter' => null and the client + library should throw before the request is sent. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/requied/array/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["headerParameter"] = _SERIALIZER.header("header_parameter", header_parameter, "[str]", div=",") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_post_optional_array_header_request( + *, header_parameter: Optional[List[str]] = None, **kwargs: Any +) -> HttpRequest: + """Test explicitly optional integer. Please put a header 'headerParameter' => null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword header_parameter: + :paramtype header_parameter: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/optional/array/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if header_parameter is not None: + header_parameters["headerParameter"] = _SERIALIZER.header( + "header_parameter", header_parameter, "[str]", div="," + ) + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/__init__.py new file mode 100644 index 00000000000..7963f152b24 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_get_required_path_request + from ._request_builders_py3 import build_put_optional_query_request + from ._request_builders_py3 import build_put_optional_header_request + from ._request_builders_py3 import build_put_optional_body_request + from ._request_builders_py3 import build_put_optional_binary_body_request + from ._request_builders_py3 import build_get_required_global_path_request + from ._request_builders_py3 import build_get_required_global_query_request + from ._request_builders_py3 import build_get_optional_global_query_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_required_path_request # type: ignore + from ._request_builders import build_put_optional_query_request # type: ignore + from ._request_builders import build_put_optional_header_request # type: ignore + from ._request_builders import build_put_optional_body_request # type: ignore + from ._request_builders import build_put_optional_binary_body_request # type: ignore + from ._request_builders import build_get_required_global_path_request # type: ignore + from ._request_builders import build_get_required_global_query_request # type: ignore + from ._request_builders import build_get_optional_global_query_request # type: ignore + +__all__ = [ + "build_get_required_path_request", + "build_put_optional_query_request", + "build_put_optional_header_request", + "build_put_optional_body_request", + "build_put_optional_binary_body_request", + "build_get_required_global_path_request", + "build_get_required_global_query_request", + "build_get_optional_global_query_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/_request_builders.py new file mode 100644 index 00000000000..7e2019aeede --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/_request_builders.py @@ -0,0 +1,339 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, IO, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_required_path_request( + path_parameter, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_parameter: + :type path_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/required/path/{pathParameter}') + path_format_arguments = { + 'pathParameter': _SERIALIZER.url("path_parameter", path_parameter, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_query_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + query_parameter = kwargs.pop('query_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/query') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_parameter is not None: + query_parameters['queryParameter'] = _SERIALIZER.query("query_parameter", query_parameter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_header_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional header parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + query_parameter = kwargs.pop('query_parameter', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/header') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if query_parameter is not None: + header_parameters['queryParameter'] = _SERIALIZER.header("query_parameter", query_parameter, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_optional_binary_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/implicit/optional/binary-body') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_required_global_path_request( + required_global_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/global/required/path/{required-global-path}') + path_format_arguments = { + 'required-global-path': _SERIALIZER.url("required_global_path", required_global_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_required_global_query_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly required query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_global_query: number of items to skip. + :paramtype required_global_query: str + :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 + """ + + required_global_query = kwargs.pop('required_global_query') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/global/required/query') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['required-global-query'] = _SERIALIZER.query("required_global_query", required_global_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_optional_global_query_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword optional_global_query: number of items to skip. + :paramtype optional_global_query: int + :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 + """ + + optional_global_query = kwargs.pop('optional_global_query', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/reqopt/global/optional/query') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if optional_global_query is not None: + query_parameters['optional-global-query'] = _SERIALIZER.query("optional_global_query", optional_global_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/_request_builders_py3.py new file mode 100644 index 00000000000..49712930601 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/requiredoptionallowlevel/rest/implicit/_request_builders_py3.py @@ -0,0 +1,261 @@ +# 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, IO, List, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_required_path_request(path_parameter: str, **kwargs: Any) -> HttpRequest: + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_parameter: + :type path_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/required/path/{pathParameter}") + path_format_arguments = { + "pathParameter": _SERIALIZER.url("path_parameter", path_parameter, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_optional_query_request(*, query_parameter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/query") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if query_parameter is not None: + query_parameters["queryParameter"] = _SERIALIZER.query("query_parameter", query_parameter, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_put_optional_header_request(*, query_parameter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional header parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword query_parameter: + :paramtype query_parameter: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/header") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if query_parameter is not None: + header_parameters["queryParameter"] = _SERIALIZER.header("query_parameter", query_parameter, "str") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, **kwargs) + + +def build_put_optional_body_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = "str (optional)" + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_put_optional_binary_body_request(*, content: Any = None, **kwargs: Any) -> HttpRequest: + """Test implicitly optional body parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/implicit/optional/binary-body") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_required_global_path_request(required_global_path: str, **kwargs: Any) -> HttpRequest: + """Test implicitly required path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param required_global_path: number of items to skip. + :type required_global_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/global/required/path/{required-global-path}") + path_format_arguments = { + "required-global-path": _SERIALIZER.url("required_global_path", required_global_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_required_global_query_request(*, required_global_query: str, **kwargs: Any) -> HttpRequest: + """Test implicitly required query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword required_global_query: number of items to skip. + :paramtype required_global_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/global/required/query") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["required-global-query"] = _SERIALIZER.query("required_global_query", required_global_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_optional_global_query_request( + *, optional_global_query: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + """Test implicitly optional query parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword optional_global_query: number of items to skip. + :paramtype optional_global_query: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/reqopt/global/optional/query") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if optional_global_query is not None: + query_parameters["optional-global-query"] = _SERIALIZER.query( + "optional_global_query", optional_global_query, "int" + ) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/setup.py new file mode 100644 index 00000000000..50394544490 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/RequiredOptionalLowLevel/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 = "autorestrequiredoptionaltestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestRequiredOptionalTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestRequiredOptionalTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/setup.py new file mode 100644 index 00000000000..e4d0aa34330 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/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 = "autoresturltestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestUrlTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestUrlTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/__init__.py new file mode 100644 index 00000000000..b0ddf6aa89e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/__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 ._auto_rest_url_test_service import AutoRestUrlTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestUrlTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_auto_rest_url_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_auto_rest_url_test_service.py new file mode 100644 index 00000000000..553b5db9cbc --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_auto_rest_url_test_service.py @@ -0,0 +1,97 @@ +# 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 AutoRestUrlTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestUrlTestService(object): + """Test Infrastructure for AutoRest. + + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param global_string_query: should contain value null. + :type global_string_query: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + global_string_path, # type: str + global_string_query=None, # type: Optional[str] + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `urllowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from urllowlevel.rest import paths + >>> request = paths.build_get_boolean_true_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestUrlTestService + 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/UrlLowLevel/urllowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_configuration.py new file mode 100644 index 00000000000..820efa20c14 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_configuration.py @@ -0,0 +1,61 @@ +# 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, Optional + + +class AutoRestUrlTestServiceConfiguration(Configuration): + """Configuration for AutoRestUrlTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param global_string_query: should contain value null. + :type global_string_query: str + """ + + def __init__( + self, + global_string_path, # type: str + global_string_query=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if global_string_path is None: + raise ValueError("Parameter 'global_string_path' must not be None.") + super(AutoRestUrlTestServiceConfiguration, self).__init__(**kwargs) + + self.global_string_path = global_string_path + self.global_string_query = global_string_query + kwargs.setdefault("sdk_moniker", "autoresturltestservice/{}".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/UrlLowLevel/urllowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/_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/UrlLowLevel/urllowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/aio/__init__.py new file mode 100644 index 00000000000..3e3440baef2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/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 ._auto_rest_url_test_service import AutoRestUrlTestService + +__all__ = ["AutoRestUrlTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/aio/_auto_rest_url_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/aio/_auto_rest_url_test_service.py new file mode 100644 index 00000000000..2b8a6a50a7e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/aio/_auto_rest_url_test_service.py @@ -0,0 +1,87 @@ +# 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 AutoRestUrlTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestUrlTestService: + """Test Infrastructure for AutoRest. + + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param global_string_query: should contain value null. + :type global_string_query: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + global_string_path: str, + global_string_query: Optional[str] = None, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `urllowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from urllowlevel.rest import paths + >>> request = paths.build_get_boolean_true_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestUrlTestService": + 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/UrlLowLevel/urllowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/aio/_configuration.py new file mode 100644 index 00000000000..4a97851c593 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/aio/_configuration.py @@ -0,0 +1,48 @@ +# 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, Optional + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + + +class AutoRestUrlTestServiceConfiguration(Configuration): + """Configuration for AutoRestUrlTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param global_string_query: should contain value null. + :type global_string_query: str + """ + + def __init__(self, global_string_path: str, global_string_query: Optional[str] = None, **kwargs: Any) -> None: + if global_string_path is None: + raise ValueError("Parameter 'global_string_path' must not be None.") + super(AutoRestUrlTestServiceConfiguration, self).__init__(**kwargs) + + self.global_string_path = global_string_path + self.global_string_query = global_string_query + kwargs.setdefault("sdk_moniker", "autoresturltestservice/{}".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/UrlLowLevel/urllowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/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/UrlLowLevel/urllowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/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/UrlLowLevel/urllowlevel/rest/path_items/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/__init__.py new file mode 100644 index 00000000000..cd604938f2c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/__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 ._request_builders_py3 import build_get_all_with_values_request + from ._request_builders_py3 import build_get_global_query_null_request + from ._request_builders_py3 import build_get_global_and_local_query_null_request + from ._request_builders_py3 import build_get_local_path_item_query_null_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_all_with_values_request # type: ignore + from ._request_builders import build_get_global_query_null_request # type: ignore + from ._request_builders import build_get_global_and_local_query_null_request # type: ignore + from ._request_builders import build_get_local_path_item_query_null_request # type: ignore + +__all__ = [ + "build_get_all_with_values_request", + "build_get_global_query_null_request", + "build_get_global_and_local_query_null_request", + "build_get_local_path_item_query_null_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/_request_builders.py new file mode 100644 index 00000000000..49fd305be47 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/_request_builders.py @@ -0,0 +1,295 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_all_with_values_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_global_query_null_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_global_and_local_query_null_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain null value. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_local_path_item_query_null_request( + path_item_string_path, # type: str + global_string_path, # type: str + local_string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery=null, localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: should contain value null. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value null. + :paramtype local_string_query: str + :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 + """ + + path_item_string_query = kwargs.pop('path_item_string_query', None) # type: Optional[str] + global_string_query = kwargs.pop('global_string_query', None) # type: Optional[str] + local_string_query = kwargs.pop('local_string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null') + path_format_arguments = { + 'pathItemStringPath': _SERIALIZER.url("path_item_string_path", path_item_string_path, 'str'), + 'globalStringPath': _SERIALIZER.url("global_string_path", global_string_path, 'str'), + 'localStringPath': _SERIALIZER.url("local_string_path", local_string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters['pathItemStringQuery'] = _SERIALIZER.query("path_item_string_query", path_item_string_query, 'str') + if global_string_query is not None: + query_parameters['globalStringQuery'] = _SERIALIZER.query("global_string_query", global_string_query, 'str') + if local_string_query is not None: + query_parameters['localStringQuery'] = _SERIALIZER.query("local_string_query", local_string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/_request_builders_py3.py new file mode 100644 index 00000000000..99c7aa52b74 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/path_items/_request_builders_py3.py @@ -0,0 +1,282 @@ +# 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 datetime +from typing import Any, List, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_all_with_values_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_global_query_null_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery='localStringQuery'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value 'localStringQuery'. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_global_and_local_query_null_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery=null, + pathItemStringQuery='pathItemStringQuery', localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: A string value 'pathItemStringQuery' that appears as a query + parameter. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain null value. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_local_path_item_query_null_request( + path_item_string_path: str, + global_string_path: str, + local_string_path: str, + *, + path_item_string_query: Optional[str] = None, + global_string_query: Optional[str] = None, + local_string_query: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + """send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', + localStringPath='localStringPath', globalStringQuery='globalStringQuery', + pathItemStringQuery=null, localStringQuery=null. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param path_item_string_path: A string value 'pathItemStringPath' that appears in the path. + :type path_item_string_path: str + :param global_string_path: A string value 'globalItemStringPath' that appears in the path. + :type global_string_path: str + :param local_string_path: should contain value 'localStringPath'. + :type local_string_path: str + :keyword path_item_string_query: should contain value null. + :paramtype path_item_string_query: str + :keyword global_string_query: should contain value null. + :paramtype global_string_query: str + :keyword local_string_query: should contain value null. + :paramtype local_string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null", + ) + path_format_arguments = { + "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), + "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), + "localStringPath": _SERIALIZER.url("local_string_path", local_string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if path_item_string_query is not None: + query_parameters["pathItemStringQuery"] = _SERIALIZER.query( + "path_item_string_query", path_item_string_query, "str" + ) + if global_string_query is not None: + query_parameters["globalStringQuery"] = _SERIALIZER.query("global_string_query", global_string_query, "str") + if local_string_query is not None: + query_parameters["localStringQuery"] = _SERIALIZER.query("local_string_query", local_string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/__init__.py new file mode 100644 index 00000000000..5f24a088959 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/__init__.py @@ -0,0 +1,94 @@ +# 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_get_boolean_true_request + from ._request_builders_py3 import build_get_boolean_false_request + from ._request_builders_py3 import build_get_int_one_million_request + from ._request_builders_py3 import build_get_int_negative_one_million_request + from ._request_builders_py3 import build_get_ten_billion_request + from ._request_builders_py3 import build_get_negative_ten_billion_request + from ._request_builders_py3 import build_float_scientific_positive_request + from ._request_builders_py3 import build_float_scientific_negative_request + from ._request_builders_py3 import build_double_decimal_positive_request + from ._request_builders_py3 import build_double_decimal_negative_request + from ._request_builders_py3 import build_string_unicode_request + from ._request_builders_py3 import build_string_url_encoded_request + from ._request_builders_py3 import build_string_url_non_encoded_request + from ._request_builders_py3 import build_string_empty_request + from ._request_builders_py3 import build_string_null_request + from ._request_builders_py3 import build_enum_valid_request + from ._request_builders_py3 import build_enum_null_request + from ._request_builders_py3 import build_byte_multi_byte_request + from ._request_builders_py3 import build_byte_empty_request + from ._request_builders_py3 import build_byte_null_request + from ._request_builders_py3 import build_date_valid_request + from ._request_builders_py3 import build_date_null_request + from ._request_builders_py3 import build_date_time_valid_request + from ._request_builders_py3 import build_date_time_null_request + from ._request_builders_py3 import build_base64_url_request + from ._request_builders_py3 import build_array_csv_in_path_request + from ._request_builders_py3 import build_unix_time_url_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_boolean_true_request # type: ignore + from ._request_builders import build_get_boolean_false_request # type: ignore + from ._request_builders import build_get_int_one_million_request # type: ignore + from ._request_builders import build_get_int_negative_one_million_request # type: ignore + from ._request_builders import build_get_ten_billion_request # type: ignore + from ._request_builders import build_get_negative_ten_billion_request # type: ignore + from ._request_builders import build_float_scientific_positive_request # type: ignore + from ._request_builders import build_float_scientific_negative_request # type: ignore + from ._request_builders import build_double_decimal_positive_request # type: ignore + from ._request_builders import build_double_decimal_negative_request # type: ignore + from ._request_builders import build_string_unicode_request # type: ignore + from ._request_builders import build_string_url_encoded_request # type: ignore + from ._request_builders import build_string_url_non_encoded_request # type: ignore + from ._request_builders import build_string_empty_request # type: ignore + from ._request_builders import build_string_null_request # type: ignore + from ._request_builders import build_enum_valid_request # type: ignore + from ._request_builders import build_enum_null_request # type: ignore + from ._request_builders import build_byte_multi_byte_request # type: ignore + from ._request_builders import build_byte_empty_request # type: ignore + from ._request_builders import build_byte_null_request # type: ignore + from ._request_builders import build_date_valid_request # type: ignore + from ._request_builders import build_date_null_request # type: ignore + from ._request_builders import build_date_time_valid_request # type: ignore + from ._request_builders import build_date_time_null_request # type: ignore + from ._request_builders import build_base64_url_request # type: ignore + from ._request_builders import build_array_csv_in_path_request # type: ignore + from ._request_builders import build_unix_time_url_request # type: ignore + +__all__ = [ + "build_get_boolean_true_request", + "build_get_boolean_false_request", + "build_get_int_one_million_request", + "build_get_int_negative_one_million_request", + "build_get_ten_billion_request", + "build_get_negative_ten_billion_request", + "build_float_scientific_positive_request", + "build_float_scientific_negative_request", + "build_double_decimal_positive_request", + "build_double_decimal_negative_request", + "build_string_unicode_request", + "build_string_url_encoded_request", + "build_string_url_non_encoded_request", + "build_string_empty_request", + "build_string_null_request", + "build_enum_valid_request", + "build_enum_null_request", + "build_byte_multi_byte_request", + "build_byte_empty_request", + "build_byte_null_request", + "build_date_valid_request", + "build_date_null_request", + "build_date_time_valid_request", + "build_date_time_null_request", + "build_base64_url_request", + "build_array_csv_in_path_request", + "build_unix_time_url_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/_request_builders.py new file mode 100644 index 00000000000..f5a139138f7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/_request_builders.py @@ -0,0 +1,1017 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_boolean_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/bool/true/{boolPath}') + path_format_arguments = { + 'boolPath': _SERIALIZER.url("bool_path", bool_path, 'bool'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/bool/false/{boolPath}') + path_format_arguments = { + 'boolPath': _SERIALIZER.url("bool_path", bool_path, 'bool'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/int/1000000/{intPath}') + path_format_arguments = { + 'intPath': _SERIALIZER.url("int_path", int_path, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_negative_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/int/-1000000/{intPath}') + path_format_arguments = { + 'intPath': _SERIALIZER.url("int_path", int_path, 'int'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/long/10000000000/{longPath}') + path_format_arguments = { + 'longPath': _SERIALIZER.url("long_path", long_path, 'long'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_negative_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/long/-10000000000/{longPath}') + path_format_arguments = { + 'longPath': _SERIALIZER.url("long_path", long_path, 'long'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/float/1.034E+20/{floatPath}') + path_format_arguments = { + 'floatPath': _SERIALIZER.url("float_path", float_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/float/-1.034E-20/{floatPath}') + path_format_arguments = { + 'floatPath': _SERIALIZER.url("float_path", float_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/double/9999999.999/{doublePath}') + path_format_arguments = { + 'doublePath': _SERIALIZER.url("double_path", double_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/double/-9999999.999/{doublePath}') + path_format_arguments = { + 'doublePath': _SERIALIZER.url("double_path", double_path, 'float'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_unicode_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/unicode/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_url_non_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'begin!*'();:@&=+$,end. + + https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@&=+$,end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/begin!*\'();:@&=+$,end/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str', skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/empty/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_string_null_request( + string_path, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param string_path: null string value. + :type string_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/null/{stringPath}') + path_format_arguments = { + 'stringPath': _SERIALIZER.url("string_path", string_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_enum_valid_request( + enum_path, # type: Union[str, "_models.UriColor"] + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get using uri with 'green color' in path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send the value green. + :type enum_path: str or ~urllowlevel.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/enum/green%20color/{enumPath}') + path_format_arguments = { + 'enumPath': _SERIALIZER.url("enum_path", enum_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_enum_null_request( + enum_path, # type: Union[str, "_models.UriColor"] + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (should throw on the client before the request is sent on wire). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send null should throw. + :type enum_path: str or ~urllowlevel.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/null/{enumPath}') + path_format_arguments = { + 'enumPath': _SERIALIZER.url("enum_path", enum_path, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_byte_multi_byte_request( + byte_path, # type: bytearray + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/byte/multibyte/{bytePath}') + path_format_arguments = { + 'bytePath': _SERIALIZER.url("byte_path", byte_path, 'bytearray'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_byte_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_path = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/byte/empty/{bytePath}') + path_format_arguments = { + 'bytePath': _SERIALIZER.url("byte_path", byte_path, 'bytearray'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_byte_null_request( + byte_path, # type: bytearray + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as byte array (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: null as byte array (should throw). + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/byte/null/{bytePath}') + path_format_arguments = { + 'bytePath': _SERIALIZER.url("byte_path", byte_path, 'bytearray'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_path = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/date/2012-01-01/{datePath}') + path_format_arguments = { + 'datePath': _SERIALIZER.url("date_path", date_path, 'date'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_null_request( + date_path, # type: datetime.date + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date - this should throw or be unusable on the client side, depending on date + representation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_path: null as date (should throw). + :type date_path: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/date/null/{datePath}') + path_format_arguments = { + 'datePath': _SERIALIZER.url("date_path", date_path, 'date'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_path = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}') + path_format_arguments = { + 'dateTimePath': _SERIALIZER.url("date_time_path", date_time_path, 'iso-8601'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_null_request( + date_time_path, # type: datetime.datetime + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date-time, should be disallowed or throw depending on representation of date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_time_path: null as date-time. + :type date_time_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/datetime/null/{dateTimePath}') + path_format_arguments = { + 'dateTimePath': _SERIALIZER.url("date_time_path", date_time_path, 'iso-8601'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_base64_url_request( + base64_url_path, # type: bytes + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'lorem' encoded value as 'bG9yZW0' (base64url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param base64_url_path: base64url encoded value. + :type base64_url_path: bytes + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/string/bG9yZW0/{base64UrlPath}') + path_format_arguments = { + 'base64UrlPath': _SERIALIZER.url("base64_url_path", base64_url_path, 'base64'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_array_csv_in_path_request( + array_path, # type: List[str] + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] + using the csv-array format. + :type array_path: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}') + path_format_arguments = { + 'arrayPath': _SERIALIZER.url("array_path", array_path, '[str]', div=','), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_unix_time_url_request( + unix_time_url_path, # type: datetime.datetime + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unix_time_url_path: Unix time encoded value. + :type unix_time_url_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/paths/int/1460505600/{unixTimeUrlPath}') + path_format_arguments = { + 'unixTimeUrlPath': _SERIALIZER.url("unix_time_url_path", unix_time_url_path, 'unix-time'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/_request_builders_py3.py new file mode 100644 index 00000000000..bbd71e10a94 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/paths/_request_builders_py3.py @@ -0,0 +1,791 @@ +# 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 datetime +from typing import Any, List, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_boolean_true_request(**kwargs: Any) -> HttpRequest: + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/bool/true/{boolPath}") + path_format_arguments = { + "boolPath": _SERIALIZER.url("bool_path", bool_path, "bool"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_boolean_false_request(**kwargs: Any) -> HttpRequest: + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_path = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/bool/false/{boolPath}") + path_format_arguments = { + "boolPath": _SERIALIZER.url("bool_path", bool_path, "bool"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/int/1000000/{intPath}") + path_format_arguments = { + "intPath": _SERIALIZER.url("int_path", int_path, "int"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_int_negative_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_path = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/int/-1000000/{intPath}") + path_format_arguments = { + "intPath": _SERIALIZER.url("int_path", int_path, "int"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/long/10000000000/{longPath}") + path_format_arguments = { + "longPath": _SERIALIZER.url("long_path", long_path, "long"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_negative_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_path = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/long/-10000000000/{longPath}") + path_format_arguments = { + "longPath": _SERIALIZER.url("long_path", long_path, "long"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_float_scientific_positive_request(**kwargs: Any) -> HttpRequest: + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/float/1.034E+20/{floatPath}") + path_format_arguments = { + "floatPath": _SERIALIZER.url("float_path", float_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_float_scientific_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_path = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/float/-1.034E-20/{floatPath}") + path_format_arguments = { + "floatPath": _SERIALIZER.url("float_path", float_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_double_decimal_positive_request(**kwargs: Any) -> HttpRequest: + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/double/9999999.999/{doublePath}") + path_format_arguments = { + "doublePath": _SERIALIZER.url("double_path", double_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_double_decimal_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_path = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/double/-9999999.999/{doublePath}") + path_format_arguments = { + "doublePath": _SERIALIZER.url("double_path", double_path, "float"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_unicode_request(**kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/unicode/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}" + ) + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_url_non_encoded_request(**kwargs: Any) -> HttpRequest: + """Get 'begin!*'();:@&=+$,end. + + https://tools.ietf.org/html/rfc3986#appendix-A 'path' accept any 'pchar' not encoded. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "begin!*'();:@&=+$,end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/begin!*'();:@&=+$,end/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str", skip_quote=True), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_empty_request(**kwargs: Any) -> HttpRequest: + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_path = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/empty/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_string_null_request(string_path: str, **kwargs: Any) -> HttpRequest: + """Get null (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param string_path: null string value. + :type string_path: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/null/{stringPath}") + path_format_arguments = { + "stringPath": _SERIALIZER.url("string_path", string_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_enum_valid_request(enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> HttpRequest: + """Get using uri with 'green color' in path parameter. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send the value green. + :type enum_path: str or ~urllowlevel.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/enum/green%20color/{enumPath}") + path_format_arguments = { + "enumPath": _SERIALIZER.url("enum_path", enum_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_enum_null_request(enum_path: Union[str, "_models.UriColor"], **kwargs: Any) -> HttpRequest: + """Get null (should throw on the client before the request is sent on wire). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param enum_path: send null should throw. + :type enum_path: str or ~urllowlevel.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/null/{enumPath}") + path_format_arguments = { + "enumPath": _SERIALIZER.url("enum_path", enum_path, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_byte_multi_byte_request(byte_path: bytearray, **kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/byte/multibyte/{bytePath}") + path_format_arguments = { + "bytePath": _SERIALIZER.url("byte_path", byte_path, "bytearray"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_byte_empty_request(**kwargs: Any) -> HttpRequest: + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_path = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/byte/empty/{bytePath}") + path_format_arguments = { + "bytePath": _SERIALIZER.url("byte_path", byte_path, "bytearray"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_byte_null_request(byte_path: bytearray, **kwargs: Any) -> HttpRequest: + """Get null as byte array (should throw). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param byte_path: null as byte array (should throw). + :type byte_path: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/byte/null/{bytePath}") + path_format_arguments = { + "bytePath": _SERIALIZER.url("byte_path", byte_path, "bytearray"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_path = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/date/2012-01-01/{datePath}") + path_format_arguments = { + "datePath": _SERIALIZER.url("date_path", date_path, "date"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_null_request(date_path: datetime.date, **kwargs: Any) -> HttpRequest: + """Get null as date - this should throw or be unusable on the client side, depending on date + representation. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_path: null as date (should throw). + :type date_path: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/date/null/{datePath}") + path_format_arguments = { + "datePath": _SERIALIZER.url("date_path", date_path, "date"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_path = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}") + path_format_arguments = { + "dateTimePath": _SERIALIZER.url("date_time_path", date_time_path, "iso-8601"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_date_time_null_request(date_time_path: datetime.datetime, **kwargs: Any) -> HttpRequest: + """Get null as date-time, should be disallowed or throw depending on representation of date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param date_time_path: null as date-time. + :type date_time_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/datetime/null/{dateTimePath}") + path_format_arguments = { + "dateTimePath": _SERIALIZER.url("date_time_path", date_time_path, "iso-8601"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_base64_url_request(base64_url_path: bytes, **kwargs: Any) -> HttpRequest: + """Get 'lorem' encoded value as 'bG9yZW0' (base64url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param base64_url_path: base64url encoded value. + :type base64_url_path: bytes + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/string/bG9yZW0/{base64UrlPath}") + path_format_arguments = { + "base64UrlPath": _SERIALIZER.url("base64_url_path", base64_url_path, "base64"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_array_csv_in_path_request(array_path: List[str], **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param array_path: an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] + using the csv-array format. + :type array_path: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", + "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}", + ) + path_format_arguments = { + "arrayPath": _SERIALIZER.url("array_path", array_path, "[str]", div=","), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_unix_time_url_request(unix_time_url_path: datetime.datetime, **kwargs: Any) -> HttpRequest: + """Get the date 2016-04-13 encoded value as '1460505600' (Unix time). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param unix_time_url_path: Unix time encoded value. + :type unix_time_url_path: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/paths/int/1460505600/{unixTimeUrlPath}") + path_format_arguments = { + "unixTimeUrlPath": _SERIALIZER.url("unix_time_url_path", unix_time_url_path, "unix-time"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/__init__.py new file mode 100644 index 00000000000..3017ee4219d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/__init__.py @@ -0,0 +1,118 @@ +# 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_get_boolean_true_request + from ._request_builders_py3 import build_get_boolean_false_request + from ._request_builders_py3 import build_get_boolean_null_request + from ._request_builders_py3 import build_get_int_one_million_request + from ._request_builders_py3 import build_get_int_negative_one_million_request + from ._request_builders_py3 import build_get_int_null_request + from ._request_builders_py3 import build_get_ten_billion_request + from ._request_builders_py3 import build_get_negative_ten_billion_request + from ._request_builders_py3 import build_get_long_null_request + from ._request_builders_py3 import build_float_scientific_positive_request + from ._request_builders_py3 import build_float_scientific_negative_request + from ._request_builders_py3 import build_float_null_request + from ._request_builders_py3 import build_double_decimal_positive_request + from ._request_builders_py3 import build_double_decimal_negative_request + from ._request_builders_py3 import build_double_null_request + from ._request_builders_py3 import build_string_unicode_request + from ._request_builders_py3 import build_string_url_encoded_request + from ._request_builders_py3 import build_string_empty_request + from ._request_builders_py3 import build_string_null_request + from ._request_builders_py3 import build_enum_valid_request + from ._request_builders_py3 import build_enum_null_request + from ._request_builders_py3 import build_byte_multi_byte_request + from ._request_builders_py3 import build_byte_empty_request + from ._request_builders_py3 import build_byte_null_request + from ._request_builders_py3 import build_date_valid_request + from ._request_builders_py3 import build_date_null_request + from ._request_builders_py3 import build_date_time_valid_request + from ._request_builders_py3 import build_date_time_null_request + from ._request_builders_py3 import build_array_string_csv_valid_request + from ._request_builders_py3 import build_array_string_csv_null_request + from ._request_builders_py3 import build_array_string_csv_empty_request + from ._request_builders_py3 import build_array_string_no_collection_format_empty_request + from ._request_builders_py3 import build_array_string_ssv_valid_request + from ._request_builders_py3 import build_array_string_tsv_valid_request + from ._request_builders_py3 import build_array_string_pipes_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_boolean_true_request # type: ignore + from ._request_builders import build_get_boolean_false_request # type: ignore + from ._request_builders import build_get_boolean_null_request # type: ignore + from ._request_builders import build_get_int_one_million_request # type: ignore + from ._request_builders import build_get_int_negative_one_million_request # type: ignore + from ._request_builders import build_get_int_null_request # type: ignore + from ._request_builders import build_get_ten_billion_request # type: ignore + from ._request_builders import build_get_negative_ten_billion_request # type: ignore + from ._request_builders import build_get_long_null_request # type: ignore + from ._request_builders import build_float_scientific_positive_request # type: ignore + from ._request_builders import build_float_scientific_negative_request # type: ignore + from ._request_builders import build_float_null_request # type: ignore + from ._request_builders import build_double_decimal_positive_request # type: ignore + from ._request_builders import build_double_decimal_negative_request # type: ignore + from ._request_builders import build_double_null_request # type: ignore + from ._request_builders import build_string_unicode_request # type: ignore + from ._request_builders import build_string_url_encoded_request # type: ignore + from ._request_builders import build_string_empty_request # type: ignore + from ._request_builders import build_string_null_request # type: ignore + from ._request_builders import build_enum_valid_request # type: ignore + from ._request_builders import build_enum_null_request # type: ignore + from ._request_builders import build_byte_multi_byte_request # type: ignore + from ._request_builders import build_byte_empty_request # type: ignore + from ._request_builders import build_byte_null_request # type: ignore + from ._request_builders import build_date_valid_request # type: ignore + from ._request_builders import build_date_null_request # type: ignore + from ._request_builders import build_date_time_valid_request # type: ignore + from ._request_builders import build_date_time_null_request # type: ignore + from ._request_builders import build_array_string_csv_valid_request # type: ignore + from ._request_builders import build_array_string_csv_null_request # type: ignore + from ._request_builders import build_array_string_csv_empty_request # type: ignore + from ._request_builders import build_array_string_no_collection_format_empty_request # type: ignore + from ._request_builders import build_array_string_ssv_valid_request # type: ignore + from ._request_builders import build_array_string_tsv_valid_request # type: ignore + from ._request_builders import build_array_string_pipes_valid_request # type: ignore + +__all__ = [ + "build_get_boolean_true_request", + "build_get_boolean_false_request", + "build_get_boolean_null_request", + "build_get_int_one_million_request", + "build_get_int_negative_one_million_request", + "build_get_int_null_request", + "build_get_ten_billion_request", + "build_get_negative_ten_billion_request", + "build_get_long_null_request", + "build_float_scientific_positive_request", + "build_float_scientific_negative_request", + "build_float_null_request", + "build_double_decimal_positive_request", + "build_double_decimal_negative_request", + "build_double_null_request", + "build_string_unicode_request", + "build_string_url_encoded_request", + "build_string_empty_request", + "build_string_null_request", + "build_enum_valid_request", + "build_enum_null_request", + "build_byte_multi_byte_request", + "build_byte_empty_request", + "build_byte_null_request", + "build_date_valid_request", + "build_date_null_request", + "build_date_time_valid_request", + "build_date_time_null_request", + "build_array_string_csv_valid_request", + "build_array_string_csv_null_request", + "build_array_string_csv_empty_request", + "build_array_string_no_collection_format_empty_request", + "build_array_string_ssv_valid_request", + "build_array_string_tsv_valid_request", + "build_array_string_pipes_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/_request_builders.py new file mode 100644 index 00000000000..e85ce3b26f6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/_request_builders.py @@ -0,0 +1,1400 @@ +# 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 datetime +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional, Union + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_boolean_true_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/bool/true') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['boolQuery'] = _SERIALIZER.query("bool_query", bool_query, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_false_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/bool/false') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['boolQuery'] = _SERIALIZER.query("bool_query", bool_query, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_boolean_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null Boolean value on query (query string should be absent). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword bool_query: null boolean value. + :paramtype bool_query: bool + :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 + """ + + bool_query = kwargs.pop('bool_query', None) # type: Optional[bool] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/bool/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if bool_query is not None: + query_parameters['boolQuery'] = _SERIALIZER.query("bool_query", bool_query, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/int/1000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['intQuery'] = _SERIALIZER.query("int_query", int_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_negative_one_million_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/int/-1000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['intQuery'] = _SERIALIZER.query("int_query", int_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_int_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null integer value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword int_query: null integer value. + :paramtype int_query: int + :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 + """ + + int_query = kwargs.pop('int_query', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/int/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if int_query is not None: + query_parameters['intQuery'] = _SERIALIZER.query("int_query", int_query, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/long/10000000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['longQuery'] = _SERIALIZER.query("long_query", long_query, 'long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_negative_ten_billion_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/long/-10000000000') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['longQuery'] = _SERIALIZER.query("long_query", long_query, 'long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_long_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'null 64 bit integer value (no query param in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword long_query: null 64 bit integer value. + :paramtype long_query: long + :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 + """ + + long_query = kwargs.pop('long_query', None) # type: Optional[int] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/long/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if long_query is not None: + query_parameters['longQuery'] = _SERIALIZER.query("long_query", long_query, 'long') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/float/1.034E+20') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['floatQuery'] = _SERIALIZER.query("float_query", float_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_float_scientific_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/float/-1.034E-20') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['floatQuery'] = _SERIALIZER.query("float_query", float_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_float_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword float_query: null numeric value. + :paramtype float_query: float + :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 + """ + + float_query = kwargs.pop('float_query', None) # type: Optional[float] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/float/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if float_query is not None: + query_parameters['floatQuery'] = _SERIALIZER.query("float_query", float_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_positive_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/double/9999999.999') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['doubleQuery'] = _SERIALIZER.query("double_query", double_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_double_decimal_negative_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/double/-9999999.999') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['doubleQuery'] = _SERIALIZER.query("double_query", double_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_double_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword double_query: null numeric value. + :paramtype double_query: float + :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 + """ + + double_query = kwargs.pop('double_query', None) # type: Optional[float] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/double/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if double_query is not None: + query_parameters['doubleQuery'] = _SERIALIZER.query("double_query", double_query, 'float') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_unicode_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/unicode/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_url_encoded_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_string_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword string_query: null string value. + :paramtype string_query: str + :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 + """ + + string_query = kwargs.pop('string_query', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/string/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if string_query is not None: + query_parameters['stringQuery'] = _SERIALIZER.query("string_query", string_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_enum_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get using uri with query parameter 'green color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: 'green color' enum value. + :paramtype enum_query: str or ~urllowlevel.models.UriColor + :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 + """ + + enum_query = kwargs.pop('enum_query', None) # type: Optional[Union[str, "_models.UriColor"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/enum/green%20color') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters['enumQuery'] = _SERIALIZER.query("enum_query", enum_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_enum_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: null string value. + :paramtype enum_query: str or ~urllowlevel.models.UriColor + :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 + """ + + enum_query = kwargs.pop('enum_query', None) # type: Optional[Union[str, "_models.UriColor"]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/enum/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters['enumQuery'] = _SERIALIZER.query("enum_query", enum_query, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_byte_multi_byte_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :paramtype byte_query: bytearray + :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 + """ + + byte_query = kwargs.pop('byte_query', None) # type: Optional[bytearray] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/byte/multibyte') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters['byteQuery'] = _SERIALIZER.query("byte_query", byte_query, 'bytearray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_byte_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_query = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/byte/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['byteQuery'] = _SERIALIZER.query("byte_query", byte_query, 'bytearray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_byte_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as byte array (no query parameters in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: null as byte array (no query parameters in uri). + :paramtype byte_query: bytearray + :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 + """ + + byte_query = kwargs.pop('byte_query', None) # type: Optional[bytearray] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/byte/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters['byteQuery'] = _SERIALIZER.query("byte_query", byte_query, 'bytearray') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_query = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/date/2012-01-01') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['dateQuery'] = _SERIALIZER.query("date_query", date_query, 'date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date - this should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_query: null as date (no query parameters in uri). + :paramtype date_query: ~datetime.date + :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 + """ + + date_query = kwargs.pop('date_query', None) # type: Optional[datetime.date] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/date/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_query is not None: + query_parameters['dateQuery'] = _SERIALIZER.query("date_query", date_query, 'date') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_query = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/datetime/2012-01-01T01%3A01%3A01Z') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['dateTimeQuery'] = _SERIALIZER.query("date_time_query", date_time_query, 'iso-8601') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_date_time_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get null as date-time, should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_time_query: null as date-time (no query parameters). + :paramtype date_time_query: ~datetime.datetime + :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 + """ + + date_time_query = kwargs.pop('date_time_query', None) # type: Optional[datetime.datetime] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/datetime/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_time_query is not None: + query_parameters['dateTimeQuery'] = _SERIALIZER.query("date_time_query", date_time_query, 'iso-8601') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_csv_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/csv/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_csv_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/csv/string/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_csv_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array [] of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/csv/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_no_collection_format_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', + 'bonjour'] for the 'arrayQuery' parameter to the service. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/none/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_ssv_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + ssv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the ssv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/ssv/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=' ') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_tsv_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + tsv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the tsv-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/tsv/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div=' ') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_pipes_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + pipes-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the pipes-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/pipes/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = _SERIALIZER.query("array_query", array_query, '[str]', div='|') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/_request_builders_py3.py new file mode 100644 index 00000000000..9740a8523f9 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlLowLevel/urllowlevel/rest/queries/_request_builders_py3.py @@ -0,0 +1,1050 @@ +# 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 datetime +from typing import Any, List, Optional, Union + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_boolean_true_request(**kwargs: Any) -> HttpRequest: + """Get true Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = True + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/bool/true") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["boolQuery"] = _SERIALIZER.query("bool_query", bool_query, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_boolean_false_request(**kwargs: Any) -> HttpRequest: + """Get false Boolean value on path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + bool_query = False + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/bool/false") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["boolQuery"] = _SERIALIZER.query("bool_query", bool_query, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_boolean_null_request(*, bool_query: Optional[bool] = None, **kwargs: Any) -> HttpRequest: + """Get null Boolean value on query (query string should be absent). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword bool_query: null boolean value. + :paramtype bool_query: bool + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/bool/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if bool_query is not None: + query_parameters["boolQuery"] = _SERIALIZER.query("bool_query", bool_query, "bool") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_int_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = 1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/int/1000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["intQuery"] = _SERIALIZER.query("int_query", int_query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_int_negative_one_million_request(**kwargs: Any) -> HttpRequest: + """Get '-1000000' integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + int_query = -1000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/int/-1000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["intQuery"] = _SERIALIZER.query("int_query", int_query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_int_null_request(*, int_query: Optional[int] = None, **kwargs: Any) -> HttpRequest: + """Get null integer value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword int_query: null integer value. + :paramtype int_query: int + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/int/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if int_query is not None: + query_parameters["intQuery"] = _SERIALIZER.query("int_query", int_query, "int") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = 10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/long/10000000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["longQuery"] = _SERIALIZER.query("long_query", long_query, "long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_negative_ten_billion_request(**kwargs: Any) -> HttpRequest: + """Get '-10000000000' 64 bit integer value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + long_query = -10000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/long/-10000000000") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["longQuery"] = _SERIALIZER.query("long_query", long_query, "long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_long_null_request(*, long_query: Optional[int] = None, **kwargs: Any) -> HttpRequest: + """Get 'null 64 bit integer value (no query param in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword long_query: null 64 bit integer value. + :paramtype long_query: long + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/long/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if long_query is not None: + query_parameters["longQuery"] = _SERIALIZER.query("long_query", long_query, "long") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_float_scientific_positive_request(**kwargs: Any) -> HttpRequest: + """Get '1.034E+20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = 103400000000000000000 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/float/1.034E+20") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["floatQuery"] = _SERIALIZER.query("float_query", float_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_float_scientific_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-1.034E-20' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + float_query = -1.034e-20 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/float/-1.034E-20") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["floatQuery"] = _SERIALIZER.query("float_query", float_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_float_null_request(*, float_query: Optional[float] = None, **kwargs: Any) -> HttpRequest: + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword float_query: null numeric value. + :paramtype float_query: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/float/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if float_query is not None: + query_parameters["floatQuery"] = _SERIALIZER.query("float_query", float_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_double_decimal_positive_request(**kwargs: Any) -> HttpRequest: + """Get '9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = 9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/double/9999999.999") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["doubleQuery"] = _SERIALIZER.query("double_query", double_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_double_decimal_negative_request(**kwargs: Any) -> HttpRequest: + """Get '-9999999.999' numeric value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + double_query = -9999999.999 + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/double/-9999999.999") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["doubleQuery"] = _SERIALIZER.query("double_query", double_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_double_null_request(*, double_query: Optional[float] = None, **kwargs: Any) -> HttpRequest: + """Get null numeric value (no query parameter). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword double_query: null numeric value. + :paramtype double_query: float + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/double/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if double_query is not None: + query_parameters["doubleQuery"] = _SERIALIZER.query("double_query", double_query, "float") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_unicode_request(**kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "啊齄丂狛狜隣郎隣兀﨩" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/string/unicode/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_url_encoded_request(**kwargs: Any) -> HttpRequest: + """Get 'begin!*'();:@ &=+$,/?#[]end. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "begin!*'();:@ &=+$,/?#[]end" + accept = "application/json" + # Construct URL + url = kwargs.pop( + "template_url", "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend" + ) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_empty_request(**kwargs: Any) -> HttpRequest: + """Get ''. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + string_query = "" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_string_null_request(*, string_query: Optional[str] = None, **kwargs: Any) -> HttpRequest: + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword string_query: null string value. + :paramtype string_query: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/string/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if string_query is not None: + query_parameters["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_enum_valid_request( + *, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any +) -> HttpRequest: + """Get using uri with query parameter 'green color'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: 'green color' enum value. + :paramtype enum_query: str or ~urllowlevel.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/enum/green%20color") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters["enumQuery"] = _SERIALIZER.query("enum_query", enum_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_enum_null_request( + *, enum_query: Optional[Union[str, "_models.UriColor"]] = None, **kwargs: Any +) -> HttpRequest: + """Get null (no query parameter in url). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword enum_query: null string value. + :paramtype enum_query: str or ~urllowlevel.models.UriColor + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/enum/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if enum_query is not None: + query_parameters["enumQuery"] = _SERIALIZER.query("enum_query", enum_query, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_byte_multi_byte_request(*, byte_query: Optional[bytearray] = None, **kwargs: Any) -> HttpRequest: + """Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array. + :paramtype byte_query: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/byte/multibyte") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters["byteQuery"] = _SERIALIZER.query("byte_query", byte_query, "bytearray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_byte_empty_request(**kwargs: Any) -> HttpRequest: + """Get '' as byte array. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + byte_query = bytearray("", encoding="utf-8") + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/byte/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["byteQuery"] = _SERIALIZER.query("byte_query", byte_query, "bytearray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_byte_null_request(*, byte_query: Optional[bytearray] = None, **kwargs: Any) -> HttpRequest: + """Get null as byte array (no query parameters in uri). + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword byte_query: null as byte array (no query parameters in uri). + :paramtype byte_query: bytearray + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/byte/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if byte_query is not None: + query_parameters["byteQuery"] = _SERIALIZER.query("byte_query", byte_query, "bytearray") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01' as date. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_query = "2012-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/date/2012-01-01") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["dateQuery"] = _SERIALIZER.query("date_query", date_query, "date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_null_request(*, date_query: Optional[datetime.date] = None, **kwargs: Any) -> HttpRequest: + """Get null as date - this should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_query: null as date (no query parameters in uri). + :paramtype date_query: ~datetime.date + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/date/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_query is not None: + query_parameters["dateQuery"] = _SERIALIZER.query("date_query", date_query, "date") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_time_valid_request(**kwargs: Any) -> HttpRequest: + """Get '2012-01-01T01:01:01Z' as date-time. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + date_time_query = "2012-01-01T01:01:01Z" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/datetime/2012-01-01T01%3A01%3A01Z") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["dateTimeQuery"] = _SERIALIZER.query("date_time_query", date_time_query, "iso-8601") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_date_time_null_request(*, date_time_query: Optional[datetime.datetime] = None, **kwargs: Any) -> HttpRequest: + """Get null as date-time, should result in no query parameters in uri. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword date_time_query: null as date-time (no query parameters). + :paramtype date_time_query: ~datetime.datetime + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/datetime/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if date_time_query is not None: + query_parameters["dateTimeQuery"] = _SERIALIZER.query("date_time_query", date_time_query, "iso-8601") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_csv_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/csv/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_csv_null_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get a null array of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/csv/string/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_csv_empty_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an empty array [] of string using the csv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the csv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/csv/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_no_collection_format_empty_request( + *, array_query: Optional[List[str]] = None, **kwargs: Any +) -> HttpRequest: + """Array query has no defined collection format, should default to csv. Pass in ['hello', 'nihao', + 'bonjour'] for the 'arrayQuery' parameter to the service. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: Array-typed query parameter. Pass in ['hello', 'nihao', 'bonjour']. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/none/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=",") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_ssv_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + ssv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the ssv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/ssv/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=" ") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_tsv_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + tsv-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the tsv-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/tsv/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div=" ") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_pipes_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + pipes-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the pipes-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/pipes/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = _SERIALIZER.query("array_query", array_query, "[str]", div="|") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/setup.py new file mode 100644 index 00000000000..915d4facbe0 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/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 = "autoresturlmutlicollectionformattestservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestUrlMutliCollectionFormatTestService", + author_email="", + url="", + keywords=["Swagger", "AutoRestUrlMutliCollectionFormatTestService"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/__init__.py new file mode 100644 index 00000000000..a41cc69c59f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/__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 ._auto_rest_url_mutli_collection_format_test_service import AutoRestUrlMutliCollectionFormatTestService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestUrlMutliCollectionFormatTestService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_auto_rest_url_mutli_collection_format_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_auto_rest_url_mutli_collection_format_test_service.py new file mode 100644 index 00000000000..6bd455e3a50 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_auto_rest_url_mutli_collection_format_test_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestUrlMutliCollectionFormatTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestUrlMutliCollectionFormatTestService(object): + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlMutliCollectionFormatTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `urlmulticollectionformatlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from urlmulticollectionformatlowlevel.rest import queries + >>> request = queries.build_array_string_multi_null_request(array_query=array_query, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestUrlMutliCollectionFormatTestService + 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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_configuration.py new file mode 100644 index 00000000000..3ea2f6ac0ac --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_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 AutoRestUrlMutliCollectionFormatTestServiceConfiguration(Configuration): + """Configuration for AutoRestUrlMutliCollectionFormatTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestUrlMutliCollectionFormatTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autoresturlmutlicollectionformattestservice/{}".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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/_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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/__init__.py new file mode 100644 index 00000000000..0b179356efb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/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 ._auto_rest_url_mutli_collection_format_test_service import AutoRestUrlMutliCollectionFormatTestService + +__all__ = ["AutoRestUrlMutliCollectionFormatTestService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/_auto_rest_url_mutli_collection_format_test_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/_auto_rest_url_mutli_collection_format_test_service.py new file mode 100644 index 00000000000..70100a667fa --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/_auto_rest_url_mutli_collection_format_test_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestUrlMutliCollectionFormatTestServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestUrlMutliCollectionFormatTestService: + """Test Infrastructure for AutoRest. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestUrlMutliCollectionFormatTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `urlmulticollectionformatlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from urlmulticollectionformatlowlevel.rest import queries + >>> request = queries.build_array_string_multi_null_request(array_query=array_query, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestUrlMutliCollectionFormatTestService": + 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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..30b9cb9fe74 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/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 AutoRestUrlMutliCollectionFormatTestServiceConfiguration(Configuration): + """Configuration for AutoRestUrlMutliCollectionFormatTestService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestUrlMutliCollectionFormatTestServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autoresturlmutlicollectionformattestservice/{}".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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/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/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/__init__.py new file mode 100644 index 00000000000..deed18c33fd --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/__init__.py @@ -0,0 +1,22 @@ +# 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_array_string_multi_null_request + from ._request_builders_py3 import build_array_string_multi_empty_request + from ._request_builders_py3 import build_array_string_multi_valid_request +except (SyntaxError, ImportError): + from ._request_builders import build_array_string_multi_null_request # type: ignore + from ._request_builders import build_array_string_multi_empty_request # type: ignore + from ._request_builders import build_array_string_multi_valid_request # type: ignore + +__all__ = [ + "build_array_string_multi_null_request", + "build_array_string_multi_empty_request", + "build_array_string_multi_valid_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/_request_builders.py new file mode 100644 index 00000000000..c353b6fa18d --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/_request_builders.py @@ -0,0 +1,143 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_array_string_multi_null_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a null array of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/multi/string/null') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = [_SERIALIZER.query("array_query", q, 'str') if q is not None else '' for q in array_query] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_multi_empty_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty array [] of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/multi/string/empty') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = [_SERIALIZER.query("array_query", q, 'str') if q is not None else '' for q in array_query] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_array_string_multi_valid_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + mult-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the mult-array format. + :paramtype array_query: list[str] + :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 + """ + + array_query = kwargs.pop('array_query', None) # type: Optional[List[str]] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/queries/array/multi/string/valid') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters['arrayQuery'] = [_SERIALIZER.query("array_query", q, 'str') if q is not None else '' for q in array_query] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/_request_builders_py3.py new file mode 100644 index 00000000000..6a7aba129ec --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel/urlmulticollectionformatlowlevel/rest/queries/_request_builders_py3.py @@ -0,0 +1,111 @@ +# 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, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_array_string_multi_null_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get a null array of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: a null array of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/multi/string/null") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = [ + _SERIALIZER.query("array_query", q, "str") if q is not None else "" for q in array_query + ] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_multi_empty_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an empty array [] of string using the multi-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an empty array [] of string using the multi-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/multi/string/empty") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = [ + _SERIALIZER.query("array_query", q, "str") if q is not None else "" for q in array_query + ] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_array_string_multi_valid_request(*, array_query: Optional[List[str]] = None, **kwargs: Any) -> HttpRequest: + """Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the + mult-array format. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword array_query: an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, + ''] using the mult-array format. + :paramtype array_query: list[str] + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/queries/array/multi/string/valid") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if array_query is not None: + query_parameters["arrayQuery"] = [ + _SERIALIZER.query("array_query", q, "str") if q is not None else "" for q in array_query + ] + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/setup.py new file mode 100644 index 00000000000..f909ccf3776 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/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 = "autorestvalidationtest" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestValidationTest", + author_email="", + url="", + keywords=["Swagger", "AutoRestValidationTest"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest. No server backend exists for these tests. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/__init__.py new file mode 100644 index 00000000000..1c0b912c18f --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/__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 ._auto_rest_validation_test import AutoRestValidationTest +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestValidationTest"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_auto_rest_validation_test.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_auto_rest_validation_test.py new file mode 100644 index 00000000000..03c5a7951a7 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_auto_rest_validation_test.py @@ -0,0 +1,94 @@ +# 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 AutoRestValidationTestConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestValidationTest(object): + """Test Infrastructure for AutoRest. No server backend exists for these tests. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestValidationTestConfiguration(subscription_id, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `validationlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from validationlowlevel.rest import build_validation_of_method_parameters_request + >>> request = build_validation_of_method_parameters_request(subscription_id, resource_group_name, id, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestValidationTest + 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/ValidationLowLevel/validationlowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_configuration.py new file mode 100644 index 00000000000..a62c4abd7d4 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_configuration.py @@ -0,0 +1,58 @@ +# 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 AutoRestValidationTestConfiguration(Configuration): + """Configuration for AutoRestValidationTest. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: Subscription ID. + :type subscription_id: str + """ + + def __init__( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(AutoRestValidationTestConfiguration, self).__init__(**kwargs) + + self.subscription_id = subscription_id + self.api_version = "1.0.0" + kwargs.setdefault("sdk_moniker", "autorestvalidationtest/{}".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/ValidationLowLevel/validationlowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/_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/ValidationLowLevel/validationlowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/aio/__init__.py new file mode 100644 index 00000000000..c0421d927ac --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/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 ._auto_rest_validation_test import AutoRestValidationTest + +__all__ = ["AutoRestValidationTest"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/aio/_auto_rest_validation_test.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/aio/_auto_rest_validation_test.py new file mode 100644 index 00000000000..f206b576c35 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/aio/_auto_rest_validation_test.py @@ -0,0 +1,79 @@ +# 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 AutoRestValidationTestConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestValidationTest: + """Test Infrastructure for AutoRest. No server backend exists for these tests. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, subscription_id: str, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestValidationTestConfiguration(subscription_id, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `validationlowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from validationlowlevel.rest import build_validation_of_method_parameters_request + >>> request = build_validation_of_method_parameters_request(subscription_id, resource_group_name, id, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestValidationTest": + 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/ValidationLowLevel/validationlowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/aio/_configuration.py new file mode 100644 index 00000000000..f25620da528 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/aio/_configuration.py @@ -0,0 +1,46 @@ +# 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 AutoRestValidationTestConfiguration(Configuration): + """Configuration for AutoRestValidationTest. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: Subscription ID. + :type subscription_id: str + """ + + def __init__(self, subscription_id: str, **kwargs: Any) -> None: + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(AutoRestValidationTestConfiguration, self).__init__(**kwargs) + + self.subscription_id = subscription_id + self.api_version = "1.0.0" + kwargs.setdefault("sdk_moniker", "autorestvalidationtest/{}".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/ValidationLowLevel/validationlowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/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/ValidationLowLevel/validationlowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/__init__.py new file mode 100644 index 00000000000..3d6cfc6b060 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/__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 ._request_builders_py3 import build_validation_of_method_parameters_request + from ._request_builders_py3 import build_validation_of_body_request + from ._request_builders_py3 import build_get_with_constant_in_path_request + from ._request_builders_py3 import build_post_with_constant_in_body_request +except (SyntaxError, ImportError): + from ._request_builders import build_validation_of_method_parameters_request # type: ignore + from ._request_builders import build_validation_of_body_request # type: ignore + from ._request_builders import build_get_with_constant_in_path_request # type: ignore + from ._request_builders import build_post_with_constant_in_body_request # type: ignore + +__all__ = [ + "build_validation_of_method_parameters_request", + "build_validation_of_body_request", + "build_get_with_constant_in_path_request", + "build_post_with_constant_in_body_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/_request_builders.py new file mode 100644 index 00000000000..dbb78a4a878 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/_request_builders.py @@ -0,0 +1,318 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_validation_of_method_parameters_request( + subscription_id, # type: str + resource_group_name, # type: str + id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Validates input parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :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 + + # response body for status code(s): 200 + response.json() == { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/fakepath/{subscriptionId}/{resourceGroupName}/{id}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9\']+'), + 'id': _SERIALIZER.url("id", id, 'int', maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['apiVersion'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validation_of_body_request( + subscription_id, # type: str + resource_group_name, # type: str + id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Validates body parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/fakepath/{subscriptionId}/{resourceGroupName}/{id}') + path_format_arguments = { + 'subscriptionId': _SERIALIZER.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'), + 'id': _SERIALIZER.url("id", id, 'int', maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['apiVersion'] = _SERIALIZER.query("api_version", api_version, 'str') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_with_constant_in_path_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """get_with_constant_in_path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + constant_param = "constant" + # Construct URL + url = kwargs.pop("template_url", '/validation/constantsInPath/{constantParam}/value') + path_format_arguments = { + 'constantParam': _SERIALIZER.url("constant_param", constant_param, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_post_with_constant_in_body_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """post_with_constant_in_body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + constant_param = "constant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/validation/constantsInPath/{constantParam}/value') + path_format_arguments = { + 'constantParam': _SERIALIZER.url("constant_param", constant_param, 'str'), + } + 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/_request_builders_py3.py new file mode 100644 index 00000000000..a219eaf9ee8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/ValidationLowLevel/validationlowlevel/rest/_request_builders_py3.py @@ -0,0 +1,284 @@ +# 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, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_validation_of_method_parameters_request( + subscription_id: str, resource_group_name: str, id: int, **kwargs: Any +) -> HttpRequest: + """Validates input parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :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 + + # response body for status code(s): 200 + response.json() == { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + """ + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/fakepath/{subscriptionId}/{resourceGroupName}/{id}") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=10, min_length=3, pattern=r"[a-zA-Z0-9\']+" + ), + "id": _SERIALIZER.url("id", id, "int", maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["apiVersion"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_validation_of_body_request( + subscription_id: str, resource_group_name: str, id: int, *, json: Any = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Validates body parameters on the method. See swagger for details. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. + :type resource_group_name: str + :param id: Required int multiple of 10 from 100 to 1000. + :type id: int + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + api_version = "1.0.0" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/fakepath/{subscriptionId}/{resourceGroupName}/{id}") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=10, min_length=3, pattern=r"[a-zA-Z0-9]+" + ), + "id": _SERIALIZER.url("id", id, "int", maximum=1000, minimum=100, multiple=10), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["apiVersion"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=url, params=query_parameters, headers=header_parameters, json=json, content=content, **kwargs + ) + + +def build_get_with_constant_in_path_request(**kwargs: Any) -> HttpRequest: + """get_with_constant_in_path. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + constant_param = "constant" + # Construct URL + url = kwargs.pop("template_url", "/validation/constantsInPath/{constantParam}/value") + path_format_arguments = { + "constantParam": _SERIALIZER.url("constant_param", constant_param, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_post_with_constant_in_body_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """post_with_constant_in_body. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "capacity": "int (optional)", + "child": { + "constProperty": "str", + "count": "int (optional)" + }, + "constChild": { + "constProperty": "str", + "constProperty2": "str" + }, + "constInt": "int", + "constString": "str", + "constStringAsEnum": "str (optional)", + "display_names": [ + "str (optional)" + ], + "image": "str (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + constant_param = "constant" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/validation/constantsInPath/{constantParam}/value") + path_format_arguments = { + "constantParam": _SERIALIZER.url("constant_param", constant_param, "str"), + } + 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, json=json, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/setup.py new file mode 100644 index 00000000000..f66bb3ada67 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/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 = "autorestswaggerbatxmlservice" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestSwaggerBATXMLService", + author_email="", + url="", + keywords=["Swagger", "AutoRestSwaggerBATXMLService"], + 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/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/__init__.py new file mode 100644 index 00000000000..fc6f96c6d5e --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/__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 ._auto_rest_swagger_batxml_service import AutoRestSwaggerBATXMLService +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AutoRestSwaggerBATXMLService"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_auto_rest_swagger_batxml_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_auto_rest_swagger_batxml_service.py new file mode 100644 index 00000000000..e2d2f94cdf6 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_auto_rest_swagger_batxml_service.py @@ -0,0 +1,91 @@ +# 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 AutoRestSwaggerBATXMLServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class AutoRestSwaggerBATXMLService(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATXMLServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `xmlservicelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmlservicelowlevel.rest import xml + >>> request = xml.build_get_complex_type_ref_no_meta_request(**kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> AutoRestSwaggerBATXMLService + 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/XmlLowLevel/xmlservicelowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_configuration.py new file mode 100644 index 00000000000..d8887a241fe --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_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 AutoRestSwaggerBATXMLServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATXMLService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AutoRestSwaggerBATXMLServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatxmlservice/{}".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/XmlLowLevel/xmlservicelowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/_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/XmlLowLevel/xmlservicelowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/aio/__init__.py new file mode 100644 index 00000000000..d68d5c97caf --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/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 ._auto_rest_swagger_batxml_service import AutoRestSwaggerBATXMLService + +__all__ = ["AutoRestSwaggerBATXMLService"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/aio/_auto_rest_swagger_batxml_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/aio/_auto_rest_swagger_batxml_service.py new file mode 100644 index 00000000000..1d59aa017f5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/aio/_auto_rest_swagger_batxml_service.py @@ -0,0 +1,77 @@ +# 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 AutoRestSwaggerBATXMLServiceConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class AutoRestSwaggerBATXMLService: + """Test Infrastructure for AutoRest Swagger BAT. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AutoRestSwaggerBATXMLServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `xmlservicelowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmlservicelowlevel.rest import xml + >>> request = xml.build_get_complex_type_ref_no_meta_request(**kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "AutoRestSwaggerBATXMLService": + 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/XmlLowLevel/xmlservicelowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/aio/_configuration.py new file mode 100644 index 00000000000..8cd31cae2e5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/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 AutoRestSwaggerBATXMLServiceConfiguration(Configuration): + """Configuration for AutoRestSwaggerBATXMLService. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AutoRestSwaggerBATXMLServiceConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "autorestswaggerbatxmlservice/{}".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/XmlLowLevel/xmlservicelowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/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/XmlLowLevel/xmlservicelowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/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/XmlLowLevel/xmlservicelowlevel/rest/xml/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/__init__.py new file mode 100644 index 00000000000..b64de561abc --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/__init__.py @@ -0,0 +1,115 @@ +# 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_get_complex_type_ref_no_meta_request + from ._request_builders_py3 import build_put_complex_type_ref_no_meta_request + from ._request_builders_py3 import build_get_complex_type_ref_with_meta_request + from ._request_builders_py3 import build_put_complex_type_ref_with_meta_request + from ._request_builders_py3 import build_get_simple_request + from ._request_builders_py3 import build_put_simple_request + from ._request_builders_py3 import build_get_wrapped_lists_request + from ._request_builders_py3 import build_put_wrapped_lists_request + from ._request_builders_py3 import build_get_headers_request + from ._request_builders_py3 import build_get_empty_list_request + from ._request_builders_py3 import build_put_empty_list_request + from ._request_builders_py3 import build_get_empty_wrapped_lists_request + from ._request_builders_py3 import build_put_empty_wrapped_lists_request + from ._request_builders_py3 import build_get_root_list_request + from ._request_builders_py3 import build_put_root_list_request + from ._request_builders_py3 import build_get_root_list_single_item_request + from ._request_builders_py3 import build_put_root_list_single_item_request + from ._request_builders_py3 import build_get_empty_root_list_request + from ._request_builders_py3 import build_put_empty_root_list_request + from ._request_builders_py3 import build_get_empty_child_element_request + from ._request_builders_py3 import build_put_empty_child_element_request + from ._request_builders_py3 import build_list_containers_request + from ._request_builders_py3 import build_get_service_properties_request + from ._request_builders_py3 import build_put_service_properties_request + from ._request_builders_py3 import build_get_acls_request + from ._request_builders_py3 import build_put_acls_request + from ._request_builders_py3 import build_list_blobs_request + from ._request_builders_py3 import build_json_input_request + from ._request_builders_py3 import build_json_output_request + from ._request_builders_py3 import build_get_xms_text_request + from ._request_builders_py3 import build_get_bytes_request + from ._request_builders_py3 import build_put_binary_request + from ._request_builders_py3 import build_get_uri_request + from ._request_builders_py3 import build_put_uri_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_complex_type_ref_no_meta_request # type: ignore + from ._request_builders import build_put_complex_type_ref_no_meta_request # type: ignore + from ._request_builders import build_get_complex_type_ref_with_meta_request # type: ignore + from ._request_builders import build_put_complex_type_ref_with_meta_request # type: ignore + from ._request_builders import build_get_simple_request # type: ignore + from ._request_builders import build_put_simple_request # type: ignore + from ._request_builders import build_get_wrapped_lists_request # type: ignore + from ._request_builders import build_put_wrapped_lists_request # type: ignore + from ._request_builders import build_get_headers_request # type: ignore + from ._request_builders import build_get_empty_list_request # type: ignore + from ._request_builders import build_put_empty_list_request # type: ignore + from ._request_builders import build_get_empty_wrapped_lists_request # type: ignore + from ._request_builders import build_put_empty_wrapped_lists_request # type: ignore + from ._request_builders import build_get_root_list_request # type: ignore + from ._request_builders import build_put_root_list_request # type: ignore + from ._request_builders import build_get_root_list_single_item_request # type: ignore + from ._request_builders import build_put_root_list_single_item_request # type: ignore + from ._request_builders import build_get_empty_root_list_request # type: ignore + from ._request_builders import build_put_empty_root_list_request # type: ignore + from ._request_builders import build_get_empty_child_element_request # type: ignore + from ._request_builders import build_put_empty_child_element_request # type: ignore + from ._request_builders import build_list_containers_request # type: ignore + from ._request_builders import build_get_service_properties_request # type: ignore + from ._request_builders import build_put_service_properties_request # type: ignore + from ._request_builders import build_get_acls_request # type: ignore + from ._request_builders import build_put_acls_request # type: ignore + from ._request_builders import build_list_blobs_request # type: ignore + from ._request_builders import build_json_input_request # type: ignore + from ._request_builders import build_json_output_request # type: ignore + from ._request_builders import build_get_xms_text_request # type: ignore + from ._request_builders import build_get_bytes_request # type: ignore + from ._request_builders import build_put_binary_request # type: ignore + from ._request_builders import build_get_uri_request # type: ignore + from ._request_builders import build_put_uri_request # type: ignore + +__all__ = [ + "build_get_complex_type_ref_no_meta_request", + "build_put_complex_type_ref_no_meta_request", + "build_get_complex_type_ref_with_meta_request", + "build_put_complex_type_ref_with_meta_request", + "build_get_simple_request", + "build_put_simple_request", + "build_get_wrapped_lists_request", + "build_put_wrapped_lists_request", + "build_get_headers_request", + "build_get_empty_list_request", + "build_put_empty_list_request", + "build_get_empty_wrapped_lists_request", + "build_put_empty_wrapped_lists_request", + "build_get_root_list_request", + "build_put_root_list_request", + "build_get_root_list_single_item_request", + "build_put_root_list_single_item_request", + "build_get_empty_root_list_request", + "build_put_empty_root_list_request", + "build_get_empty_child_element_request", + "build_put_empty_child_element_request", + "build_list_containers_request", + "build_get_service_properties_request", + "build_put_service_properties_request", + "build_get_acls_request", + "build_put_acls_request", + "build_list_blobs_request", + "build_json_input_request", + "build_json_output_request", + "build_get_xms_text_request", + "build_get_bytes_request", + "build_put_binary_request", + "build_get_uri_request", + "build_put_uri_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/_request_builders.py new file mode 100644 index 00000000000..9d546342ef3 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/_request_builders.py @@ -0,0 +1,1526 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, List, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_complex_type_ref_no_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "RefToModel": { + "ID": "str (optional)" + }, + "Something": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-no-meta') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_type_ref_no_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-no-meta') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_complex_type_ref_with_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "RefToModel": { + "ID": "str (optional)" + }, + "Something": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-with-meta') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_complex_type_ref_with_meta_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/complex-type-ref-with-meta') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_simple_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "author": "str (optional)", + "date": "str (optional)", + "slides": [ + { + "items": [ + "str (optional)" + ], + "title": "str (optional)", + "type": "str (optional)" + } + ], + "title": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/simple') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_simple_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/simple') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "BadApples": [ + "str (optional)" + ], + "GoodApples": [ + "str (optional)" + ] + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/wrapped-lists') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/wrapped-lists') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_headers_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get strongly-typed response headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", '/xml/headers') + + return HttpRequest( + method="GET", + url=url, + **kwargs + ) + + +def build_get_empty_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "author": "str (optional)", + "date": "str (optional)", + "slides": [ + { + "items": [ + "str (optional)" + ], + "title": "str (optional)", + "type": "str (optional)" + } + ], + "title": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-list') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "BadApples": [ + "str (optional)" + ], + "GoodApples": [ + "str (optional)" + ] + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-wrapped-lists') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_wrapped_lists_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-wrapped-lists') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + ] + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_root_list_single_item_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + ] + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list-single-item') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_root_list_single_item_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/root-list-single-item') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + ] + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-root-list') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_root_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-root-list') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_empty_child_element_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets an XML document with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-child-element') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_empty_child_element_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts a value with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/empty-child-element') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_list_containers_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists containers in a storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Containers": [ + { + "Metadata": { + "str": "str (optional)" + }, + "Name": "str", + "Properties": { + "Etag": "str", + "Last-Modified": "datetime", + "LeaseDuration": "str (optional)", + "LeaseState": "str (optional)", + "LeaseStatus": "str (optional)", + "PublicAccess": "str (optional)" + } + } + ], + "Marker": "str (optional)", + "MaxResults": "int", + "NextMarker": "str", + "Prefix": "str", + "ServiceEndpoint": "str" + } + """ + + comp = "list" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_service_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Cors": [ + { + "AllowedHeaders": "str", + "AllowedMethods": "str", + "AllowedOrigins": "str", + "ExposedHeaders": "str", + "MaxAgeInSeconds": "int" + } + ], + "DefaultServiceVersion": "str (optional)", + "DeleteRetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "HourMetrics": { + "Enabled": "bool", + "IncludeAPIs": "bool (optional)", + "RetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "Version": "str (optional)" + }, + "Logging": { + "Delete": "bool", + "Read": "bool", + "RetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "Version": "str", + "Write": "bool" + }, + "MinuteMetrics": { + "Enabled": "bool", + "IncludeAPIs": "bool (optional)", + "RetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "Version": "str (optional)" + } + } + """ + + comp = "properties" + restype = "service" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_service_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + comp = "properties" + restype = "service" + # Construct URL + url = kwargs.pop("template_url", '/xml/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # 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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_acls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "AccessPolicy": { + "Expiry": "datetime", + "Permission": "str", + "Start": "datetime" + }, + "Id": "str" + } + ] + """ + + comp = "acl" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/mycontainer') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_acls_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Puts storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + comp = "acl" + restype = "container" + # Construct URL + url = kwargs.pop("template_url", '/xml/mycontainer') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # 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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_blobs_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Lists blobs in a storage container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Blobs": { + "Blob": [ + { + "Deleted": "bool", + "Metadata": { + "str": "str (optional)" + }, + "Name": "str", + "Properties": { + "AccessTier": "str (optional)", + "AccessTierInferred": "bool (optional)", + "ArchiveStatus": "str (optional)", + "BlobType": "str (optional)", + "Cache-Control": "str (optional)", + "Content-Disposition": "str (optional)", + "Content-Encoding": "str (optional)", + "Content-Language": "str (optional)", + "Content-Length": "long (optional)", + "Content-MD5": "str (optional)", + "Content-Type": "str (optional)", + "CopyCompletionTime": "datetime (optional)", + "CopyId": "str (optional)", + "CopyProgress": "str (optional)", + "CopySource": "str (optional)", + "CopyStatus": "str (optional)", + "CopyStatusDescription": "str (optional)", + "DeletedTime": "datetime (optional)", + "DestinationSnapshot": "str (optional)", + "Etag": "str", + "IncrementalCopy": "bool (optional)", + "Last-Modified": "datetime", + "LeaseDuration": "str (optional)", + "LeaseState": "str (optional)", + "LeaseStatus": "str (optional)", + "RemainingRetentionDays": "int (optional)", + "ServerEncrypted": "bool (optional)", + "x-ms-blob-sequence-number": "int (optional)" + }, + "Snapshot": "str" + } + ], + "BlobPrefix": [ + { + "Name": "str" + } + ] + }, + "ContainerName": "str", + "Delimiter": "str", + "Marker": "str", + "MaxResults": "int", + "NextMarker": "str", + "Prefix": "str", + "ServiceEndpoint": "str (optional)" + } + """ + + comp = "list" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/mycontainer') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['comp'] = _SERIALIZER.query("comp", comp, 'str') + query_parameters['restype'] = _SERIALIZER.query("restype", restype, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_json_input_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID + number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "int (optional)" + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/xml/jsoninput') + + # 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="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_json_output_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """A Swagger with XML that has one operation that returns JSON. ID number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "id": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/xml/jsonoutput') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_xms_text_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get back an XML object with an x-ms-text property, which should translate to the returned + object's 'language' property being 'english' and its 'content' property being 'I am text'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "content": "str (optional)", + "language": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/x-ms-text') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_bytes_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Bytes": "bytearray (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/bytes') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_binary_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/bytes') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_get_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Get an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Url": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/url') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_put_uri_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Put an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", '/xml/url') + + # 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') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/_request_builders_py3.py new file mode 100644 index 00000000000..4df051b07ed --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmlLowLevel/xmlservicelowlevel/rest/xml/_request_builders_py3.py @@ -0,0 +1,1248 @@ +# 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, List, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_complex_type_ref_no_meta_request(**kwargs: Any) -> HttpRequest: + """Get a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "RefToModel": { + "ID": "str (optional)" + }, + "Something": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-no-meta") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_type_ref_no_meta_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a complex type that has a ref to a complex type with no XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-no-meta") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_complex_type_ref_with_meta_request(**kwargs: Any) -> HttpRequest: + """Get a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "RefToModel": { + "ID": "str (optional)" + }, + "Something": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-with-meta") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_complex_type_ref_with_meta_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a complex type that has a ref to a complex type with XML node. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/complex-type-ref-with-meta") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_simple_request(**kwargs: Any) -> HttpRequest: + """Get a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "author": "str (optional)", + "date": "str (optional)", + "slides": [ + { + "items": [ + "str (optional)" + ], + "title": "str (optional)", + "type": "str (optional)" + } + ], + "title": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/simple") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_simple_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put a simple XML document. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/simple") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_wrapped_lists_request(**kwargs: Any) -> HttpRequest: + """Get an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "BadApples": [ + "str (optional)" + ], + "GoodApples": [ + "str (optional)" + ] + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/wrapped-lists") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_wrapped_lists_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put an XML document with multiple wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/wrapped-lists") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_headers_request(**kwargs: Any) -> HttpRequest: + """Get strongly-typed response headers. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + """ + + # Construct URL + url = kwargs.pop("template_url", "/xml/headers") + + return HttpRequest(method="GET", url=url, **kwargs) + + +def build_get_empty_list_request(**kwargs: Any) -> HttpRequest: + """Get an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "author": "str (optional)", + "date": "str (optional)", + "slides": [ + { + "items": [ + "str (optional)" + ], + "title": "str (optional)", + "type": "str (optional)" + } + ], + "title": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_list_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts an empty list. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-list") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_empty_wrapped_lists_request(**kwargs: Any) -> HttpRequest: + """Gets some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "BadApples": [ + "str (optional)" + ], + "GoodApples": [ + "str (optional)" + ] + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-wrapped-lists") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_wrapped_lists_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts some empty wrapped lists. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-wrapped-lists") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_root_list_request(**kwargs: Any) -> HttpRequest: + """Gets a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + ] + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_root_list_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_root_list_single_item_request(**kwargs: Any) -> HttpRequest: + """Gets a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + ] + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list-single-item") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_root_list_single_item_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a list with a single item. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/root-list-single-item") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_empty_root_list_request(**kwargs: Any) -> HttpRequest: + """Gets an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + ] + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-root-list") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_root_list_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts an empty list as the root element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-root-list") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_empty_child_element_request(**kwargs: Any) -> HttpRequest: + """Gets an XML document with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "expiration": "datetime (optional)", + "flavor": "str (optional)", + "name": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-child-element") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_empty_child_element_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts a value with an empty child element. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/empty-child-element") + + # 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="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_list_containers_request(**kwargs: Any) -> HttpRequest: + """Lists containers in a storage account. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Containers": [ + { + "Metadata": { + "str": "str (optional)" + }, + "Name": "str", + "Properties": { + "Etag": "str", + "Last-Modified": "datetime", + "LeaseDuration": "str (optional)", + "LeaseState": "str (optional)", + "LeaseStatus": "str (optional)", + "PublicAccess": "str (optional)" + } + } + ], + "Marker": "str (optional)", + "MaxResults": "int", + "NextMarker": "str", + "Prefix": "str", + "ServiceEndpoint": "str" + } + """ + + comp = "list" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_get_service_properties_request(**kwargs: Any) -> HttpRequest: + """Gets storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Cors": [ + { + "AllowedHeaders": "str", + "AllowedMethods": "str", + "AllowedOrigins": "str", + "ExposedHeaders": "str", + "MaxAgeInSeconds": "int" + } + ], + "DefaultServiceVersion": "str (optional)", + "DeleteRetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "HourMetrics": { + "Enabled": "bool", + "IncludeAPIs": "bool (optional)", + "RetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "Version": "str (optional)" + }, + "Logging": { + "Delete": "bool", + "Read": "bool", + "RetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "Version": "str", + "Write": "bool" + }, + "MinuteMetrics": { + "Enabled": "bool", + "IncludeAPIs": "bool (optional)", + "RetentionPolicy": { + "Days": "int (optional)", + "Enabled": "bool" + }, + "Version": "str (optional)" + } + } + """ + + comp = "properties" + restype = "service" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_put_service_properties_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts storage service properties. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + comp = "properties" + restype = "service" + # Construct URL + url = kwargs.pop("template_url", "/xml/") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # 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="PUT", url=url, params=query_parameters, headers=header_parameters, content=content, **kwargs + ) + + +def build_get_acls_request(**kwargs: Any) -> HttpRequest: + """Gets storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == [ + { + "AccessPolicy": { + "Expiry": "datetime", + "Permission": "str", + "Start": "datetime" + }, + "Id": "str" + } + ] + """ + + comp = "acl" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/mycontainer") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_put_acls_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Puts storage ACLs for a container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + comp = "acl" + restype = "container" + # Construct URL + url = kwargs.pop("template_url", "/xml/mycontainer") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # 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="PUT", url=url, params=query_parameters, headers=header_parameters, content=content, **kwargs + ) + + +def build_list_blobs_request(**kwargs: Any) -> HttpRequest: + """Lists blobs in a storage container. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Blobs": { + "Blob": [ + { + "Deleted": "bool", + "Metadata": { + "str": "str (optional)" + }, + "Name": "str", + "Properties": { + "AccessTier": "str (optional)", + "AccessTierInferred": "bool (optional)", + "ArchiveStatus": "str (optional)", + "BlobType": "str (optional)", + "Cache-Control": "str (optional)", + "Content-Disposition": "str (optional)", + "Content-Encoding": "str (optional)", + "Content-Language": "str (optional)", + "Content-Length": "long (optional)", + "Content-MD5": "str (optional)", + "Content-Type": "str (optional)", + "CopyCompletionTime": "datetime (optional)", + "CopyId": "str (optional)", + "CopyProgress": "str (optional)", + "CopySource": "str (optional)", + "CopyStatus": "str (optional)", + "CopyStatusDescription": "str (optional)", + "DeletedTime": "datetime (optional)", + "DestinationSnapshot": "str (optional)", + "Etag": "str", + "IncrementalCopy": "bool (optional)", + "Last-Modified": "datetime", + "LeaseDuration": "str (optional)", + "LeaseState": "str (optional)", + "LeaseStatus": "str (optional)", + "RemainingRetentionDays": "int (optional)", + "ServerEncrypted": "bool (optional)", + "x-ms-blob-sequence-number": "int (optional)" + }, + "Snapshot": "str" + } + ], + "BlobPrefix": [ + { + "Name": "str" + } + ] + }, + "ContainerName": "str", + "Delimiter": "str", + "Marker": "str", + "MaxResults": "int", + "NextMarker": "str", + "Prefix": "str", + "ServiceEndpoint": "str (optional)" + } + """ + + comp = "list" + restype = "container" + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/mycontainer") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters["comp"] = _SERIALIZER.query("comp", comp, "str") + query_parameters["restype"] = _SERIALIZER.query("restype", restype, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, params=query_parameters, headers=header_parameters, **kwargs) + + +def build_json_input_request(*, json: Any = None, content: Any = None, **kwargs: Any) -> HttpRequest: + """A Swagger with XML that has one operation that takes JSON as input. You need to send the ID + number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword json: Pass in a JSON-serializable object (usually a dictionary). See the template in + our example to find the input shape. + :paramtype json: any + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + + # JSON input template you can fill out and use as your `json` input. + json = { + "id": "int (optional)" + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/xml/jsoninput") + + # 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="PUT", url=url, headers=header_parameters, json=json, content=content, **kwargs) + + +def build_json_output_request(**kwargs: Any) -> HttpRequest: + """A Swagger with XML that has one operation that returns JSON. ID number 42. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "id": "int (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/xml/jsonoutput") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_xms_text_request(**kwargs: Any) -> HttpRequest: + """Get back an XML object with an x-ms-text property, which should translate to the returned + object's 'language' property being 'english' and its 'content' property being 'I am text'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "content": "str (optional)", + "language": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/x-ms-text") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_get_bytes_request(**kwargs: Any) -> HttpRequest: + """Get an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Bytes": "bytearray (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/bytes") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_binary_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put an XML document with binary property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/bytes") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) + + +def build_get_uri_request(**kwargs: Any) -> HttpRequest: + """Get an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :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 + + # response body for status code(s): 200 + response.json() == { + "Url": "str (optional)" + } + """ + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/url") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_put_uri_request(*, content: Any, **kwargs: Any) -> HttpRequest: + """Put an XML document with uri property. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). + :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 + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + accept = "application/xml" + # Construct URL + url = kwargs.pop("template_url", "/xml/url") + + # 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") + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=url, headers=header_parameters, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/setup.py new file mode 100644 index 00000000000..be1b940b1a8 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/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 = "xmserrorresponseextensions" +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.16.0"] + +setup( + name=NAME, + version=VERSION, + description="XMSErrorResponseExtensions", + author_email="", + url="", + keywords=["Swagger", "XMSErrorResponseExtensions"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + XMS Error Response Extensions. + """, +) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/__init__.py new file mode 100644 index 00000000000..dbe454fb878 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/__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 ._xms_error_response_extensions import XMSErrorResponseExtensions +from ._version import VERSION + +__version__ = VERSION +__all__ = ["XMSErrorResponseExtensions"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_configuration.py new file mode 100644 index 00000000000..4f88e442feb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_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 XMSErrorResponseExtensionsConfiguration(Configuration): + """Configuration for XMSErrorResponseExtensions. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(XMSErrorResponseExtensionsConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "xmserrorresponseextensions/{}".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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_xms_error_response_extensions.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_xms_error_response_extensions.py new file mode 100644 index 00000000000..e9b03074fec --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/_xms_error_response_extensions.py @@ -0,0 +1,91 @@ +# 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 XMSErrorResponseExtensionsConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class XMSErrorResponseExtensions(object): + """XMS Error Response Extensions. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost" + self._config = XMSErrorResponseExtensionsConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `xmserrorresponselowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmserrorresponselowlevel.rest import pet + >>> request = pet.build_get_pet_by_id_request(pet_id, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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: () -> XMSErrorResponseExtensions + 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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/__init__.py new file mode 100644 index 00000000000..5ce17060db2 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/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 ._xms_error_response_extensions import XMSErrorResponseExtensions + +__all__ = ["XMSErrorResponseExtensions"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/_configuration.py new file mode 100644 index 00000000000..6f7dc1e94db --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/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 XMSErrorResponseExtensionsConfiguration(Configuration): + """Configuration for XMSErrorResponseExtensions. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(XMSErrorResponseExtensionsConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "xmserrorresponseextensions/{}".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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/_xms_error_response_extensions.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/_xms_error_response_extensions.py new file mode 100644 index 00000000000..a1f34c3413c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/aio/_xms_error_response_extensions.py @@ -0,0 +1,77 @@ +# 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 XMSErrorResponseExtensionsConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class XMSErrorResponseExtensions: + """XMS Error Response Extensions. + + :param base_url: Service URL + :type base_url: str + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost" + self._config = XMSErrorResponseExtensionsConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + 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 `xmserrorresponselowlevel.rest`. + Use these helper methods to create the request you pass to this method. See our example below: + + >>> from xmserrorresponselowlevel.rest import pet + >>> request = pet.build_get_pet_by_id_request(pet_id, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :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) -> "XMSErrorResponseExtensions": + 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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/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/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/__init__.py new file mode 100644 index 00000000000..108280ab605 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/__init__.py @@ -0,0 +1,22 @@ +# 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_get_pet_by_id_request + from ._request_builders_py3 import build_do_something_request + from ._request_builders_py3 import build_has_models_param_request +except (SyntaxError, ImportError): + from ._request_builders import build_get_pet_by_id_request # type: ignore + from ._request_builders import build_do_something_request # type: ignore + from ._request_builders import build_has_models_param_request # type: ignore + +__all__ = [ + "build_get_pet_by_id_request", + "build_do_something_request", + "build_has_models_param_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/_request_builders.py new file mode 100644 index 00000000000..0f90d631c73 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/_request_builders.py @@ -0,0 +1,154 @@ +# 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.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_get_pet_by_id_request( + pet_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Gets pets by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: pet id. + :type pet_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/errorStatusCodes/Pets/{petId}/GetPet') + path_format_arguments = { + 'petId': _SERIALIZER.url("pet_id", pet_id, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_do_something_request( + what_action, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Asks pet to do something. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param what_action: what action the pet should do. + :type what_action: str + :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 + + # response body for status code(s): 200 + response.json() == { + "actionResponse": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/errorStatusCodes/Pets/doSomething/{whatAction}') + path_format_arguments = { + 'whatAction': _SERIALIZER.url("what_action", what_action, 'str'), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_has_models_param_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't + conflict with the input param name 'models'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword models: Make sure model deserialization doesn't conflict with this param name, which + has input name 'models'. Use client default value in call. + :paramtype models: str + :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 + """ + + models = kwargs.pop('models', "value1") # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/errorStatusCodes/Pets/hasModelsParam') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if models is not None: + query_parameters['models'] = _SERIALIZER.query("models", models, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/_request_builders_py3.py new file mode 100644 index 00000000000..f4f73b5fe52 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/XmsErrorResponseLowLevel/xmserrorresponselowlevel/rest/pet/_request_builders_py3.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. +# -------------------------------------------------------------------------- +from typing import Any, Optional + +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from msrest import Serializer + +_SERIALIZER = Serializer() + + +def build_get_pet_by_id_request(pet_id: str, **kwargs: Any) -> HttpRequest: + """Gets pets by id. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: pet id. + :type pet_id: str + :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 + + # response body for status code(s): 200 + response.json() == { + "name": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/errorStatusCodes/Pets/{petId}/GetPet") + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=url, headers=header_parameters, **kwargs) + + +def build_do_something_request(what_action: str, **kwargs: Any) -> HttpRequest: + """Asks pet to do something. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param what_action: what action the pet should do. + :type what_action: str + :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 + + # response body for status code(s): 200 + response.json() == { + "actionResponse": "str (optional)" + } + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/errorStatusCodes/Pets/doSomething/{whatAction}") + path_format_arguments = { + "whatAction": _SERIALIZER.url("what_action", what_action, "str"), + } + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, **kwargs) + + +def build_has_models_param_request(*, models: Optional[str] = "value1", **kwargs: Any) -> HttpRequest: + """Ensure you can correctly deserialize the returned PetActionError and deserialization doesn't + conflict with the input param name 'models'. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :keyword models: Make sure model deserialization doesn't conflict with this param name, which + has input name 'models'. Use client default value in call. + :paramtype models: str + :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 + """ + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", "/errorStatusCodes/Pets/hasModelsParam") + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if models is not None: + query_parameters["models"] = _SERIALIZER.query("models", models, "str") + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=url, params=query_parameters, headers=header_parameters, **kwargs) diff --git a/test/vanilla/low-level/UpdateAcceptanceTests/asynctests/test_required_to_optional_async.py b/test/vanilla/low-level/UpdateAcceptanceTests/asynctests/test_required_to_optional_async.py new file mode 100644 index 00000000000..eaee6acc99d --- /dev/null +++ b/test/vanilla/low-level/UpdateAcceptanceTests/asynctests/test_required_to_optional_async.py @@ -0,0 +1,49 @@ + +# -------------------------------------------------------------------------- +# +# 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 async_generator import yield_, async_generator + + +from llcpackagelowlevel.aio import LLCClient +from llcpackagelowlevel.rest.params import build_get_required_request + +@pytest.fixture +@async_generator +async def client(): + async with LLCClient(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.mark.asyncio +async def test_required_to_optional(client): + request = build_get_required_request( + parameter1="foo", + parameter2="foo", + parameter3="foo", + ) + response = await client.send_request(request) + assert response.status_code == 200 + \ No newline at end of file diff --git a/test/vanilla/low-level/UpdateAcceptanceTests/conftest.py b/test/vanilla/low-level/UpdateAcceptanceTests/conftest.py new file mode 100644 index 00000000000..8e287c175bb --- /dev/null +++ b/test/vanilla/low-level/UpdateAcceptanceTests/conftest.py @@ -0,0 +1,59 @@ +# -------------------------------------------------------------------------- +# +# 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 +import sys +import subprocess +import os +import signal +from os.path import dirname, realpath +cwd = dirname(realpath(__file__)) + +#Ideally this would be in a common helper library shared between the tests +def start_server_process(): + cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd) + if os.name == 'nt': #On windows, subprocess creation works without being in the shell + return subprocess.Popen(cmd) + + return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) #On linux, have to set shell=True + +#Ideally this would be in a common helper library shared between the tests +def terminate_server_process(process): + if os.name == 'nt': + process.kill() + else: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups + +@pytest.fixture(scope="session") +def testserver(): + """Start the Autorest testserver.""" + server = start_server_process() + yield + terminate_server_process(server) + +# Ignore collection of async tests for Python 2 +collect_ignore = [] +if sys.version_info < (3,5): + collect_ignore.append("asynctests") diff --git a/test/vanilla/low-level/UpdateAcceptanceTests/test_required_to_optional.py b/test/vanilla/low-level/UpdateAcceptanceTests/test_required_to_optional.py new file mode 100644 index 00000000000..8c4a86ec30b --- /dev/null +++ b/test/vanilla/low-level/UpdateAcceptanceTests/test_required_to_optional.py @@ -0,0 +1,47 @@ + +# -------------------------------------------------------------------------- +# +# 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 llcpackagelowlevel import LLCClient +from llcpackagelowlevel.rest.params import build_get_required_request + + +@pytest.fixture +def client(): + with LLCClient(base_url="http://localhost:3000") as client: + yield client + + +def test_required_to_optional(client): + request = build_get_required_request( + parameter1="foo", + parameter2="foo", + parameter3="foo", + ) + response = client.send_request(request) + assert response.status_code == 200 \ No newline at end of file diff --git a/test/vanilla/low-level/coverage/report-optional.json b/test/vanilla/low-level/coverage/report-optional.json new file mode 100644 index 00000000000..a283e45cc2b --- /dev/null +++ b/test/vanilla/low-level/coverage/report-optional.json @@ -0,0 +1,48 @@ +{ + "StreamUploadFile": 109, + "UpdatePetWithForm": 0, + "getDecimalInvalid": 20, + "getDecimalBig": 20, + "getDecimalSmall": 20, + "getDecimalBigPositiveDecimal": 20, + "getDecimalBigNegativeDecimal": 20, + "putDecimalBig": 20, + "putDecimalSmall": 20, + "putDecimalBigPositiveDecimal": 20, + "putDecimalBigNegativeDecimal": 2, + "putDateTimeMaxUtc7MS": 0, + "getDateTimeMaxUtc7MSUppercase": 27, + "putDateTimeMaxLocalPositiveOffset": 27, + "putDateTimeMaxLocalNegativeOffset": 0, + "putDateTimeMinLocalPositiveOffset": 0, + "putDateTimeMinLocalNegativeOffset": 27, + "HeaderParameterProtectedKey": 1, + "CustomHeaderInRequest": 2, + "FormdataStreamUploadFile": 58, + "HttpSuccess200Options": 0, + "HttpRedirect307Options": 0, + "HttpRetry502Options": 0, + "HttpClientFailure400Options": 0, + "HttpClientFailure403Options": 0, + "HttpClientFailure412Options": 0, + "ResponsesScenarioNoModelEmptyBody": 23, + "sendErrorWithParamNameModels": 4, + "MultiapiPutTestOneApiVersionOne": 0, + "MultiapiPutTestOneApiVersionTwo": 0, + "MultiapiGetTestTwoApiVersionOne": 0, + "MultiapiGetTestTwoApiVersionTwo": 0, + "MultiapiGetTestTwoApiVersionThree": 0, + "MultiapiPutTestThreeApiVersionTwo": 0, + "MultiapiPostTestFourApiVersionTwo": 0, + "MultiapiPostTestFourApiVersionThreeJSON": 0, + "MultiapiPostTestFourApiVersionThreePDF": 0, + "MultiapiPutTestFiveApiVersionThree": 0, + "MultiapiLRO": 0, + "MultiapiPaging": 0, + "MultiapiLROAndPaging": 0, + "MultiapiDifferentCallsApiVersionOne": 0, + "MultiapiDifferentCallsApiVersionTwo": 0, + "MultiapiDifferentCallsApiVersionThree": 0, + "MultiapiCustomBaseUrlApiVersionOne": 0, + "MultiapiCustomBaseUrlApiVersionTwo": 0 +} \ No newline at end of file diff --git a/test/vanilla/low-level/coverage/report-vanilla.json b/test/vanilla/low-level/coverage/report-vanilla.json new file mode 100644 index 00000000000..62cd38b733b --- /dev/null +++ b/test/vanilla/low-level/coverage/report-vanilla.json @@ -0,0 +1,607 @@ +{ + "GetStringAsAnything": 0, + "PutStringAsAnything": 0, + "GetObjectAsAnything": 0, + "PutObjectAsAnything": 0, + "GetArrayAsAnything": 0, + "PutArrayAsAnything": 0, + "verifyIncorrectErrorParsing": 0, + "LLCRequiredToOptional": 2, + "MediaTypesAnalyzeBodyNoAcceptHeader": 0, + "verifyHost": 0, + "ImplicitOptionalBinaryBody": 0, + "ExplicitOptionalBinaryBody": 0, + "ExplicitRequiredBinaryBody": 0, + "OptionalImplicitBody": 0, + "GeneralOptional": 0, + "OptionalImplicitHeader": 0, + "OptionalImplicitQuery": 0, + "OptionalGlobalQuery": 0, + "getStringNull": 0, + "putStringNull": 0, + "getStringEmpty": 0, + "putStringEmpty": 0, + "getStringNotProvided": 0, + "getStringWithLeadingAndTrailingWhitespace": 0, + "putStringWithLeadingAndTrailingWhitespace": 0, + "getStringBase64UrlEncoded": 0, + "putStringBase64UrlEncoded": 0, + "getStringBase64Encoded": 0, + "getStringNullBase64UrlEncoding": 0, + "getStringMultiByteCharacters": 0, + "putStringMultiByteCharacters": 0, + "getEnumNotExpandable": 0, + "putEnumNotExpandable": 0, + "getEnumReferenced": 0, + "putEnumReferenced": 0, + "getEnumReferencedConstant": 0, + "putEnumReferencedConstant": 0, + "XmlGetBytes": 0, + "XmlPutBytes": 0, + "XmlGetUrl": 0, + "XmlPutUrl": 0, + "additionalPropertiesTrue": 0, + "additionalPropertiesSubclass": 0, + "additionalPropertiesTypeObject": 0, + "additionalPropertiesTypeString": 0, + "additionalPropertiesInProperties": 0, + "additionalPropertiesInPropertiesWithAPTypeString": 0, + "getArrayNull": 0, + "getArrayEmpty": 0, + "putArrayEmpty": 0, + "getArrayInvalid": 0, + "getArrayBooleanValid": 0, + "putArrayBooleanValid": 0, + "getArrayBooleanWithNull": 0, + "getArrayBooleanWithString": 0, + "getArrayIntegerValid": 0, + "putArrayIntegerValid": 0, + "getArrayIntegerWithNull": 0, + "getArrayIntegerWithString": 0, + "getArrayLongValid": 0, + "putArrayLongValid": 0, + "getArrayLongWithNull": 0, + "getArrayLongWithString": 0, + "getArrayFloatValid": 0, + "putArrayFloatValid": 0, + "getArrayFloatWithNull": 0, + "getArrayFloatWithString": 0, + "getArrayDoubleValid": 0, + "putArrayDoubleValid": 0, + "getArrayDoubleWithNull": 0, + "getArrayDoubleWithString": 0, + "getArrayStringValid": 0, + "putArrayStringValid": 0, + "getArrayEnumValid": 0, + "putArrayEnumValid": 0, + "getArrayStringEnumValid": 0, + "putArrayStringEnumValid": 0, + "getArrayStringWithNull": 0, + "getArrayStringWithNumber": 0, + "getArrayDateValid": 0, + "putArrayDateValid": 0, + "getArrayDateWithNull": 0, + "getArrayDateWithInvalidChars": 0, + "getArrayDateTimeValid": 0, + "putArrayDateTimeValid": 0, + "getArrayDateTimeWithNull": 0, + "getArrayDateTimeWithInvalidChars": 0, + "getArrayDateTimeRfc1123Valid": 0, + "putArrayDateTimeRfc1123Valid": 0, + "getArrayDurationValid": 0, + "putArrayDurationValid": 0, + "getArrayUuidValid": 0, + "getArrayUuidWithInvalidChars": 0, + "putArrayUuidValid": 0, + "getArrayByteValid": 0, + "putArrayByteValid": 0, + "getArrayByteWithNull": 0, + "getArrayArrayNull": 0, + "getArrayArrayEmpty": 0, + "getArrayArrayItemNull": 0, + "getArrayArrayItemEmpty": 0, + "getArrayArrayValid": 0, + "putArrayArrayValid": 0, + "getArrayComplexNull": 0, + "getArrayComplexEmpty": 0, + "getArrayComplexItemNull": 0, + "getArrayComplexItemEmpty": 0, + "getArrayComplexValid": 0, + "putArrayComplexValid": 0, + "getArrayDictionaryNull": 0, + "getArrayDictionaryEmpty": 0, + "getArrayDictionaryItemNull": 0, + "getArrayDictionaryItemEmpty": 0, + "getArrayDictionaryValid": 0, + "putArrayDictionaryValid": 0, + "getBoolTrue": 0, + "putBoolTrue": 0, + "getBoolFalse": 0, + "putBoolFalse": 0, + "getBoolInvalid": 0, + "getBoolNull": 0, + "getByteNull": 0, + "getByteEmpty": 0, + "getByteNonAscii": 0, + "putByteNonAscii": 0, + "getByteInvalid": 0, + "getDateNull": 0, + "getDateInvalid": 0, + "getDateOverflow": 0, + "getDateUnderflow": 0, + "getDateMax": 0, + "putDateMax": 0, + "getDateMin": 0, + "putDateMin": 0, + "getDateTimeNull": 0, + "getDateTimeInvalid": 0, + "getDateTimeOverflow": 0, + "getDateTimeUnderflow": 0, + "putDateTimeMaxUtc": 0, + "getDateTimeMaxUtcLowercase": 0, + "getDateTimeMaxUtcUppercase": 0, + "getDateTimeMaxLocalPositiveOffsetLowercase": 0, + "getDateTimeMaxLocalPositiveOffsetUppercase": 0, + "getDateTimeMaxLocalNegativeOffsetLowercase": 0, + "getDateTimeMaxLocalNegativeOffsetUppercase": 0, + "getDateTimeMinUtc": 0, + "putDateTimeMinUtc": 0, + "getDateTimeMinLocalPositiveOffset": 0, + "getDateTimeMinLocalNegativeOffset": 0, + "getDateTimeRfc1123Null": 0, + "getDateTimeRfc1123Invalid": 0, + "getDateTimeRfc1123Overflow": 0, + "getDateTimeRfc1123Underflow": 0, + "getDateTimeRfc1123MinUtc": 0, + "putDateTimeRfc1123Max": 0, + "putDateTimeRfc1123Min": 0, + "getDateTimeRfc1123MaxUtcLowercase": 0, + "getDateTimeRfc1123MaxUtcUppercase": 0, + "getIntegerNull": 0, + "getIntegerInvalid": 0, + "getIntegerOverflow": 0, + "getIntegerUnderflow": 0, + "getLongOverflow": 0, + "getLongUnderflow": 0, + "putIntegerMax": 0, + "putLongMax": 0, + "putIntegerMin": 0, + "putLongMin": 0, + "getNumberNull": 0, + "getFloatInvalid": 0, + "getDoubleInvalid": 0, + "getFloatBigScientificNotation": 0, + "putFloatBigScientificNotation": 0, + "getDoubleBigScientificNotation": 0, + "putDoubleBigScientificNotation": 0, + "getDoubleBigPositiveDecimal": 0, + "putDoubleBigPositiveDecimal": 0, + "getDoubleBigNegativeDecimal": 0, + "putDoubleBigNegativeDecimal": 0, + "getFloatSmallScientificNotation": 0, + "putFloatSmallScientificNotation": 0, + "getDoubleSmallScientificNotation": 0, + "putDoubleSmallScientificNotation": 0, + "putComplexBasicValid": 0, + "getComplexBasicValid": 0, + "getComplexBasicEmpty": 0, + "getComplexBasicNotProvided": 0, + "getComplexBasicNull": 0, + "getComplexBasicInvalid": 0, + "putComplexPrimitiveInteger": 0, + "putComplexPrimitiveLong": 0, + "putComplexPrimitiveFloat": 0, + "putComplexPrimitiveDouble": 0, + "putComplexPrimitiveBool": 0, + "putComplexPrimitiveString": 0, + "putComplexPrimitiveDate": 0, + "putComplexPrimitiveDateTime": 0, + "putComplexPrimitiveDateTimeRfc1123": 0, + "putComplexPrimitiveDuration": 0, + "putComplexPrimitiveByte": 0, + "getComplexPrimitiveInteger": 0, + "getComplexPrimitiveLong": 0, + "getComplexPrimitiveFloat": 0, + "getComplexPrimitiveDouble": 0, + "getComplexPrimitiveBool": 0, + "getComplexPrimitiveString": 0, + "getComplexPrimitiveDate": 0, + "getComplexPrimitiveDateTime": 0, + "getComplexPrimitiveDateTimeRfc1123": 0, + "getComplexPrimitiveDuration": 0, + "getComplexPrimitiveByte": 0, + "putComplexArrayValid": 0, + "putComplexArrayEmpty": 0, + "getComplexArrayValid": 0, + "getComplexArrayEmpty": 0, + "getComplexArrayNotProvided": 0, + "putComplexDictionaryValid": 0, + "putComplexDictionaryEmpty": 0, + "getComplexDictionaryValid": 0, + "getComplexDictionaryEmpty": 0, + "getComplexDictionaryNull": 0, + "getComplexDictionaryNotProvided": 0, + "putComplexInheritanceValid": 0, + "getComplexInheritanceValid": 0, + "putComplexPolymorphismValid": 0, + "getComplexPolymorphismValid": 0, + "putComplexPolymorphismComplicated": 0, + "getComplexPolymorphismComplicated": 0, + "putComplexPolymorphismNoDiscriminator": 0, + "putComplexPolymorphicRecursiveValid": 0, + "getComplexPolymorphicRecursiveValid": 0, + "putComplexReadOnlyPropertyValid": 0, + "getComplexReadOnlyPropertyValid": 0, + "UrlPathsBoolFalse": 0, + "UrlPathsBoolTrue": 0, + "UrlPathsIntPositive": 0, + "UrlPathsIntNegative": 0, + "UrlPathsLongPositive": 0, + "UrlPathsLongNegative": 0, + "UrlPathsFloatPositive": 0, + "UrlPathsFloatNegative": 0, + "UrlPathsDoublePositive": 0, + "UrlPathsDoubleNegative": 0, + "UrlPathsStringUrlEncoded": 0, + "UrlPathsStringUrlNonEncoded": 0, + "UrlPathsStringEmpty": 0, + "UrlPathsStringUnicode": 0, + "UrlPathsEnumValid": 0, + "UrlPathsByteMultiByte": 0, + "UrlPathsByteEmpty": 0, + "UrlPathsDateValid": 0, + "UrlPathsDateTimeValid": 0, + "UrlQueriesBoolFalse": 0, + "UrlQueriesBoolTrue": 0, + "UrlQueriesBoolNull": 0, + "UrlQueriesIntPositive": 0, + "UrlQueriesIntNegative": 0, + "UrlQueriesIntNull": 0, + "UrlQueriesLongPositive": 0, + "UrlQueriesLongNegative": 0, + "UrlQueriesLongNull": 0, + "UrlQueriesFloatPositive": 0, + "UrlQueriesFloatNegative": 0, + "UrlQueriesFloatNull": 0, + "UrlQueriesDoublePositive": 0, + "UrlQueriesDoubleNegative": 0, + "UrlQueriesDoubleNull": 0, + "UrlQueriesStringUrlEncoded": 0, + "UrlQueriesStringEmpty": 0, + "UrlQueriesStringNull": 0, + "UrlQueriesStringUnicode": 0, + "UrlQueriesEnumValid": 0, + "UrlQueriesEnumNull": 0, + "UrlQueriesByteMultiByte": 0, + "UrlQueriesByteEmpty": 0, + "UrlQueriesByteNull": 0, + "UrlQueriesDateValid": 0, + "UrlQueriesDateNull": 0, + "UrlQueriesDateTimeValid": 0, + "UrlQueriesDateTimeNull": 0, + "UrlQueriesArrayCsvNull": 0, + "UrlQueriesArrayCsvEmpty": 0, + "UrlQueriesArrayCsvValid": 0, + "UrlQueriesArrayMultiNull": 0, + "UrlQueriesArrayMultiEmpty": 0, + "UrlQueriesArrayMultiValid": 0, + "UrlQueriesArraySsvValid": 0, + "UrlQueriesArrayPipesValid": 0, + "UrlQueriesArrayTsvValid": 0, + "UrlQueriesArrayNoCollectionFormatValid": 0, + "UrlPathItemGetAll": 0, + "UrlPathItemGetGlobalNull": 0, + "UrlPathItemGetGlobalAndLocalNull": 0, + "UrlPathItemGetPathItemAndLocalNull": 0, + "putDictionaryEmpty": 0, + "getDictionaryNull": 0, + "getDictionaryEmpty": 0, + "getDictionaryInvalid": 0, + "getDictionaryNullValue": 0, + "getDictionaryNullkey": 0, + "getDictionaryKeyEmptyString": 0, + "getDictionaryBooleanValid": 0, + "getDictionaryBooleanWithNull": 0, + "getDictionaryBooleanWithString": 0, + "getDictionaryIntegerValid": 0, + "getDictionaryIntegerWithNull": 0, + "getDictionaryIntegerWithString": 0, + "getDictionaryLongValid": 0, + "getDictionaryLongWithNull": 0, + "getDictionaryLongWithString": 0, + "getDictionaryFloatValid": 0, + "getDictionaryFloatWithNull": 0, + "getDictionaryFloatWithString": 0, + "getDictionaryDoubleValid": 0, + "getDictionaryDoubleWithNull": 0, + "getDictionaryDoubleWithString": 0, + "getDictionaryStringValid": 0, + "getDictionaryStringWithNull": 0, + "getDictionaryStringWithNumber": 0, + "getDictionaryDateValid": 0, + "getDictionaryDateWithNull": 0, + "getDictionaryDateWithInvalidChars": 0, + "getDictionaryDateTimeValid": 0, + "getDictionaryDateTimeWithNull": 0, + "getDictionaryDateTimeWithInvalidChars": 0, + "getDictionaryDateTimeRfc1123Valid": 0, + "getDictionaryDurationValid": 0, + "getDictionaryByteValid": 0, + "getDictionaryByteWithNull": 0, + "putDictionaryBooleanValid": 0, + "putDictionaryIntegerValid": 0, + "putDictionaryLongValid": 0, + "putDictionaryFloatValid": 0, + "putDictionaryDoubleValid": 0, + "putDictionaryStringValid": 0, + "putDictionaryDateValid": 0, + "putDictionaryDateTimeValid": 0, + "putDictionaryDateTimeRfc1123Valid": 0, + "putDictionaryDurationValid": 0, + "putDictionaryByteValid": 0, + "getDictionaryComplexNull": 0, + "getDictionaryComplexEmpty": 0, + "getDictionaryComplexItemNull": 0, + "getDictionaryComplexItemEmpty": 0, + "getDictionaryComplexValid": 0, + "putDictionaryComplexValid": 0, + "getDictionaryArrayNull": 0, + "getDictionaryArrayEmpty": 0, + "getDictionaryArrayItemNull": 0, + "getDictionaryArrayItemEmpty": 0, + "getDictionaryArrayValid": 0, + "putDictionaryArrayValid": 0, + "getDictionaryDictionaryNull": 0, + "getDictionaryDictionaryEmpty": 0, + "getDictionaryDictionaryItemNull": 0, + "getDictionaryDictionaryItemEmpty": 0, + "getDictionaryDictionaryValid": 0, + "putDictionaryDictionaryValid": 0, + "putDurationPositive": 0, + "getDurationNull": 0, + "getDurationInvalid": 0, + "getDurationPositive": 0, + "HeaderParameterExistingKey": 0, + "HeaderResponseExistingKey": 0, + "HeaderResponseProtectedKey": 0, + "HeaderParameterIntegerPositive": 0, + "HeaderParameterIntegerNegative": 0, + "HeaderParameterLongPositive": 0, + "HeaderParameterLongNegative": 0, + "HeaderParameterFloatPositive": 0, + "HeaderParameterFloatNegative": 0, + "HeaderParameterDoublePositive": 0, + "HeaderParameterDoubleNegative": 0, + "HeaderParameterBoolTrue": 0, + "HeaderParameterBoolFalse": 0, + "HeaderParameterStringValid": 0, + "HeaderParameterStringNull": 0, + "HeaderParameterStringEmpty": 0, + "HeaderParameterDateValid": 0, + "HeaderParameterDateMin": 0, + "HeaderParameterDateTimeValid": 0, + "HeaderParameterDateTimeMin": 0, + "HeaderParameterDateTimeRfc1123Valid": 0, + "HeaderParameterDateTimeRfc1123Min": 0, + "HeaderParameterBytesValid": 0, + "HeaderParameterDurationValid": 0, + "HeaderResponseIntegerPositive": 0, + "HeaderResponseIntegerNegative": 0, + "HeaderResponseLongPositive": 0, + "HeaderResponseLongNegative": 0, + "HeaderResponseFloatPositive": 0, + "HeaderResponseFloatNegative": 0, + "HeaderResponseDoublePositive": 0, + "HeaderResponseDoubleNegative": 0, + "HeaderResponseBoolTrue": 0, + "HeaderResponseBoolFalse": 0, + "HeaderResponseStringValid": 0, + "HeaderResponseStringNull": 0, + "HeaderResponseStringEmpty": 0, + "HeaderParameterEnumValid": 0, + "HeaderParameterEnumNull": 0, + "HeaderResponseEnumValid": 0, + "HeaderResponseEnumNull": 0, + "HeaderResponseDateValid": 0, + "HeaderResponseDateMin": 0, + "HeaderResponseDateTimeValid": 0, + "HeaderResponseDateTimeMin": 0, + "HeaderResponseDateTimeRfc1123Valid": 0, + "HeaderResponseDateTimeRfc1123Min": 0, + "HeaderResponseBytesValid": 0, + "HeaderResponseDurationValid": 0, + "ConstantsInPath": 0, + "ConstantsInBody": 0, + "CustomBaseUri": 0, + "CustomBaseUriMoreOptions": 0, + "getModelFlattenArray": 0, + "putModelFlattenArray": 0, + "getModelFlattenDictionary": 0, + "putModelFlattenDictionary": 0, + "getModelFlattenResourceCollection": 0, + "putModelFlattenResourceCollection": 0, + "putModelFlattenCustomBase": 0, + "postModelFlattenCustomParameter": 0, + "putModelFlattenCustomGroupedParameter": 0, + "getArrayBase64Url": 0, + "getDictionaryBase64Url": 0, + "UrlPathsStringBase64Url": 0, + "UrlPathsArrayCSVInPath": 0, + "getUnixTime": 0, + "getInvalidUnixTime": 0, + "getNullUnixTime": 0, + "putUnixTime": 0, + "UrlPathsIntUnixTime": 0, + "expectedEnum": 0, + "unexpectedEnum": 0, + "allowedValueEnum": 0, + "roundTripEnum": 0, + "expectedNoErrors": 0, + "expectedPetSadError": 0, + "expectedPetHungryError": 0, + "intError": 0, + "stringError": 0, + "animalNotFoundError": 0, + "linkNotFoundError": 0, + "getDateTimeMinLocalNoOffset": 0, + "getComplexPolymorphismDotSyntax": 0, + "getComposedWithDiscriminator": 0, + "getComposedWithoutDiscriminator": 0, + "FileStreamNonempty": 0, + "FileStreamVeryLarge": 0, + "FileStreamEmpty": 0, + "HttpSuccess200Head": 0, + "HttpSuccess200Get": 0, + "HttpSuccess200Put": 0, + "HttpSuccess200Post": 0, + "HttpSuccess200Patch": 0, + "HttpSuccess200Delete": 0, + "HttpSuccess201Put": 0, + "HttpSuccess201Post": 0, + "HttpSuccess202Put": 0, + "HttpSuccess202Post": 0, + "HttpSuccess202Patch": 0, + "HttpSuccess202Delete": 0, + "HttpSuccess204Head": 0, + "HttpSuccess404Head": 0, + "HttpSuccess204Put": 0, + "HttpSuccess204Post": 0, + "HttpSuccess204Patch": 0, + "HttpSuccess204Delete": 0, + "HttpRedirect300Head": 0, + "HttpRedirect300Get": 0, + "HttpRedirect301Put": 0, + "HttpRedirect301Get": 0, + "HttpRedirect302Head": 0, + "HttpRedirect302Get": 0, + "HttpRedirect302Patch": 0, + "HttpRedirect303Post": 0, + "HttpRedirect307Head": 0, + "HttpRedirect307Get": 0, + "HttpRedirect307Put": 0, + "HttpRedirect307Post": 0, + "HttpRedirect307Patch": 0, + "HttpRedirect307Delete": 0, + "HttpRetry408Head": 0, + "HttpRetry500Put": 0, + "HttpRetry500Patch": 0, + "HttpRetry502Get": 0, + "HttpRetry503Post": 0, + "HttpRetry503Delete": 0, + "HttpRetry504Put": 0, + "HttpRetry504Patch": 0, + "HttpClientFailure400Head": 0, + "HttpClientFailure400Get": 0, + "HttpClientFailure400Put": 0, + "HttpClientFailure400Post": 0, + "HttpClientFailure400Patch": 0, + "HttpClientFailure400Delete": 0, + "HttpClientFailure401Head": 0, + "HttpClientFailure402Get": 0, + "HttpClientFailure403Get": 0, + "HttpClientFailure404Put": 0, + "HttpClientFailure405Patch": 0, + "HttpClientFailure406Post": 0, + "HttpClientFailure407Delete": 0, + "HttpClientFailure409Put": 0, + "HttpClientFailure410Head": 0, + "HttpClientFailure411Get": 0, + "HttpClientFailure412Get": 0, + "HttpClientFailure413Put": 0, + "HttpClientFailure414Patch": 0, + "HttpClientFailure415Post": 0, + "HttpClientFailure416Get": 0, + "HttpClientFailure417Delete": 0, + "HttpClientFailure429Head": 0, + "HttpServerFailure501Head": 0, + "HttpServerFailure501Get": 0, + "HttpServerFailure505Post": 0, + "HttpServerFailure505Delete": 0, + "ResponsesScenarioA200MatchingModel": 0, + "ResponsesScenarioA204MatchingNoModel": 0, + "ResponsesScenarioA201DefaultNoModel": 0, + "ResponsesScenarioA202DefaultNoModel": 0, + "ResponsesScenarioA400DefaultModel": 0, + "ResponsesScenarioB200MatchingModel": 0, + "ResponsesScenarioB201MatchingModel": 0, + "ResponsesScenarioB400DefaultModel": 0, + "ResponsesScenarioC200MatchingModel": 0, + "ResponsesScenarioC201MatchingModel": 0, + "ResponsesScenarioC404MatchingModel": 0, + "ResponsesScenarioC400DefaultModel": 0, + "ResponsesScenarioD202MatchingNoModel": 0, + "ResponsesScenarioD204MatchingNoModel": 0, + "ResponsesScenarioD400DefaultModel": 0, + "ResponsesScenarioE202MatchingInvalid": 0, + "ResponsesScenarioE204MatchingNoModel": 0, + "ResponsesScenarioE400DefaultNoModel": 0, + "ResponsesScenarioE400DefaultInvalid": 0, + "ResponsesScenarioF200DefaultModel": 0, + "ResponsesScenarioF200DefaultNone": 0, + "ResponsesScenarioF400DefaultModel": 0, + "ResponsesScenarioF400DefaultNone": 0, + "ResponsesScenarioG200DefaultInvalid": 0, + "ResponsesScenarioG200DefaultNoModel": 0, + "ResponsesScenarioG400DefaultInvalid": 0, + "ResponsesScenarioG400DefaultNoModel": 0, + "ResponsesScenarioH200MatchingNone": 0, + "ResponsesScenarioH200MatchingModel": 0, + "ResponsesScenarioH200MatchingInvalid": 0, + "ResponsesScenarioH400NonMatchingNone": 0, + "ResponsesScenarioH400NonMatchingModel": 0, + "ResponsesScenarioH400NonMatchingInvalid": 0, + "ResponsesScenarioH202NonMatchingModel": 0, + "ResponsesScenarioEmptyErrorBody": 0, + "ResponsesScenarioNoModelErrorBody": 0, + "MediaTypeJson": 0, + "MediaTypePdf": 0, + "MediaTypeWithEncoding": 0, + "StorageListContainersXML": 0, + "StorageGetServicePropertiesXML": 0, + "StoragePutServicePropertiesXML": 0, + "StorageGetContainerACLXML": 0, + "StorageListBlobsXML": 0, + "StoragePutContainerACLXML": 0, + "GetSimpleXML": 0, + "PutSimpleXML": 0, + "GetWrappedXMLList": 0, + "PutWrappedXMLList": 0, + "GetEmptyXMLList": 0, + "PutEmptyXMLList": 0, + "GetEmptyWrappedXMLList": 0, + "PutEmptyWrappedXMLList": 0, + "GetXMLListAtRoot": 0, + "PutXMLListAtRoot": 0, + "GetXMLListAtRootSingle": 0, + "PutXMLListAtRootSingle": 0, + "GetEmptyXMLListAtRoot": 0, + "PutEmptyXMLListAtRoot": 0, + "GetXMLEmptyNode": 0, + "PutXMLEmptyNode": 0, + "GetRootWithRefAndNoMetaXML": 0, + "PutRootWithRefAndNoMetaXML": 0, + "GetRootWithRefAndMetaXML": 0, + "PutRootWithRefAndMetaXML": 0, + "jsonInputInXMLSwagger": 0, + "jsonOutputInXMLSwagger": 0, + "GetWithXMsText": 0, + "ObjectTypeResponse": 0, + "ObjectTypePut": 0, + "ObjectTypeErrorResponse": 0, + "NonStringEnumsPostInt": 0, + "NonStringEnumsGetInt": 0, + "NonStringEnumsPostFloat": 0, + "NonStringEnumsGetFloat": 0, + "BodyTimeGet": 0, + "BodyTimePut": 0, + "MultipleInheritancePetGet": 0, + "MultipleInheritancePetPut": 0, + "MultipleInheritanceHorseGet": 0, + "MultipleInheritanceHorsePut": 0, + "MultipleInheritanceFelineGet": 0, + "MultipleInheritanceFelinePut": 0, + "MultipleInheritanceCatGet": 0, + "MultipleInheritanceCatPut": 0, + "MultipleInheritanceKittenGet": 0, + "MultipleInheritanceKittenPut": 0 +} \ No newline at end of file diff --git a/test/vanilla/low-level/initial_requirements.txt b/test/vanilla/low-level/initial_requirements.txt new file mode 100644 index 00000000000..daac7f2f8fa --- /dev/null +++ b/test/vanilla/low-level/initial_requirements.txt @@ -0,0 +1,9 @@ +requests>=2.14.0 +pytest +pytest-cov +pytest-asyncio==0.14.0;python_full_version>="3.5.2" +async_generator;python_full_version>="3.5.2" +msrest>=0.6.21 +azure-core>=1.3.0 +aiohttp;python_full_version>="3.5.2" +-e ./Expected/AcceptanceTests/LLCInitialLowLevel/ \ No newline at end of file diff --git a/test/vanilla/low-level/requirements.txt b/test/vanilla/low-level/requirements.txt new file mode 100644 index 00000000000..2c9e572ca4b --- /dev/null +++ b/test/vanilla/low-level/requirements.txt @@ -0,0 +1,45 @@ +requests>=2.14.0 +pytest +pytest-cov +pytest-asyncio==0.14.0;python_full_version>="3.5.2" +async_generator;python_full_version>="3.5.2" +msrest>=0.6.21 +azure-core>=1.3.0 +aiohttp;python_full_version>="3.5.2" +-e ./Expected/AcceptanceTests/AdditionalPropertiesLowLevel +-e ./Expected/AcceptanceTests/AnythingLowLevel +-e ./Expected/AcceptanceTests/BodyArrayLowLevel +-e ./Expected/AcceptanceTests/BodyBooleanLowLevel +-e ./Expected/AcceptanceTests/BodyByteLowLevel +-e ./Expected/AcceptanceTests/BodyComplexLowLevel +-e ./Expected/AcceptanceTests/BodyDateLowLevel +-e ./Expected/AcceptanceTests/BodyDateTimeLowLevel +-e ./Expected/AcceptanceTests/BodyDateTimeRfc1123LowLevel +-e ./Expected/AcceptanceTests/BodyDictionaryLowLevel +-e ./Expected/AcceptanceTests/BodyDurationLowLevel +-e ./Expected/AcceptanceTests/BodyFileLowLevel +-e ./Expected/AcceptanceTests/BodyFormDataLowLevel +-e ./Expected/AcceptanceTests/BodyIntegerLowLevel +-e ./Expected/AcceptanceTests/BodyNumberLowLevel +-e ./Expected/AcceptanceTests/BodyStringLowLevel +-e ./Expected/AcceptanceTests/BodyTimeLowLevel +-e ./Expected/AcceptanceTests/CustomBaseUriLowLevel +-e ./Expected/AcceptanceTests/CustomBaseUriMoreOptionsLowLevel +-e ./Expected/AcceptanceTests/ExtensibleEnumsLowLevel +-e ./Expected/AcceptanceTests/HeaderLowLevel +-e ./Expected/AcceptanceTests/HttpLowLevel +-e ./Expected/AcceptanceTests/IncorrectErrorResponseLowLevel +-e ./Expected/AcceptanceTests/MediaTypesLowLevel +-e ./Expected/AcceptanceTests/ModelFlatteningLowLevel +-e ./Expected/AcceptanceTests/MultipleInheritanceLowLevel +-e ./Expected/AcceptanceTests/NoOperationsLowLevel +-e ./Expected/AcceptanceTests/NonStringEnumsLowLevel +-e ./Expected/AcceptanceTests/ObjectTypeLowLevel +-e ./Expected/AcceptanceTests/ParameterFlatteningLowLevel +-e ./Expected/AcceptanceTests/ReportLowLevel +-e ./Expected/AcceptanceTests/RequiredOptionalLowLevel +-e ./Expected/AcceptanceTests/UrlLowLevel +-e ./Expected/AcceptanceTests/UrlMultiCollectionFormatLowLevel +-e ./Expected/AcceptanceTests/ValidationLowLevel +-e ./Expected/AcceptanceTests/XmlLowLevel +-e ./Expected/AcceptanceTests/XmsErrorResponseLowLevel \ No newline at end of file diff --git a/test/vanilla/low-level/tox.ini b/test/vanilla/low-level/tox.ini new file mode 100644 index 00000000000..9f1a7f3490e --- /dev/null +++ b/test/vanilla/low-level/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist=py27, py36 +skipsdist=True + +[testenv] +deps= + -rrequirements.txt + coverage +commands= + pytest --cov=Expected + +[testenv:initial-ci] +deps= + -rinitial_requirements.txt +commands = + pytest --cov=Expected UpdateAcceptanceTests + +[testenv:update-ci] +deps= + -rupdate_requirements.txt +commands = + pytest --cov=Expected UpdateAcceptanceTests + +[testenv:ci] +deps= + -rrequirements.txt + coverage==4.5.4 + pytest-cov +commands = + pytest --cov=Expected AcceptanceTests diff --git a/test/vanilla/low-level/update_requirements.txt b/test/vanilla/low-level/update_requirements.txt new file mode 100644 index 00000000000..ea97006573e --- /dev/null +++ b/test/vanilla/low-level/update_requirements.txt @@ -0,0 +1,9 @@ +requests>=2.14.0 +pytest +pytest-cov +pytest-asyncio==0.14.0;python_full_version>="3.5.2" +async_generator;python_full_version>="3.5.2" +msrest>=0.6.21 +azure-core>=1.3.0 +aiohttp;python_full_version>="3.5.2" +-e ./Expected/AcceptanceTests/LLCUpdateOneLowLevel \ No newline at end of file diff --git a/test/vanilla/packages.config b/test/vanilla/packages.config deleted file mode 100644 index 2d5c663a425..00000000000 --- a/test/vanilla/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file